MENU_FILE_OPEN = 200 class MainFrame < Wx::Frame def initialize super(nil, :title => 'Simulátor hradlové sítě', :size => [400, 300]) # menu menu_bar = Wx::MenuBar.new menu_file = Wx::Menu.new menu_file.append(MENU_FILE_OPEN, "&Otevřít") menu_file.append(Wx::ID_EXIT, "&Zavřít") menu_bar.append(menu_file,"&Soubor") self.menu_bar = menu_bar evt_menu MENU_FILE_OPEN, :on_open evt_menu Wx::ID_EXIT, :on_exit end def on_open(event) dlg = Wx::FileDialog.new(self, "Vybrat soubor", Dir.getwd, '', $wildcard, Wx::OPEN) if dlg.show_modal == Wx::ID_OK paths = dlg.get_paths paths.each { |path| process path } end end def on_exit(event) close end def process(file) begin Net.new(file) rescue => err on_error(err) end end def error_box(error) end end