def __init__(self, name, subtitle, *args, **kwds): self._name = name self._subtitle = subtitle self._cancel = False self._height = 330 if sys.platform.startswith('win') else 300 self._width = 500 kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL wx.Frame.__init__(self, *args, **kwds) self.panel = wx.Panel(self) headline = self._name + ((' — ' + self._subtitle) if self._subtitle else '') self.headline = wx.StaticText(self.panel, wx.ID_ANY, headline, style = wx.ALIGN_CENTER) self.headline.SetFont(wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_BOLD, 0, "Arial")) # For macos, I figured out how to make the background color of the text # box be the same as the rest of the UI elements. That looks nicer for # our purposes (IMHO) than the default (which would be white), but then # we need a divider to separate the headline from the text area. if not sys.platform.startswith('win'): self.divider1 = wx.StaticLine(self.panel, wx.ID_ANY) self.divider1.SetMinSize((self._width, 2)) self.text_area = wx.richtext.RichTextCtrl(self.panel, wx.ID_ANY, size = (self._width, 200), style = wx.TE_MULTILINE | wx.TE_READONLY) # Quit button on the bottom. if not sys.platform.startswith('win'): self.divider2 = wx.StaticLine(self.panel, wx.ID_ANY) self.quit_button = wx.Button(self.panel, label = "Quit") self.quit_button.Bind(wx.EVT_KEY_DOWN, self.on_cancel_or_quit) # On macos, the color of the text background is set to the same as the # rest of the UI panel. I haven't figured out how to do it on Windows. if not sys.platform.startswith('win'): gray = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND) self.text_area.SetBackgroundColour(gray) # Create a simple menu bar. self.menuBar = wx.MenuBar(0) # Add a "File" menu with a quit item. self.fileMenu = wx.Menu() self.exitItem = wx.MenuItem(self.fileMenu, wx.ID_EXIT, "&Exit", wx.EmptyString, wx.ITEM_NORMAL) self.fileMenu.Append(self.exitItem) if sys.platform.startswith('win'): # Only need to add a File menu on Windows. On Macs, wxPython # automatically puts the wx.ID_EXIT item under the app menu. self.menuBar.Append(self.fileMenu, "&File") # Add a "help" menu bar item. self.helpMenu = wx.Menu() self.helpItem = wx.MenuItem(self.helpMenu, wx.ID_HELP, "&Help", wx.EmptyString, wx.ITEM_NORMAL) self.helpMenu.Append(self.helpItem) self.helpMenu.AppendSeparator() self.aboutItem = wx.MenuItem(self.helpMenu, wx.ID_ABOUT, "&About " + self._name, wx.EmptyString, wx.ITEM_NORMAL) self.helpMenu.Append(self.aboutItem) self.menuBar.Append(self.helpMenu, "Help") # Put everything together and bind some keystrokes to events. self.SetMenuBar(self.menuBar) self.Bind(wx.EVT_MENU, self.on_cancel_or_quit, id = self.exitItem.GetId()) self.Bind(wx.EVT_MENU, self.on_help, id = self.helpItem.GetId()) self.Bind(wx.EVT_MENU, self.on_about, id = self.aboutItem.GetId()) self.Bind(wx.EVT_CLOSE, self.on_cancel_or_quit) self.Bind(wx.EVT_BUTTON, self.on_cancel_or_quit, self.quit_button) close_id = wx.NewId() self.Bind(wx.EVT_MENU, self.on_cancel_or_quit, id = close_id) accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('W'), close_id )]) self.SetAcceleratorTable(accel_tbl) # Now that we created all the elements, set layout and placement. self.SetSize((self._width, self._height)) self.SetTitle(self._name) self.outermost_sizer = wx.BoxSizer(wx.VERTICAL) self.outermost_sizer.AddSpacer(5) self.outermost_sizer.Add(self.headline, 0, wx.ALIGN_CENTER, 0) self.outermost_sizer.AddSpacer(5) if not sys.platform.startswith('win'): self.outermost_sizer.Add(self.divider1, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 0) self.outermost_sizer.AddSpacer(5) self.outermost_sizer.Add(self.text_area, 0, wx.EXPAND, 0) self.outermost_sizer.AddSpacer(5) if not sys.platform.startswith('win'): self.outermost_sizer.Add(self.divider2, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 0) self.outermost_sizer.AddSpacer(5) self.outermost_sizer.Add(self.quit_button, 0, wx.BOTTOM | wx.CENTER, 0) self.outermost_sizer.AddSpacer(5) self.SetSizer(self.outermost_sizer) self.Layout() self.Centre() # Finally, hook in message-passing interface. pub.subscribe(self.login_dialog, "login_dialog") pub.subscribe(self.info_message, "info_message") pub.subscribe(self.open_file, "open_file") pub.subscribe(self.save_file, "save_file")
def __init__(self, parent, proj): self.current_matrix = None self.model: AHPProject = proj wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="МАИ проэкт", pos=wx.DefaultPosition, size=wx.Size(1285, 737), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) self.main_menu = wx.MenuBar(0) self.edit_menu = wx.Menu() self.change_mi = wx.MenuItem(self.edit_menu, wx.ID_ANY, "Изменить", wx.EmptyString, wx.ITEM_NORMAL) self.edit_menu.Append(self.change_mi) self.update_ui = wx.MenuItem(self.edit_menu, wx.ID_ANY, "Обновить", wx.EmptyString, wx.ITEM_NORMAL) self.edit_menu.Append(self.update_ui) self.calc_memu = wx.Menu() self.calc_mi = wx.MenuItem(self.calc_memu, wx.ID_ANY, "Вычислить") self.gr_menu = wx.MenuItem(self.calc_memu, wx.ID_ANY, "Показать график") self.calc_memu.Append(self.calc_mi) self.calc_memu.Append(self.gr_menu) self.main_menu.Append(self.edit_menu, "Правка") self.main_menu.Append(self.calc_memu, "Расчеты") self.SetMenuBar(self.main_menu) bSizer2 = wx.BoxSizer(wx.HORIZONTAL) self.m_notebook1 = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), 0) self.m_notebook1.SetMaxSize(wx.Size(300, -1)) self.m_panel1 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), wx.TAB_TRAVERSAL) bSizer5 = wx.BoxSizer(wx.VERTICAL) self.struct_view = wx.TreeCtrl(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.Size(1000, 1000), wx.TR_DEFAULT_STYLE) bSizer5.Add(self.struct_view, 0, wx.ALL, 0) self.m_panel1.SetSizer(bSizer5) self.m_panel1.Layout() bSizer5.Fit(self.m_panel1) self.m_notebook1.AddPage(self.m_panel1, u"Структура", False) bSizer2.Add(self.m_notebook1, 1, wx.EXPAND | wx.ALL, 0) self.m_notebook2 = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(675, -1), 0) self.matrix_edit = wx.ScrolledWindow(self.m_notebook2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL | wx.ALWAYS_SHOW_SB) self.matrix_edit.SetScrollRate(5, 5) self.m_notebook2.AddPage(self.matrix_edit, u"Изменение матриц", True) self.result_win = wx.ScrolledWindow(self.m_notebook2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL) self.result_win.SetScrollRate(5, 5) self.m_notebook2.AddPage(self.result_win, u"отчет", False) bSizer2.Add(self.m_notebook2, 1, wx.EXPAND | wx.ALL, 0) self.m_notebook3 = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.m_notebook3.SetMaxSize(wx.Size(300, -1)) self.m_scrolledWindow7 = wx.ScrolledWindow(self.m_notebook3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL) self.m_scrolledWindow7.SetScrollRate(5, 5) bSizer4 = wx.BoxSizer(wx.VERTICAL) self.props = pg.PropertyGrid(self.m_scrolledWindow7, wx.ID_ANY, wx.DefaultPosition, wx.Size(292, 647), wx.propgrid.PG_DEFAULT_STYLE | wx.propgrid.PG_TOOLTIPS) bSizer4.Add(self.props, 0, wx.ALL, 0) self.m_scrolledWindow7.SetSizer(bSizer4) self.m_scrolledWindow7.Layout() bSizer4.Fit(self.m_scrolledWindow7) self.m_notebook3.AddPage(self.m_scrolledWindow7, u"Свойства", False) bSizer2.Add(self.m_notebook3, 1, wx.EXPAND | wx.ALL, 0) self.SetSizer(bSizer2) self.Layout() self.Centre(wx.BOTH) self.Bind(wx.EVT_MENU, self.calculate, id=self.calc_mi.GetId()) self.Bind(wx.EVT_MENU, self.update, id=self.update_ui.GetId()) self.Bind(wx.EVT_MENU, self.show_chart, id=self.gr_menu.GetId()) self.Bind(wx.EVT_CLOSE, self.accept_close) self.update(None)
def addMenu(self, entry, callback): """ Adds a menu entry in the main GUI menu. entry (str): the complete path for the entry. It should have at least one group specified. If a group is non existing it will automatically be created. To add a keyboard shortcut, add it after a \t. For instance: "View/Fancy acquisition..." or: "New group/Subgroup/The action\tCtrl+A" callback (callable): function to call when that entry is selected. raise ValueError: If the entry doesn't have a group or a name """ # TODO: have a way to disable the menu on some conditions # Either return MenuItem (but cannot be call_in_wx_main anymore) # or pass a BooleanVA which indicate when the menu is enabled, # or just pass a list of tabs where the menu is enabled. # TODO: allow to pass a BooleanVA instead of callable => make it a checkable menu item main_frame = self.main_app.main_frame # Split the entry into groups and entry name path = entry.split("/") if len(path) < 2: raise ValueError("Failed to find a group and a name in '%s'" % (entry,)) # Find or create group and subgroups # Nicely, in wxwidgets, the root level is a different class (MenuBar vs # Menu) with slightly different methods p = path[0] if not p: raise ValueError("Path contains empty group name '%s'" % (p,)) root_group = main_frame.GetMenuBar() sub_group_idx = root_group.FindMenu(p) if sub_group_idx == wx.NOT_FOUND: logging.debug("Creating new menu group %s", p) curr_group = wx.Menu() # Insert as second last to keep 'Help' last menulen = root_group.GetMenuCount() root_group.Insert(menulen - 1, curr_group, p) else: curr_group = root_group.GetMenu(sub_group_idx) # All sub-levels are wx.Menu for p in path[1:-1]: if not p: raise ValueError("Path contains empty group name '%s'" % (p,)) sub_group_id = curr_group.FindItem(p) if sub_group_id == wx.NOT_FOUND: logging.debug("Creating new menu group %s", p) sub_group = wx.Menu() curr_group.AppendSubMenu(sub_group, p) else: mi = curr_group.FindItemById(sub_group_id) sub_group = mi.GetSubMenu() if sub_group is None: raise ValueError("Cannot create menu group %s, which is already an entry" % (p,)) curr_group = sub_group # TODO: if adding for the first time to standard menu, first add a separator # Add the menu item menu_item = curr_group.Append(wx.ID_ANY, path[-1]) # Attach the callback function def menu_callback_wrapper(evt): try: callback() except Exception: logging.exception("Error when processing menu entry %s of plugin %s", path[-1], self) main_frame.Bind(wx.EVT_MENU, menu_callback_wrapper, id=menu_item.Id)
def __init__(self, manager=None): wx.Frame.__init__(self, None, -1, "ODT Chomper 0.9", size=(900, 500)) self.watching = [] self.delim = " " #Let's try to get a proto-digest from a file to memorize the ODT layout if os.path.exists("." + os.path.sep + "odt.layout"): f = open("." + os.path.sep + "odt.layout") lines = f.readlines() f.close() lines = [line.strip() for line in lines] self.digest = odtchomp.Interpreter({}, keys=lines) else: #No file at all! self.digest = None self.exportPath = os.getcwd() self.dt = ODTDropTarget(self) self.SetDropTarget(self.dt) self.manager = manager self.Bind(wx.EVT_CLOSE, self.onClose) #A very simple menubar menubar = wx.MenuBar() about = wx.Menu() about.Append(999, 'About', 'Program information and license') menubar.Append(about, "About") self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.showAbout, id=999) panel = wx.Panel(self, -1) self.panel = panel #OK, I do need a reference to this to send size events later #Point Zero: Major Box Sizer sizer = wx.BoxSizer(wx.VERTICAL) #Deal with import button self.importButton = wx.Button(panel, 1, "Import") sizer.Add(self.importButton, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) self.Bind(wx.EVT_BUTTON, self.importFile, id=1) #Deal with active label self.fileLabel = wx.StaticText(panel, -1, "No File Loaded", style=wx.ALIGN_CENTER) sizer.Add(self.fileLabel, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10) sizer.Add(wx.StaticLine(panel, -1), 0, wx.EXPAND | wx.BOTTOM, 15) #Listboxes! Prepare horizontal sizer tsizer = wx.BoxSizer() #Do left listbox llbsizer = wx.BoxSizer(wx.VERTICAL) lefttitle = wx.StaticText(panel, -1, "Available Data Fields", style=wx.ALIGN_CENTER) self.leftbox = wx.ListBox(panel, 10, choices=[], style=wx.LB_SINGLE) llbsizer.Add(lefttitle, 0, wx.ALIGN_CENTER) llbsizer.Add(self.leftbox, 1, wx.ALIGN_CENTER | wx.EXPAND | wx.TOP, 10) tsizer.Add(llbsizer, 1, wx.ALIGN_CENTER | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) self.leftbox.Bind(wx.EVT_LEFT_DCLICK, self.takeData) midbsizer = wx.BoxSizer(wx.VERTICAL) #Add/Remove Buttons a = wx.Button(panel, 20, "-->") self.Bind(wx.EVT_BUTTON, self.takeData, id=20) b = wx.Button(panel, 21, "<--") self.Bind(wx.EVT_BUTTON, self.puntData, id=21) c = wx.Button(panel, 22, "+All") self.Bind(wx.EVT_BUTTON, self.takeAll, id=22) d = wx.Button(panel, 23, "-All") self.Bind(wx.EVT_BUTTON, self.puntAll, id=23) midbsizer.Add(a, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) midbsizer.Add(b, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) midbsizer.Add(c, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) midbsizer.Add(d, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) #Radio Controls label = wx.StaticText(panel, -1, "File Delimiter") self.spaceDelim = wx.RadioButton(panel, 30, "Space", style=wx.RB_GROUP) self.tabDelim = wx.RadioButton(panel, 31, "Tab") self.commaDelim = wx.RadioButton(panel, 32, "Comma") self.Bind(wx.EVT_RADIOBUTTON, self.setDelim, id=30) self.Bind(wx.EVT_RADIOBUTTON, self.setDelim, id=31) self.Bind(wx.EVT_RADIOBUTTON, self.setDelim, id=32) self.spaceDelim.SetValue(True) midbsizer.Add((-1, 10)) midbsizer.Add(label, 0, wx.ALIGN_CENTER | wx.BOTTOM | wx.TOP, 10) midbsizer.Add(self.spaceDelim, 0, wx.LEFT | wx.BOTTOM, 2) midbsizer.Add(self.tabDelim, 0, wx.LEFT | wx.BOTTOM, 2) midbsizer.Add(self.commaDelim, 0, wx.LEFT | wx.BOTTOM, 2) tsizer.Add(midbsizer, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 10) #Final Listbox rlbsizer = wx.BoxSizer(wx.VERTICAL) righttitle = wx.StaticText(panel, -1, "Exported Data Fields", style=wx.ALIGN_CENTER) self.rightbox = wx.ListBox(panel, 11, choices=[], style=wx.LB_SINGLE) rlbsizer.Add(righttitle, 0, wx.ALIGN_CENTER) rlbsizer.Add(self.rightbox, 1, wx.ALIGN_CENTER | wx.EXPAND | wx.TOP, 10) tsizer.Add(rlbsizer, 1, wx.ALIGN_CENTER | wx.EXPAND | wx.LEFT | wx.RIGHT, 10) self.rightbox.Bind(wx.EVT_LEFT_DCLICK, self.puntData) #U/D buttons udbsizer = wx.BoxSizer(wx.VERTICAL) a = wx.Button(panel, 50, "Move Up") b = wx.Button(panel, 51, "Move Down") self.Bind(wx.EVT_BUTTON, self.bumpUp, id=50) self.Bind(wx.EVT_BUTTON, self.bumpDown, id=51) udbsizer.Add(a, 0, wx.CENTER | wx.BOTTOM, 10) udbsizer.Add(b, 0, wx.CENTER | wx.BOTTOM, 10) tsizer.Add(udbsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 10) #Clean up horizontal sizers sizer.Add(tsizer, 1, wx.EXPAND | wx.BOTTOM, 20) # Export! sizer.Add(wx.StaticLine(panel, -1), 0, wx.EXPAND | wx.BOTTOM, 15) self.batchModeCheckbox = wx.CheckBox(panel, 60, "Drag-Drop Batch Mode") self.batchModeCheckbox.SetValue(False) sizer.Add(self.batchModeCheckbox, 0, wx.ALIGN_CENTER | wx.TOP, 10) self.Bind(wx.EVT_CHECKBOX, self.fixBatchMode, id=60) self.exportButton = wx.Button(panel, 70, "Export") self.exportButton._secondLevelEnable = False sizer.Add(self.exportButton, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) self.Bind(wx.EVT_BUTTON, self.exportFile, id=70) self.exportButton.Disable() #Late-game setup if self.digest: self.leftbox.Set(self.digest.getNames()) #Cleanup panel.SetSizer(sizer) if self.manager: self.CenterOnParent() self.Show()
def CreatePopupMenu(self): """ Overrides method in parent class to provide a Popup Menu when the user clicks on MyData's system tray (or menubar) icon. """ self.menu = wx.Menu() self.aboutMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(), "About MyData") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.aboutMyDataMenuItem) else: self.menu.AppendItem(self.aboutMyDataMenuItem) self.Bind(wx.EVT_MENU, self.frame.OnAbout, self.aboutMyDataMenuItem, self.aboutMyDataMenuItem.GetId()) self.menu.AppendSeparator() self.syncNowMenuItem = wx.MenuItem(self.menu, wx.NewId(), "Sync Now") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.syncNowMenuItem) else: self.menu.AppendItem(self.syncNowMenuItem) self.Bind(wx.EVT_MENU, MyDataTaskBarIcon.OnSyncNow, self.syncNowMenuItem, self.syncNowMenuItem.GetId()) self.menu.AppendSeparator() self.myTardisMainWindowMenuItem = wx.MenuItem(self.menu, wx.NewId(), "MyData Main Window") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.myTardisMainWindowMenuItem) else: self.menu.AppendItem(self.myTardisMainWindowMenuItem) self.Bind(wx.EVT_MENU, self.OnMyDataMainWindow, self.myTardisMainWindowMenuItem) self.myTardisSettingsMenuItem = wx.MenuItem(self.menu, wx.NewId(), "MyData Settings") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.myTardisSettingsMenuItem) else: self.menu.AppendItem(self.myTardisSettingsMenuItem) self.Bind(wx.EVT_MENU, self.OnMyDataSettings, self.myTardisSettingsMenuItem) self.menu.AppendSeparator() self.myTardisHelpMenuItem = wx.MenuItem(self.menu, wx.NewId(), "MyData Help") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.myTardisHelpMenuItem) else: self.menu.AppendItem(self.myTardisHelpMenuItem) self.Bind(wx.EVT_MENU, MyDataTaskBarIcon.OnMyDataHelp, self.myTardisHelpMenuItem) self.menu.AppendSeparator() self.exitMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(), "Exit MyData") if 'phoenix' in wx.PlatformInfo: self.menu.Append(self.exitMyDataMenuItem) else: self.menu.AppendItem(self.exitMyDataMenuItem) self.Bind(wx.EVT_MENU, self.OnExit, self.exitMyDataMenuItem) return self.menu
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"HexMvc Architecture 3 Gui", pos = wx.DefaultPosition, size = wx.Size( 500,439 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INACTIVECAPTION ) ) self.m_menubar1 = wx.MenuBar( 0 ) self.m_menu1 = wx.Menu() self.m_menuItem1FileNew = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"New", wx.EmptyString, wx.ITEM_NORMAL ) self.m_menu1.AppendItem( self.m_menuItem1FileNew ) self.m_menubar1.Append( self.m_menu1, u"File" ) self.SetMenuBar( self.m_menubar1 ) self.m_statusBar1 = self.CreateStatusBar( 1, wx.ST_SIZEGRIP, wx.ID_ANY ) bSizer4 = wx.BoxSizer( wx.VERTICAL ) bSizer10NewLoadSave = wx.BoxSizer( wx.HORIZONTAL ) self.m_button12 = wx.Button( self, wx.ID_ANY, u"New / Clear", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer10NewLoadSave.Add( self.m_button12, 0, wx.ALL, 5 ) self.m_button13 = wx.Button( self, wx.ID_ANY, u"Load", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer10NewLoadSave.Add( self.m_button13, 0, wx.ALL, 5 ) self.m_button20 = wx.Button( self, wx.ID_ANY, u"Save", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer10NewLoadSave.Add( self.m_button20, 0, wx.ALL, 5 ) bSizer6 = wx.BoxSizer( wx.VERTICAL ) bSizer10NewLoadSave.Add( bSizer6, 1, wx.EXPAND, 5 ) bSizer4.Add( bSizer10NewLoadSave, 0, wx.EXPAND, 5 ) bSizer21Dump = wx.BoxSizer( wx.VERTICAL ) self.m_textCtrlDump = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE ) bSizer21Dump.Add( self.m_textCtrlDump, 1, wx.ALL|wx.EXPAND, 5 ) bSizer4.Add( bSizer21Dump, 1, wx.EXPAND, 5 ) bSizer7 = wx.BoxSizer( wx.HORIZONTAL ) bSizer5 = wx.BoxSizer( wx.HORIZONTAL ) self.m_button11 = wx.Button( self, wx.ID_ANY, u"Dump Model", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer5.Add( self.m_button11, 0, wx.ALL, 5 ) bSizer7.Add( bSizer5, 1, wx.EXPAND, 5 ) bSizer8Hyperlinks = wx.BoxSizer( wx.VERTICAL ) self.m_hyperlink1 = wx.HyperlinkCtrl( self, wx.ID_ANY, u"/", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE ) bSizer8Hyperlinks.Add( self.m_hyperlink1, 0, wx.ALL, 5 ) self.m_hyperlink2 = wx.HyperlinkCtrl( self, wx.ID_ANY, u"/modelsize", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE ) bSizer8Hyperlinks.Add( self.m_hyperlink2, 0, wx.ALL, 5 ) self.m_hyperlink3 = wx.HyperlinkCtrl( self, wx.ID_ANY, u"/dumpthings", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE ) bSizer8Hyperlinks.Add( self.m_hyperlink3, 0, wx.ALL, 5 ) self.m_hyperlink4 = wx.HyperlinkCtrl( self, wx.ID_ANY, u"/addthing", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE ) bSizer8Hyperlinks.Add( self.m_hyperlink4, 0, wx.ALL, 5 ) bSizer7.Add( bSizer8Hyperlinks, 1, wx.EXPAND, 5 ) bSizer4.Add( bSizer7, 0, wx.EXPAND, 5 ) self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) bSizer4.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 ) bSizer17Things = wx.BoxSizer( wx.HORIZONTAL ) bSizer18Commands = wx.BoxSizer( wx.VERTICAL ) bSizer102Add = wx.BoxSizer( wx.HORIZONTAL ) self.m_button122 = wx.Button( self, wx.ID_ANY, u"Add Thing", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer102Add.Add( self.m_button122, 0, wx.ALL, 5 ) self.inputFieldTxt = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer102Add.Add( self.inputFieldTxt, 0, wx.ALL, 5 ) bSizer18Commands.Add( bSizer102Add, 1, wx.EXPAND, 5 ) bSizer101AddInfo = wx.BoxSizer( wx.HORIZONTAL ) self.m_button121 = wx.Button( self, wx.ID_ANY, u"Add Info to Thing", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer101AddInfo.Add( self.m_button121, 0, wx.ALL, 5 ) self.inputFieldTxtZ = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer101AddInfo.Add( self.inputFieldTxtZ, 0, wx.ALL, 5 ) bSizer18Commands.Add( bSizer101AddInfo, 1, wx.EXPAND, 5 ) bSizer20 = wx.BoxSizer( wx.VERTICAL ) self.m_button131 = wx.Button( self, wx.ID_ANY, u"Delete Thing", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer20.Add( self.m_button131, 0, wx.ALL, 5 ) bSizer18Commands.Add( bSizer20, 1, wx.EXPAND, 5 ) bSizer9 = wx.BoxSizer( wx.VERTICAL ) bSizer18Commands.Add( bSizer9, 1, wx.EXPAND, 5 ) bSizer17Things.Add( bSizer18Commands, 1, wx.EXPAND, 5 ) bSizer19Listbox = wx.BoxSizer( wx.VERTICAL ) m_listBox1Choices = [] self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, 0 ) bSizer19Listbox.Add( self.m_listBox1, 1, wx.ALL|wx.EXPAND, 5 ) bSizer17Things.Add( bSizer19Listbox, 1, wx.EXPAND, 5 ) bSizer4.Add( bSizer17Things, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer4 ) self.Layout() self.Centre( wx.BOTH ) # Connect Events self.Bind( wx.EVT_CLOSE, self.OnClose ) self.Bind( wx.EVT_MENU, self.OnFileNew, id = self.m_menuItem1FileNew.GetId() ) self.m_button12.Bind( wx.EVT_BUTTON, self.OnFileNew ) self.m_button13.Bind( wx.EVT_BUTTON, self.OnLoadAll ) self.m_button20.Bind( wx.EVT_BUTTON, self.OnSaveAll ) self.m_button11.Bind( wx.EVT_BUTTON, self.OnDumpModel ) self.m_button122.Bind( wx.EVT_BUTTON, self.OnAddThing ) self.m_button121.Bind( wx.EVT_BUTTON, self.OnAddInfoToThing ) self.m_button131.Bind( wx.EVT_BUTTON, self.OnDeleteThing )
def __init__(self, parent): # begin wxGlade: mainFrame.__init__ wx.Frame.__init__(self, parent=parent) self.SetSize((1280, 720)) # Menu Bar self.frame_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() item = wxglade_tmp_menu.Append(wx.ID_ANY, "New case", "") self.Bind(wx.EVT_MENU, self.onNewCase, id=item.GetId()) item = wxglade_tmp_menu.Append(wx.ID_ANY, "Open case", "") self.Bind(wx.EVT_MENU, self.onOpenCase, id=item.GetId()) wxglade_tmp_menu.AppendSeparator() itemAddEvidenceBtn = wxglade_tmp_menu.Append(wx.ID_ANY, "Add evidence", "") self.Bind(wx.EVT_MENU, self.onAddEvidence, id=itemAddEvidenceBtn.GetId()) wxglade_tmp_menu.AppendSeparator() item = wxglade_tmp_menu.Append(wx.ID_ANY, "Quit", "") self.Bind(wx.EVT_MENU, self.onQuit, id=item.GetId()) self.frame_menubar.Append(wxglade_tmp_menu, "File") wxglade_tmp_menu = wx.Menu() item = wxglade_tmp_menu.Append(wx.ID_ANY, "Image files", "") self.Bind(wx.EVT_MENU, self.onSelImageFiles, id=item.GetId()) item = wxglade_tmp_menu.Append(wx.ID_ANY, "Mobile image files", "") self.Bind(wx.EVT_MENU, self.onSelMobileImageFiles, id=item.GetId()) item = wxglade_tmp_menu.Append(wx.ID_ANY, "Network pcap files", "") self.Bind(wx.EVT_MENU, self.onSelNetworkPcapFiles, id=item.GetId()) self.frame_menubar.Append(wxglade_tmp_menu, "Extract") self.SetMenuBar(self.frame_menubar) # Menu Bar end #splitter window self.window_1 = wx.SplitterWindow(self, wx.ID_ANY) #left panel self.windowLeftPanel = wx.Panel(self.window_1, wx.ID_ANY) self.tree_ctrl_1 = wx.TreeCtrl(self.windowLeftPanel, wx.ID_ANY, style=wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE) #right panel self.windowRightPanel = wx.Panel(self.window_1, wx.ID_ANY) self.searchBtn = wx.Button(self.windowRightPanel, id=wx.ID_ANY, label="Search", pos=wx.DefaultPosition, size=(100, -1), style=0, validator=wx.DefaultValidator) self.auiNotebook = wx.aui.AuiNotebook(self.windowRightPanel) self.paneltest = wx.Panel(self.auiNotebook, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) #bind events self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onItemSel, self.tree_ctrl_1) self.Bind(wx.EVT_BUTTON, self.onSearchBtn, self.searchBtn) self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onAuiClose, self.auiNotebook) #properties self.SetTitle("Forensic Pi") self.tree_ctrl_1.SetBackgroundColour(wx.Colour(240, 240, 240)) self.windowLeftPanel.SetMinSize((180, -1)) self.windowRightPanel.SetMinSize((980, -1)) self.window_1.SetMinimumPaneSize(20) #layout mainSizer = wx.BoxSizer(wx.VERTICAL) #left panel sizer panel1Sizer = wx.BoxSizer(wx.HORIZONTAL) panel1Sizer.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0) self.windowLeftPanel.SetSizer(panel1Sizer) #right panel sizer self.panel2Sizer = wx.BoxSizer(wx.VERTICAL) self.panel2Sizer.Add(self.searchBtn, 0, wx.ALIGN_RIGHT, 0) self.panel2Sizer.Add(self.auiNotebook, 1, wx.EXPAND, 0) self.windowRightPanel.SetSizer(self.panel2Sizer) #splitter self.window_1.SplitVertically(self.windowLeftPanel, self.windowRightPanel) mainSizer.Add(self.window_1, 1, wx.EXPAND, 0) self.SetSizer(mainSizer) self.Layout()
def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(600, -1)) Size = namedtuple("Size", ['x', 'y']) s = Size(100, 50) self.cn_text = None self.en_text = None cwd = os.getcwd() self.mask_path = path.join(path.abspath(cwd), 'alice_mask.png') self.user_sw = STOPWORDS self.lt = layout_template() self.name = 'WordCloud draw' self.version = '0.2' self.des = '''Draw the word cloud.\n''' self.git_website = "https://github.com/WellenWoo/WordCloud_draw" self.copyright = "(C) 2018 All Right Reserved" """创建菜单栏""" filemenu = wx.Menu() menuExit = filemenu.Append(wx.ID_EXIT, "E&xit\tCtrl+Q", "Tenminate the program") confmenu = wx.Menu() menuSw = confmenu.Append(wx.ID_ANY, "StopWords", "Add user StopWrods dict") menuMask = confmenu.Append(wx.ID_ANY, "Mask", "Set mask") helpmenu = wx.Menu() menuAbout = helpmenu.Append(wx.ID_ABOUT, "&About", "Information about this program") menuBar = wx.MenuBar() menuBar.Append(filemenu, "&File") menuBar.Append(confmenu, "&Configure") menuBar.Append(helpmenu, "&Help") self.SetMenuBar(menuBar) """创建输入框""" self.in1 = wx.TextCtrl(self, -1, size=(2 * s.x, s.y)) """创建按钮""" b1 = gbtn.GradientButton(self, -1, label="text") b2 = gbtn.GradientButton(self, -1, label="run") """设置输入框的提示信息""" self.in1.SetToolTipString('choose a text file') """界面布局""" self.sizer0 = rcs.RowColSizer() self.sizer0.Add(b1, row=1, col=1) self.sizer0.Add(self.in1, row=1, col=2) self.sizer0.Add(b2, row=1, col=3) """绑定回调函数""" self.Bind(wx.EVT_BUTTON, self.choose_cn, b1) self.Bind(wx.EVT_BUTTON, self.draw_cn, b2) '''菜单绑定函数''' self.Bind(wx.EVT_MENU, self.OnExit, menuExit) self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout) self.Bind(wx.EVT_MENU, self.get_stopwords, menuSw) self.Bind(wx.EVT_MENU, self.get_mask, menuMask) self.SetSizer(self.sizer0) self.SetAutoLayout(1) self.sizer0.Fit(self) self.CreateStatusBar() self.Show(True)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"MulimgViewer", pos=wx.DefaultPosition, size=wx.Size(-1, -1), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) fgSizer1 = wx.FlexGridSizer(2, 1, 0, 0) fgSizer1.SetFlexibleDirection(wx.BOTH) fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.m_panel1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) wSizer1 = wx.WrapSizer(wx.HORIZONTAL, wx.WRAPSIZER_DEFAULT_FLAGS) self.button_open_all = wx.Button(self.m_panel1, wx.ID_ANY, u"📂️", wx.DefaultPosition, wx.Size(50, -1), wx.BORDER_NONE) self.button_open_all.SetFont( wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) self.button_open_all.SetMinSize(wx.Size(50, -1)) wSizer1.Add( self.button_open_all, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) choice_input_modeChoices = [ u"Sequential", u"Parallel auto", u"Parallel manual", u"Image File List" ] self.choice_input_mode = wx.Choice(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice_input_modeChoices, 0) self.choice_input_mode.SetSelection(0) wSizer1.Add( self.choice_input_mode, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_staticline4 = wx.StaticLine(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL) wSizer1.Add(self.m_staticline4, 0, wx.EXPAND | wx.ALL, 5) self.m_button6 = wx.Button(self.m_panel1, wx.ID_ANY, u"📁️", wx.DefaultPosition, wx.Size(50, -1), wx.BORDER_NONE) self.m_button6.SetFont( wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) wSizer1.Add( self.m_button6, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.save_butoon = wx.Button(self.m_panel1, wx.ID_ANY, u"💾️", wx.DefaultPosition, wx.Size(-1, -1), wx.BORDER_NONE) self.save_butoon.SetFont( wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) self.save_butoon.SetMinSize(wx.Size(50, -1)) wSizer1.Add( self.save_butoon, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_staticline5 = wx.StaticLine(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL) wSizer1.Add(self.m_staticline5, 0, wx.EXPAND | wx.ALL, 5) self.m_button3 = wx.Button(self.m_panel1, wx.ID_ANY, u"<", wx.DefaultPosition, wx.Size(50, -1), 0) self.m_button3.SetFont( wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) wSizer1.Add( self.m_button3, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_button4 = wx.Button(self.m_panel1, wx.ID_ANY, u">", wx.DefaultPosition, wx.DefaultSize, 0) self.m_button4.SetFont( wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) self.m_button4.SetMinSize(wx.Size(50, -1)) wSizer1.Add( self.m_button4, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_button5 = wx.Button(self.m_panel1, wx.ID_ANY, u"⟳", wx.DefaultPosition, wx.DefaultSize, 0) self.m_button5.SetFont( wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) self.m_button5.SetMinSize(wx.Size(50, -1)) wSizer1.Add( self.m_button5, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.slider_value = wx.TextCtrl(self.m_panel1, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(50, -1), wx.TE_PROCESS_ENTER) wSizer1.Add( self.slider_value, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.slider_img = wx.Slider(self.m_panel1, wx.ID_ANY, 0, 0, 100, wx.DefaultPosition, wx.Size(150, -1), wx.SL_HORIZONTAL) wSizer1.Add( self.slider_img, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.slider_value_max = wx.StaticText(self.m_panel1, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, 0) self.slider_value_max.Wrap(-1) wSizer1.Add( self.slider_value_max, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_staticline6 = wx.StaticLine(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL) wSizer1.Add(self.m_staticline6, 0, wx.EXPAND | wx.ALL, 5) self.magnifier = wx.ToggleButton(self.m_panel1, wx.ID_ANY, u"🔍️", wx.DefaultPosition, wx.Size(50, -1), 0) self.magnifier.SetFont( wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) wSizer1.Add( self.magnifier, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.rotation = wx.ToggleButton(self.m_panel1, wx.ID_ANY, u"↷", wx.DefaultPosition, wx.Size(50, -1), 0) self.rotation.SetFont( wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) wSizer1.Add( self.rotation, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.m_panel1.SetSizer(wSizer1) self.m_panel1.Layout() wSizer1.Fit(self.m_panel1) fgSizer1.Add(self.m_panel1, 1, wx.EXPAND | wx.ALL, 5) fgSizer5 = wx.FlexGridSizer(1, 2, 0, 0) fgSizer5.SetFlexibleDirection(wx.BOTH) fgSizer5.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) fgSizer5.SetMinSize(wx.Size(950, 600)) self.scrolledWindow_img = wx.ScrolledWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), wx.HSCROLL | wx.VSCROLL) self.scrolledWindow_img.SetScrollRate(5, 5) fgSizer4 = wx.FlexGridSizer(2, 1, 0, 0) fgSizer4.SetFlexibleDirection(wx.BOTH) fgSizer4.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.m_staticText1 = wx.StaticText(self.scrolledWindow_img, wx.ID_ANY, u"Image show area", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText1.Wrap(-1) fgSizer4.Add(self.m_staticText1, 0, wx.ALL, 5) self.img_panel = wx.Panel(self.scrolledWindow_img, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), wx.TAB_TRAVERSAL) fgSizer4.Add(self.img_panel, 1, wx.EXPAND | wx.ALL, 5) self.scrolledWindow_img.SetSizer(fgSizer4) self.scrolledWindow_img.Layout() fgSizer4.Fit(self.scrolledWindow_img) fgSizer5.Add(self.scrolledWindow_img, 1, wx.ALL | wx.EXPAND, 5) self.scrolledWindow_set = wx.ScrolledWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), wx.HSCROLL | wx.VSCROLL) self.scrolledWindow_set.SetScrollRate(5, 5) fgSizer3 = wx.FlexGridSizer(0, 1, 0, 0) fgSizer3.SetFlexibleDirection(wx.BOTH) fgSizer3.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.m_staticText16 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Settting", wx.DefaultPosition, wx.Size(100, -1), 0) self.m_staticText16.Wrap(-1) self.m_staticText16.SetFont( wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) fgSizer3.Add(self.m_staticText16, 0, wx.ALL, 5) self.m_staticline3 = wx.StaticLine(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) fgSizer3.Add(self.m_staticline3, 0, wx.EXPAND | wx.ALL, 5) bSizer16 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText21 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Correct size", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText21.Wrap(-1) bSizer16.Add(self.m_staticText21, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) choice_normalized_sizeChoices = [u"Resize", u"Crop", u"Fill"] self.choice_normalized_size = wx.Choice(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice_normalized_sizeChoices, 0) self.choice_normalized_size.SetSelection(0) bSizer16.Add( self.choice_normalized_size, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) fgSizer3.Add(bSizer16, 1, wx.EXPAND, 5) bSizer15 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText19 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Output mode", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText19.Wrap(-1) bSizer15.Add(self.m_staticText19, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) choice_outputChoices = [ u"1:stitch", u"2:select", u"3:1+2", u"4:magnifer", u"5:1+4", u"6:2+4", u"7:1+2+4" ] self.choice_output = wx.Choice(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), choice_outputChoices, 0) self.choice_output.SetSelection(0) bSizer15.Add(self.choice_output, 0, wx.ALL, 5) fgSizer3.Add(bSizer15, 1, wx.EXPAND, 5) bSizer23 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText28 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Image interp🔍️", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText28.Wrap(-1) bSizer23.Add(self.m_staticText28, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) image_interpChoices = [u"Nearest", u"Cubic", u"Linear"] self.image_interp = wx.Choice(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, image_interpChoices, 0) self.image_interp.SetSelection(0) bSizer23.Add(self.image_interp, 0, wx.ALL, 5) fgSizer3.Add(bSizer23, 1, wx.EXPAND, 5) bSizer1 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText2 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Row", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText2.Wrap(-1) bSizer1.Add(self.m_staticText2, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.img_num_per_column = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer1.Add(self.img_num_per_column, 0, wx.ALL, 5) fgSizer3.Add(bSizer1, 1, wx.EXPAND, 5) bSizer2 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText3 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Num per img", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText3.Wrap(-1) bSizer2.Add(self.m_staticText3, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.num_per_img = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer2.Add(self.num_per_img, 0, wx.ALL, 5) fgSizer3.Add(bSizer2, 1, wx.EXPAND, 5) bSizer3 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText4 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Column", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText4.Wrap(-1) bSizer3.Add(self.m_staticText4, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.img_num_per_row = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer3.Add(self.img_num_per_row, 0, wx.ALL, 5) fgSizer3.Add(bSizer3, 1, wx.EXPAND, 5) bSizer4 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText5 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Gap (x,y)", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText5.Wrap(-1) bSizer4.Add(self.m_staticText5, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.gap = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"10,10,2,10,2", wx.DefaultPosition, wx.DefaultSize, 0) bSizer4.Add(self.gap, 0, wx.ALL, 5) fgSizer3.Add(bSizer4, 1, wx.EXPAND, 5) bSizer18 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText23 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Draw line width", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText23.Wrap(-1) bSizer18.Add(self.m_staticText23, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.line_width = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, 0) bSizer18.Add(self.line_width, 0, wx.ALL, 5) fgSizer3.Add(bSizer18, 1, wx.EXPAND, 5) bSizer9 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText10 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Vertical", wx.DefaultPosition, wx.Size(80, -1), 0) self.m_staticText10.Wrap(-1) bSizer9.Add(self.m_staticText10, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.checkBox_orientation = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer9.Add(self.checkBox_orientation, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) fgSizer3.Add(bSizer9, 1, wx.EXPAND, 5) bSizer10 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText11 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Auto layout", wx.DefaultPosition, wx.Size(80, -1), 0) self.m_staticText11.Wrap(-1) bSizer10.Add(self.m_staticText11, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.auto_layout_check = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer10.Add(self.auto_layout_check, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) fgSizer3.Add(bSizer10, 1, wx.EXPAND, 5) bSizer8 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText9 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Auto save all ", wx.DefaultPosition, wx.Size(80, -1), 0) self.m_staticText9.Wrap(-1) bSizer8.Add(self.m_staticText9, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.auto_save_all = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer8.Add(self.auto_save_all, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) fgSizer3.Add(bSizer8, 1, wx.EXPAND, 5) bSizer22 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText27 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Auto draw color", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText27.Wrap(-1) bSizer22.Add(self.m_staticText27, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.checkBox_auto_draw_color = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) self.checkBox_auto_draw_color.SetValue(True) bSizer22.Add(self.checkBox_auto_draw_color, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) fgSizer3.Add(bSizer22, 1, wx.EXPAND, 5) bSizer19 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText24 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Move file", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText24.Wrap(-1) bSizer19.Add(self.m_staticText24, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.move_file = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer19.Add(self.move_file, 0, wx.ALL, 5) fgSizer3.Add(bSizer19, 1, wx.EXPAND, 5) bSizer20 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText25 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"🔍️ Keep size", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText25.Wrap(-1) bSizer20.Add(self.m_staticText25, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.keep_magnifer_size = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) self.keep_magnifer_size.SetValue(True) bSizer20.Add(self.keep_magnifer_size, 0, wx.ALL, 5) fgSizer3.Add(bSizer20, 1, wx.EXPAND, 5) bSizer21 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText26 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Parallel+Sequential", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText26.Wrap(-1) bSizer21.Add(self.m_staticText26, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.parallel_sequential = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer21.Add(self.parallel_sequential, 0, wx.ALL, 5) fgSizer3.Add(bSizer21, 1, wx.EXPAND, 5) bSizer24 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText29 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Show box", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText29.Wrap(-1) bSizer24.Add(self.m_staticText29, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.show_box = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) self.show_box.SetValue(True) bSizer24.Add(self.show_box, 0, wx.ALL, 5) fgSizer3.Add(bSizer24, 1, wx.EXPAND, 5) bSizer25 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText30 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Move box", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText30.Wrap(-1) bSizer25.Add(self.m_staticText30, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.move_img_box = wx.CheckBox(self.scrolledWindow_set, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) bSizer25.Add(self.move_img_box, 0, wx.ALL, 5) fgSizer3.Add(bSizer25, 1, wx.EXPAND, 5) self.m_staticline1 = wx.StaticLine(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) fgSizer3.Add(self.m_staticline1, 0, wx.EXPAND | wx.ALL, 5) self.m_staticText20 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Scale", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText20.Wrap(-1) self.m_staticText20.SetFont( wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) fgSizer3.Add(self.m_staticText20, 0, wx.ALL, 5) self.m_staticline8 = wx.StaticLine(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) fgSizer3.Add(self.m_staticline8, 0, wx.EXPAND | wx.ALL, 5) bSizer7 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText8 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Truth resolution", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText8.Wrap(-1) bSizer7.Add(self.m_staticText8, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.img_resolution = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"-1,-1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer7.Add(self.img_resolution, 0, wx.ALL, 5) fgSizer3.Add(bSizer7, 1, wx.EXPAND, 5) bSizer5 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText6 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Show scale", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText6.Wrap(-1) bSizer5.Add(self.m_staticText6, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.show_scale = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"1,1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer5.Add(self.show_scale, 0, wx.ALL, 5) fgSizer3.Add(bSizer5, 1, wx.EXPAND, 5) bSizer6 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText7 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Output scale", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText7.Wrap(-1) bSizer6.Add(self.m_staticText7, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.output_scale = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"1,1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer6.Add(self.output_scale, 0, wx.ALL, 5) fgSizer3.Add(bSizer6, 1, wx.EXPAND, 5) bSizer14 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText18 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"🔍️ Scale", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText18.Wrap(-1) bSizer14.Add(self.m_staticText18, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.magnifier_scale = wx.TextCtrl(self.scrolledWindow_set, wx.ID_ANY, u"-1,-1", wx.DefaultPosition, wx.DefaultSize, 0) bSizer14.Add(self.magnifier_scale, 0, wx.ALL, 5) fgSizer3.Add(bSizer14, 1, wx.EXPAND, 5) self.m_staticline7 = wx.StaticLine(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) fgSizer3.Add(self.m_staticline7, 0, wx.EXPAND | wx.ALL, 5) self.m_staticText13 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Color/transparency", wx.DefaultPosition, wx.Size(150, -1), 0) self.m_staticText13.Wrap(-1) self.m_staticText13.SetFont( wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString)) fgSizer3.Add(self.m_staticText13, 0, wx.ALL, 5) self.m_staticline2 = wx.StaticLine(self.scrolledWindow_set, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) fgSizer3.Add(self.m_staticline2, 0, wx.EXPAND | wx.ALL, 5) bSizer17 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText22 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Draw color", wx.DefaultPosition, wx.Size(-1, -1), 0) self.m_staticText22.Wrap(-1) bSizer17.Add(self.m_staticText22, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.colourPicker_draw = wx.ColourPickerCtrl(self.scrolledWindow_set, wx.ID_ANY, wx.Colour(239, 41, 41), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE) bSizer17.Add(self.colourPicker_draw, 0, wx.ALL, 5) fgSizer3.Add(bSizer17, 1, wx.EXPAND, 5) bSizer13 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText17 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Gap color", wx.DefaultPosition, wx.Size(-1, -1), 0) self.m_staticText17.Wrap(-1) bSizer13.Add(self.m_staticText17, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.colourPicker_gap = wx.ColourPickerCtrl(self.scrolledWindow_set, wx.ID_ANY, wx.Colour(255, 255, 255), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE) bSizer13.Add(self.colourPicker_gap, 0, wx.ALL, 5) fgSizer3.Add(bSizer13, 1, wx.EXPAND, 5) bSizer12 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText14 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Background", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText14.Wrap(-1) bSizer12.Add(self.m_staticText14, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.background_slider = wx.Slider(self.scrolledWindow_set, wx.ID_ANY, 255, 0, 255, wx.DefaultPosition, wx.Size(-1, -1), wx.SL_HORIZONTAL) bSizer12.Add(self.background_slider, 1, wx.ALL, 5) fgSizer3.Add(bSizer12, 1, wx.EXPAND, 5) bSizer11 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText12 = wx.StaticText(self.scrolledWindow_set, wx.ID_ANY, u"Foreground", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText12.Wrap(-1) bSizer11.Add(self.m_staticText12, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.foreground_slider = wx.Slider(self.scrolledWindow_set, wx.ID_ANY, 255, 0, 255, wx.DefaultPosition, wx.Size(-1, -1), wx.SL_HORIZONTAL) bSizer11.Add(self.foreground_slider, 1, wx.ALL, 5) fgSizer3.Add(bSizer11, 1, wx.EXPAND, 5) self.scrolledWindow_set.SetSizer(fgSizer3) self.scrolledWindow_set.Layout() fgSizer3.Fit(self.scrolledWindow_set) fgSizer5.Add(self.scrolledWindow_set, 1, wx.ALL | wx.EXPAND, 5) fgSizer1.Add(fgSizer5, 1, wx.EXPAND, 5) self.SetSizer(fgSizer1) self.Layout() fgSizer1.Fit(self) self.m_statusBar1 = self.CreateStatusBar(4, wx.STB_SIZEGRIP, wx.ID_ANY) self.m_menubar1 = wx.MenuBar(0) self.m_menu1 = wx.Menu() self.m_menu11 = wx.Menu() self.menu_open_sequential = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"Sequential" + u"\t" + u"Ctrl+E", u"one dir mul limg", wx.ITEM_NORMAL) self.m_menu11.Append(self.menu_open_sequential) self.menu_open_auto = wx.MenuItem(self.m_menu11, wx.ID_ANY, u"Parallel auto" + u"\t" + u"Ctrl+A", u"one dir mul dir", wx.ITEM_NORMAL) self.m_menu11.Append(self.menu_open_auto) self.menu_open_manual = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"Parallel manual" + u"\t" + u"Ctrl+M", u"one dir mul dir", wx.ITEM_NORMAL) self.m_menu11.Append(self.menu_open_manual) self.menu_open_filelist = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"Image File List" + u"\t" + u"Ctrl+F", u"one dir mul dir", wx.ITEM_NORMAL) self.m_menu11.Append(self.menu_open_filelist) self.m_menu1.AppendSubMenu(self.m_menu11, u"Open") self.menu_output = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"Select output path" + u"\t" + u"Ctrl+O", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu1.Append(self.menu_output) self.m_menuItem15 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"Input flist - Parallel manual" + u"\t" + u"Ctrl+I", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu1.Append(self.m_menuItem15) self.m_menuItem16 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"Save flist - Parallel manual" + u"\t" + u"Ctrl+P", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu1.Append(self.m_menuItem16) self.m_menubar1.Append(self.m_menu1, u"File") self.m_menu2 = wx.Menu() self.menu_next = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Next" + u"\t" + u"Ctrl+N", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_next) self.menu_last = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Last" + u"\t" + u"Ctrl+L", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_last) self.menu_save = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Save" + u"\t" + u"Ctrl+S", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_save) self.menu_refresh = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Refresh" + u"\t" + u"Ctrl+R", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_refresh) self.menu_up = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Up", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_up) self.menu_down = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Down", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_down) self.menu_right = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"Right", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_right) self.menu_left = wx.MenuItem(self.m_menu2, wx.ID_ANY, u"left", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.Append(self.menu_left) self.m_menubar1.Append(self.m_menu2, u"Edit") self.m_menu3 = wx.Menu() self.index_table = wx.MenuItem(self.m_menu3, wx.ID_ANY, u"Index table" + u"\t" + u"F2", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu3.Append(self.index_table) self.menu_about = wx.MenuItem(self.m_menu3, wx.ID_ANY, u"About" + u"\t" + u"F1", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu3.Append(self.menu_about) self.m_menubar1.Append(self.m_menu3, u"Help") self.SetMenuBar(self.m_menubar1) self.Centre(wx.BOTH) # Connect Events self.Bind(wx.EVT_SIZE, self.frame_resize) self.button_open_all.Bind(wx.EVT_BUTTON, self.open_all_img) self.m_button6.Bind(wx.EVT_BUTTON, self.out_path) self.save_butoon.Bind(wx.EVT_BUTTON, self.save_img) self.m_button3.Bind(wx.EVT_BUTTON, self.last_img) self.m_button4.Bind(wx.EVT_BUTTON, self.next_img) self.m_button5.Bind(wx.EVT_BUTTON, self.refresh) self.slider_value.Bind(wx.EVT_TEXT_ENTER, self.slider_value_change) self.slider_img.Bind(wx.EVT_SCROLL, self.skip_to_n_img) self.magnifier.Bind(wx.EVT_TOGGLEBUTTON, self.magnifier_fc) self.rotation.Bind(wx.EVT_TOGGLEBUTTON, self.rotation_fc) self.choice_normalized_size.Bind(wx.EVT_CHOICE, self.change_img_stitch_mode) self.move_img_box.Bind(wx.EVT_CHECKBOX, self.move_img_box_func) self.colourPicker_gap.Bind(wx.EVT_COLOURPICKER_CHANGED, self.colour_change) self.background_slider.Bind(wx.EVT_SCROLL, self.background_alpha) self.foreground_slider.Bind(wx.EVT_SCROLL, self.foreground_alpha) self.Bind(wx.EVT_MENU, self.one_dir_mul_img, id=self.menu_open_sequential.GetId()) self.Bind(wx.EVT_MENU, self.one_dir_mul_dir_auto, id=self.menu_open_auto.GetId()) self.Bind(wx.EVT_MENU, self.one_dir_mul_dir_manual, id=self.menu_open_manual.GetId()) self.Bind(wx.EVT_MENU, self.onefilelist, id=self.menu_open_filelist.GetId()) self.Bind(wx.EVT_MENU, self.out_path, id=self.menu_output.GetId()) self.Bind(wx.EVT_MENU, self.input_flist_parallel_manual, id=self.m_menuItem15.GetId()) self.Bind(wx.EVT_MENU, self.save_flist_parallel_manual, id=self.m_menuItem16.GetId()) self.Bind(wx.EVT_MENU, self.next_img, id=self.menu_next.GetId()) self.Bind(wx.EVT_MENU, self.last_img, id=self.menu_last.GetId()) self.Bind(wx.EVT_MENU, self.save_img, id=self.menu_save.GetId()) self.Bind(wx.EVT_MENU, self.refresh, id=self.menu_refresh.GetId()) self.Bind(wx.EVT_MENU, self.up_img, id=self.menu_up.GetId()) self.Bind(wx.EVT_MENU, self.down_img, id=self.menu_down.GetId()) self.Bind(wx.EVT_MENU, self.right_img, id=self.menu_right.GetId()) self.Bind(wx.EVT_MENU, self.left_img, id=self.menu_left.GetId()) self.Bind(wx.EVT_MENU, self.index_table_gui, id=self.index_table.GetId()) self.Bind(wx.EVT_MENU, self.about_gui, id=self.menu_about.GetId())
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem): self.moduleLookup = {} sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) def get_metalevel(x): if 'metaLevel' not in x.attributes: return 0 return x.attributes['metaLevel'].value def get_metagroup(x): # We want deadspace before officer mods remap = {5: 6, 6: 5} return remap.get(x.metaGroup.ID, x.metaGroup.ID) if x.metaGroup is not None else 0 def get_boosterrank(x): # If we're returning a lot of items, sort my name if len(self.mainVariations) > 7: return x.name # Sort by booster chance to get some sort of pseudorank. elif 'boosterEffectChance1' in x.attributes: return x.attributes['boosterEffectChance1'].value # the "first" rank (Synth) doesn't have boosterEffectChance1. If we're not pulling back all boosters, return 0 for proper sorting else: return 0 m = wx.Menu() # If on Windows we need to bind out events into the root menu, on other # platforms they need to go to our sub menu if 'wxMSW' in wx.PlatformInfo: bindmenu = rootMenu else: bindmenu = m # Sort items by metalevel, and group within that metalevel items = list(self.mainVariations) # Sort all items by name first items.sort(key=lambda x: x.name) # Do not do any extra sorting for implants if 'implantItem' in context: pass # Boosters don't have meta or anything concrete that we can rank by. Go by chance to inflict side effect elif 'boosterItem' in context: items.sort(key=get_boosterrank) else: # sort by group and meta level items.sort(key=get_metalevel) items.sort(key=get_metagroup) group = None for item in items: # Apparently no metaGroup for the Tech I variant: if 'subSystem' in item.effects: thisgroup = item.marketGroup.marketGroupName elif item.metaGroup is None: thisgroup = 'Tech I' else: thisgroup = item.metaGroup.name if thisgroup != group and context not in ('implantItem', 'boosterItem'): group = thisgroup id = ContextMenuCombined.nextID() m.Append(id, '─ %s ─' % group) m.Enable(id, False) id = ContextMenuCombined.nextID() mitem = wx.MenuItem(rootMenu, id, item.name) bindmenu.Bind(wx.EVT_MENU, self.handleSwitch, mitem) self.moduleLookup[id] = item, context m.Append(mitem) mitem.Enable(fit.canFit(item)) return m
def CreatePopupMenu(self): menu = wx.Menu() menu.Append(self.ID_MEMO, '备忘') menu.Append(self.ID_ABOUT, '关于') menu.Append(self.ID_EXIT, '退出') return menu
def __init__(self, *args, **kwds): # begin wxGlade: MenuTestFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((800, 417)) self.SetTitle("All Widgets") _icon = wx.NullIcon _icon.CopyFromBitmap( wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (32, 32))) self.SetIcon(_icon) # Menu Bar self.test_menubar = wx.MenuBar() global mn_ID1 mn_ID1 = wx.NewId() global mn_ID2 mn_ID2 = wx.NewId() global mn_ID3 mn_ID3 = wx.NewId() global mn_ID4 mn_ID4 = wx.NewId() global mn_ID1C mn_ID1C = wx.NewId() global mn_ID2C mn_ID2C = wx.NewId() global mn_ID3C mn_ID3C = wx.NewId() global mn_ID4C mn_ID4C = wx.NewId() global mn_ID1R mn_ID1R = wx.NewId() global mn_ID2R mn_ID2R = wx.NewId() global mn_ID3R mn_ID3R = wx.NewId() global mn_ID4R mn_ID4R = wx.NewId() wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_OPEN, "&Open", "Stock ID") wxglade_tmp_menu.Append(wx.ID_HELP, "Manual", "Stock ID, handler") self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP) self.test_menubar.m_Close = wxglade_tmp_menu.Append( wx.ID_CLOSE, "&Close file", "Stock ID, name, handler") self.Bind(wx.EVT_MENU, self.onCloseFile, id=wx.ID_CLOSE) self.test_menubar.m_Exit = wxglade_tmp_menu.Append( wx.ID_EXIT, "E&xit", "Stock ID, name") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(wx.ID_OPEN, "&Open", "Stock ID", wx.ITEM_CHECK) wxglade_tmp_menu.Append(wx.ID_HELP, "Manual", "Stock ID, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP) self.test_menubar.m_Close = wxglade_tmp_menu.Append( wx.ID_CLOSE, "&Close file", "Stock ID, name, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.onCloseFile, id=wx.ID_CLOSE) self.test_menubar.m_Exit = wxglade_tmp_menu.Append( wx.ID_EXIT, "E&xit", "Stock ID, name", wx.ITEM_CHECK) wxglade_tmp_menu_sub = wx.Menu() wxglade_tmp_menu_sub.Append(wx.ID_OPEN, "&Open", "Stock ID", wx.ITEM_RADIO) wxglade_tmp_menu_sub.Append(wx.ID_HELP, "Manual", "Stock ID, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP) self.test_menubar.m_Close = wxglade_tmp_menu_sub.Append( wx.ID_CLOSE, "&Close file", "Stock ID, name, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onCloseFile, id=wx.ID_CLOSE) self.test_menubar.m_Exit = wxglade_tmp_menu_sub.Append( wx.ID_EXIT, "E&xit", "Stock ID, name", wx.ITEM_RADIO) wxglade_tmp_menu.Append(wx.ID_ANY, "Radio", wxglade_tmp_menu_sub, "") self.test_menubar.Append(wxglade_tmp_menu, "&Stock IDs") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(mn_ID1, "Named 1", "Named ID") wxglade_tmp_menu.Append(mn_ID2, "Named 2", "Named ID, handler") self.Bind(wx.EVT_MENU, self.on_named2, id=mn_ID2) self.test_menubar.m_named = wxglade_tmp_menu.Append( mn_ID3, "Named 3", "Named ID, name, handler") self.Bind(wx.EVT_MENU, self.on_named3, id=mn_ID3) self.test_menubar.m_named4 = wxglade_tmp_menu.Append( mn_ID4, "Named 4", "Named ID, name") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(mn_ID1C, "Named 1", "Named ID", wx.ITEM_CHECK) wxglade_tmp_menu.Append(mn_ID2C, "Named 2", "Named ID, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_named2, id=mn_ID2C) self.test_menubar.m_named3C = wxglade_tmp_menu.Append( mn_ID3C, "Named 3", "Named ID, name, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_named3, id=mn_ID3C) self.test_menubar.m_named4C = wxglade_tmp_menu.Append( mn_ID4C, "Named 4", "Named ID, name", wx.ITEM_CHECK) wxglade_tmp_menu_sub = wx.Menu() wxglade_tmp_menu_sub.Append(mn_ID1R, "Named 1", "Named ID", wx.ITEM_RADIO) wxglade_tmp_menu_sub.Append(mn_ID2R, "Named 2", "Named ID, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_named2, id=mn_ID2R) self.test_menubar.m_named3R = wxglade_tmp_menu_sub.Append( mn_ID3R, "Named 3", "Named ID, name, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_named3, id=mn_ID3R) self.test_menubar.m_named4R = wxglade_tmp_menu_sub.Append( mn_ID4R, "Named 4", "Named ID, name", wx.ITEM_RADIO) wxglade_tmp_menu.Append(wx.ID_ANY, "Radio", wxglade_tmp_menu_sub, "") self.test_menubar.Append(wxglade_tmp_menu, "&Named ID") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_ANY, "Auto 1", "Auto ID") item = wxglade_tmp_menu.Append(wx.ID_ANY, "Auto 2", "Auto ID, handler") self.Bind(wx.EVT_MENU, self.on_auto2, id=item.GetId()) self.test_menubar.m_auto3 = wxglade_tmp_menu.Append( wx.ID_ANY, "Auto 3", "Auto ID, name, handler") self.Bind(wx.EVT_MENU, self.on_auto3, id=self.test_menubar.m_auto3.GetId()) self.test_menubar.m_auto4 = wxglade_tmp_menu.Append( wx.ID_ANY, "Auto 4", "Auto ID, name") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(wx.ID_ANY, "Auto 1", "Auto ID", wx.ITEM_CHECK) item = wxglade_tmp_menu.Append(wx.ID_ANY, "Auto 2", "Auto ID, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_auto2, id=item.GetId()) self.test_menubar.m_auto3C = wxglade_tmp_menu.Append( wx.ID_ANY, "Auto 3", "Auto ID, name, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_auto3, id=self.test_menubar.m_auto3C.GetId()) self.test_menubar.m_auto4C = wxglade_tmp_menu.Append( wx.ID_ANY, "Auto 4", "Auto ID, name", wx.ITEM_CHECK) wxglade_tmp_menu_sub = wx.Menu() wxglade_tmp_menu_sub.Append(wx.ID_ANY, "Auto 1", "Auto ID", wx.ITEM_RADIO) item = wxglade_tmp_menu_sub.Append(wx.ID_ANY, "Auto 2", "Auto ID, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_auto2, id=item.GetId()) self.test_menubar.m_auto3R = wxglade_tmp_menu_sub.Append( wx.ID_ANY, "Auto 3", "Auto ID, name, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_auto3, id=self.test_menubar.m_auto3R.GetId()) self.test_menubar.m_auto4R = wxglade_tmp_menu_sub.Append( wx.ID_ANY, "Auto 4", "Auto ID, name", wx.ITEM_RADIO) wxglade_tmp_menu.Append(wx.ID_ANY, "Radio", wxglade_tmp_menu_sub, "") self.test_menubar.Append(wxglade_tmp_menu, "&Auto ID") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.NewId(), "Minus1 1", "Minus1 ID") item = wxglade_tmp_menu.Append(wx.NewId(), "Minus1 2", "Minus1 ID, handler") self.Bind(wx.EVT_MENU, self.on_Minus12, id=item.GetId()) self.test_menubar.m_Minus13 = wxglade_tmp_menu.Append( wx.NewId(), "Minus1 3", "Minus1 ID, name, handler") self.Bind(wx.EVT_MENU, self.on_Minus13, id=self.test_menubar.m_Minus13.GetId()) self.test_menubar.m_Minus14 = wxglade_tmp_menu.Append( wx.NewId(), "Minus1 4", "Minus1 ID, name") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(wx.NewId(), "Minus1 1", "Minus1 ID", wx.ITEM_CHECK) item = wxglade_tmp_menu.Append(wx.NewId(), "Minus1 2", "Minus1 ID, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_Minus12, id=item.GetId()) self.test_menubar.m_Minus13C = wxglade_tmp_menu.Append( wx.NewId(), "Minus1 3", "Minus1 ID, name, handler", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.on_Minus13, id=self.test_menubar.m_Minus13C.GetId()) self.test_menubar.m_Minus14C = wxglade_tmp_menu.Append( wx.NewId(), "Minus1 4", "Minus1 ID, name", wx.ITEM_CHECK) wxglade_tmp_menu_sub = wx.Menu() wxglade_tmp_menu_sub.Append(wx.NewId(), "Minus1 1", "Minus1 ID", wx.ITEM_RADIO) item = wxglade_tmp_menu_sub.Append(wx.NewId(), "Minus1 2", "Minus1 ID, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_Minus12, id=item.GetId()) self.test_menubar.m_Minus13R = wxglade_tmp_menu_sub.Append( wx.NewId(), "Minus1 3", "Minus1 ID, name, handler", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.on_Minus13, id=self.test_menubar.m_Minus13R.GetId()) self.test_menubar.m_Minus14R = wxglade_tmp_menu_sub.Append( wx.NewId(), "Minus1 4", "Minus1 ID, name", wx.ITEM_RADIO) wxglade_tmp_menu.Append(wx.ID_ANY, "Radio", wxglade_tmp_menu_sub, "") self.test_menubar.Append(wxglade_tmp_menu, "&Minus1 ID") self.SetMenuBar(self.test_menubar) # Menu Bar end self.Layout() self.Centre()
def __init__(self): super().__init__(parent=None, id=wx.ID_ANY, title=u"Product wxPython grid", pos=wx.DefaultPosition, size=wx.Size(500, 500), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) # Запрос на создание таблицы в БД query = 'CREATE TABLE IF NOT EXISTS {} (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, price REAL)'\ .format(TABLE_NAME) run_query(query) # Запрос инфы по таблице(поля и др.) query = 'PRAGMA table_info({})'.format(TABLE_NAME) db_rows = run_query(query) self.db_field = [] self.db_field_type = [] for row in db_rows: self.db_field.append( row[1]) # Имена полей в БД и гриде `grid_data` self.db_field_type.append(row[2]) # Типы данных полей в БД # Имена полей в шапке грида `grid_data` self.grid_field = ['№', 'Наименование', 'Цена'] # Переменные для сортировки элементов в гриде `grid_data` self.sort_name = '' self.sort_order = '' # Переменные для фильтрации элементов в гриде `grid_data` self.filter_name_tmp = '' self.filter_data_tmp = '' self.filter_name = '' self.filter_data = '' # Формируем панель-подложку на фрейме для переходов между виджетами по клавише TAB self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) vszr_frame = wx.BoxSizer(wx.VERTICAL) self.pnl_frame = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) # Глобальный распределитель виджетов по вертикали vszr_global = wx.BoxSizer(wx.VERTICAL) # Формируем надпись и поле ввода `name` self.pnl_name = wx.Panel(self.pnl_frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # self.pnl_name.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) self.pnl_name.SetFont(wx.Font(12, 70, 90, 90, False, "Courier")) self.pnl_name.SetMaxSize(wx.Size(-1, 35)) hszr_name = wx.BoxSizer(wx.HORIZONTAL) self.lbl_name = wx.StaticText(self.pnl_name, wx.ID_ANY, u"Name :", wx.DefaultPosition, wx.DefaultSize, 0) self.lbl_name.Wrap(-1) hszr_name.Add(self.lbl_name, 0, wx.ALL, 5) self.entry_name = wx.TextCtrl(self.pnl_name, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) hszr_name.Add(self.entry_name, 1, wx.ALL, 5) self.pnl_name.SetSizer(hszr_name) self.pnl_name.Layout() hszr_name.Fit(self.pnl_name) vszr_global.Add(self.pnl_name, 0, wx.ALL | wx.EXPAND, 5) # Формируем надпись и поле ввода `price` self.pnl_price = wx.Panel(self.pnl_frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # self.pnl_price.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) self.pnl_price.SetFont(wx.Font(12, 70, 90, 90, False, "Courier")) self.pnl_price.SetMaxSize(wx.Size(-1, 35)) hszr_price = wx.BoxSizer(wx.HORIZONTAL) self.lbl_price = wx.StaticText(self.pnl_price, wx.ID_ANY, u"Price :", wx.DefaultPosition, wx.DefaultSize, 0) self.lbl_price.Wrap(-1) hszr_price.Add(self.lbl_price, 0, wx.ALL, 5) self.entry_price = wx.TextCtrl(self.pnl_price, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) hszr_price.Add(self.entry_price, 1, wx.ALL, 5) self.pnl_price.SetSizer(hszr_price) self.pnl_price.Layout() hszr_price.Fit(self.pnl_price) vszr_global.Add(self.pnl_price, 0, wx.ALL | wx.EXPAND, 5) # Формируем текст сообщений на форме self.message = wx.StaticText(self.pnl_frame, wx.ID_ANY, '', wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE) self.message.Wrap(-1) self.message.SetFont(wx.Font(11, 70, 90, 90, False, "Tahoma")) self.message.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) self.message.SetMaxSize(wx.Size(-1, 35)) vszr_global.Add(self.message, 0, wx.ALL | wx.EXPAND, 5) # Формируем грид `grid_data` self.grid_data = wx.grid.Grid(self.pnl_frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.DOUBLE_BORDER) # Grid self.grid_data.CreateGrid(0, len(self.grid_field), wx.grid.Grid.SelectRows) self.grid_data.EnableEditing(False) self.grid_data.EnableGridLines(True) self.grid_data.EnableDragGridSize(False) self.grid_data.SetMargins(0, 0) # Columns self.grid_data.SetDefaultColSize(80, resizeExistingCols=True) self.grid_data.SetColMinimalAcceptableWidth(80) # self.grid_data.SetColSize(0, 60) self.grid_data.SetColSize(1, 240) # self.grid_data.SetColSize(2, 100) # self.grid_data.AutoSizeColumns() self.grid_data.EnableDragColMove(False) self.grid_data.EnableDragColSize(True) self.grid_data.SetColLabelSize(30) for i in range(len(self.grid_field)): self.grid_data.SetColLabelValue(i, self.grid_field[i]) # Определяем столбец как float с выравниванием значений по умолчанию(справа) и 2 знаками после ',' if self.grid_field[i] == 'Цена': self.grid_data.SetColFormatFloat(i, width=-1, precision=2) self.grid_data.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) # Rows self.grid_data.AutoSizeRows() self.grid_data.EnableDragRowSize(False) self.grid_data.SetRowLabelSize(40) self.grid_data.SetRowLabelAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTRE) # Label Appearance self.grid_data.UseNativeColHeader( False) # True - для отображения сортировки в заголовке столбца self.grid_data.SetLabelBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) self.grid_data.SetLabelFont(wx.Font(12, 70, 90, 90, False, "Tahoma")) self.grid_data.SetLabelTextColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)) # Cell Defaults self.grid_data.SetDefaultCellFitMode(wx.grid.GridFitMode.Ellipsize()) self.grid_data.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP) self.grid_data.SetDefaultCellFont( wx.Font(11, 70, 90, 90, False, "Arial")) # Формируем контекстное меню на `grid_data` self.pop_menu = wx.Menu() self.pm_setfil = wx.MenuItem(self.pop_menu, wx.ID_ANY, u"Set filter", wx.EmptyString, wx.ITEM_NORMAL) self.pm_clrfil = wx.MenuItem(self.pop_menu, wx.ID_ANY, u"Clear filter", wx.EmptyString, wx.ITEM_NORMAL) self.pop_menu.Append(self.pm_setfil) self.pop_menu.Append(self.pm_clrfil) self.grid_data.Bind(wx.EVT_CONTEXT_MENU, self.grid_dataOnGridCellRightClick) vszr_global.Add(self.grid_data, 1, wx.ALL | wx.EXPAND, 5) # Формируем кнопок `Add`, `Edit`, `Del` self.pnl_btn = wx.Panel(self.pnl_frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # self.pnl_btn.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) self.pnl_btn.SetFont(wx.Font(12, 70, 90, 90, False, "Courier")) hszr_but = wx.BoxSizer(wx.HORIZONTAL) self.btn_add = wx.Button(self.pnl_btn, wx.ID_ANY, u"Add", wx.DefaultPosition, wx.DefaultSize, 0 | wx.DOUBLE_BORDER) self.btn_add.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) hszr_but.Add(self.btn_add, 1, wx.ALL, 5) self.btn_edit = wx.Button(self.pnl_btn, wx.ID_ANY, u"Edit", wx.DefaultPosition, wx.DefaultSize, 0 | wx.DOUBLE_BORDER) self.btn_edit.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) hszr_but.Add(self.btn_edit, 1, wx.ALL, 5) self.btn_del = wx.Button(self.pnl_btn, wx.ID_ANY, u"Del", wx.DefaultPosition, wx.DefaultSize, 0 | wx.DOUBLE_BORDER) self.btn_del.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) hszr_but.Add(self.btn_del, 1, wx.ALL, 5) self.pnl_btn.SetSizer(hszr_but) self.pnl_btn.Layout() hszr_but.Fit(self.pnl_btn) vszr_global.Add(self.pnl_btn, 0, wx.ALL | wx.EXPAND, 5) # self.pnl_frame.SetSizer(vszr_global) self.pnl_frame.Layout() vszr_global.Fit(self.pnl_frame) vszr_frame.Add(self.pnl_frame, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(vszr_frame) self.Layout() self.Centre(wx.BOTH) # Connect Events self.Bind(wx.EVT_SIZE, self.form_resize) self.entry_name.Bind(wx.EVT_CHAR, self.OnKeyPress) self.entry_price.Bind(wx.EVT_CHAR, self.OnKeyPress) self.grid_data.Bind(wx.EVT_CHAR, self.OnKeyPress) self.grid_data.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) self.grid_data.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.grid_dataOnGridCellLeftClick) self.grid_data.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.grid_dataOnGridCellRightClick) self.grid_data.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.grid_dataOnGridLabelLeftClick) self.grid_data.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.grid_dataOnGridRangeSelect) self.Bind(wx.EVT_MENU, self.pm_setfilOnMenuSelect, id=self.pm_setfil.GetId()) self.Bind(wx.EVT_MENU, self.pm_clrfilOnMenuSelect, id=self.pm_clrfil.GetId()) self.btn_add.Bind(wx.EVT_BUTTON, self.click_add) self.btn_edit.Bind(wx.EVT_BUTTON, self.click_edit) self.btn_del.Bind(wx.EVT_BUTTON, self.click_del) # Отображение грида self.refresh_grid()
def buildMenu(parent, data): menu = wx.Menu() for i in data: buildItem(parent, menu, i) return menu
def __init__(self, properties, parent, id=-1, **kwargs): #wx.Frame.__init__(self, parent, id=id, title='CellProfiler Analyst 2.1.0 (r%s)'%(__version__), **kwargs) wx.Frame.__init__(self, parent, id=id, title='CellProfiler Analyst %s' % (__version__), **kwargs) self.properties = properties self.SetIcon(get_cpa_icon()) self.tbicon = None self.SetName('CPA') self.Center(wx.HORIZONTAL) self.CreateStatusBar() # # Setup toolbar # tb = self.CreateToolBar(wx.TB_HORZ_TEXT | wx.TB_FLAT) tb.SetToolBitmapSize((32, 32)) tb.SetSize((-1, 132)) tb.AddLabelTool(ID_IMAGE_GALLERY, 'Image Gallery', cpa.icons.image_gallery.ConvertToBitmap(), shortHelp='Image Gallery', longHelp='Launch Image Gallery Viewer') tb.AddLabelTool(ID_CLASSIFIER, 'Classifier', cpa.icons.classifier.ConvertToBitmap(), shortHelp='Classifier', longHelp='Launch Classifier') # tb.AddLabelTool(ID_CLASSIFIER, 'PixelClassifier', cpa.icons.pixelclassifier.ConvertToBitmap(), shortHelp='Pixel-based Classifier', longHelp='Launch pixel-based Classifier') tb.AddLabelTool(ID_PLATE_VIEWER, 'Plate Viewer', cpa.icons.platemapbrowser.ConvertToBitmap(), shortHelp='Plate Viewer', longHelp='Launch Plate Viewer') # tb.AddLabelTool(ID_IMAGE_VIEWER, 'ImageViewer', cpa.icons.image_viewer.ConvertToBitmap(), shortHelp='Image Viewer', longHelp='Launch ImageViewer') tb.AddLabelTool(ID_SCATTER, 'Scatter Plot', cpa.icons.scatter.ConvertToBitmap(), shortHelp='Scatter Plot', longHelp='Launch Scatter Plot') tb.AddLabelTool(ID_HISTOGRAM, 'Histogram', cpa.icons.histogram.ConvertToBitmap(), shortHelp='Histogram', longHelp='Launch Histogram') tb.AddLabelTool(ID_DENSITY, 'Density Plot', cpa.icons.density.ConvertToBitmap(), shortHelp='Density Plot', longHelp='Launch Density Plot') tb.AddLabelTool(ID_BOXPLOT, 'Box Plot', cpa.icons.boxplot.ConvertToBitmap(), shortHelp='Box Plot', longHelp='Launch Box Plot') tb.AddLabelTool(ID_TABLE_VIEWER, 'Table Viewer', cpa.icons.data_grid.ConvertToBitmap(), shortHelp='Table Viewer', longHelp='Launch Table Viewer') # tb.AddLabelTool(ID_NORMALIZE, 'Normalize', cpa.icons.normalize.ConvertToBitmap(), shortHelp='Normalization Tool', longHelp='Launch Feature Normalization Tool') tb.Realize() # TODO: IMG-1071 - The following was meant to resize based on the toolbar size but GetEffectiveMinSize breaks on Macs # Not the Case anymore with wx.Python 3 # self.SetDimensions(-1, -1, tb.GetEffectiveMinSize().width, -1, wx.SIZE_USE_EXISTING) # # Setup menu items # self.SetMenuBar(wx.MenuBar()) fileMenu = wx.Menu() savePropertiesMenuItem = fileMenu.Append(-1, 'Save properties\tCtrl+S', help='Save the properties.') ## loadWorkspaceMenuItem = fileMenu.Append(-1, 'Load properties\tCtrl+O', help='Open another properties file.') fileMenu.AppendSeparator() saveWorkspaceMenuItem = fileMenu.Append( -1, 'Save workspace\tCtrl+Shift+S', help='Save the currently open plots and settings.') loadWorkspaceMenuItem = fileMenu.Append( -1, 'Load workspace\tCtrl+Shift+O', help='Open plots saved in a previous workspace.') fileMenu.AppendSeparator() saveLogMenuItem = fileMenu.Append( -1, 'Save log', help='Save the contents of the log window.') fileMenu.AppendSeparator() self.exitMenuItem = fileMenu.Append(wx.ID_EXIT, 'Exit\tCtrl+Q', help='Exit classifier') self.GetMenuBar().Append(fileMenu, 'File') toolsMenu = wx.Menu() imageGalleryMenuItem = toolsMenu.Append( ID_IMAGE_GALLERY, 'Image Gallery Viewer\tCtrl+Shift+I', help='Launches the Image Gallery') classifierMenuItem = toolsMenu.Append(ID_CLASSIFIER, 'Classifier\tCtrl+Shift+C', help='Launches Classifier.') plateMapMenuItem = toolsMenu.Append( ID_PLATE_VIEWER, 'Plate Viewer\tCtrl+Shift+P', help='Launches the Plate Viewer tool.') #imageViewerMenuItem = toolsMenu.Append(ID_IMAGE_VIEWER, 'Image Viewer\tCtrl+Shift+I', help='Launches the ImageViewer tool.') scatterMenuItem = toolsMenu.Append( ID_SCATTER, 'Scatter Plot\tCtrl+Shift+A', help='Launches the Scatter Plot tool.') histogramMenuItem = toolsMenu.Append( ID_HISTOGRAM, 'Histogram Plot\tCtrl+Shift+H', help='Launches the Histogram Plot tool.') densityMenuItem = toolsMenu.Append( ID_DENSITY, 'Density Plot\tCtrl+Shift+D', help='Launches the Density Plot tool.') boxplotMenuItem = toolsMenu.Append(ID_BOXPLOT, 'Box Plot\tCtrl+Shift+B', help='Launches the Box Plot tool.') dataTableMenuItem = toolsMenu.Append( ID_TABLE_VIEWER, 'Table Viewer\tCtrl+Shift+T', help='Launches the Table Viewer tool.') normalizeMenuItem = toolsMenu.Append( ID_NORMALIZE, 'Normalization Tool\tCtrl+Shift+T', help= 'Launches a tool for generating normalized values for measurement columns in your tables.' ) self.GetMenuBar().Append(toolsMenu, 'Tools') logMenu = wx.Menu() debugMenuItem = logMenu.AppendRadioItem( -1, 'Debug\tCtrl+1', help='Logging window will display debug-level messages.') infoMenuItem = logMenu.AppendRadioItem( -1, 'Info\tCtrl+2', help='Logging window will display info-level messages.') warnMenuItem = logMenu.AppendRadioItem( -1, 'Warnings\tCtrl+3', help='Logging window will display warning-level messages.') errorMenuItem = logMenu.AppendRadioItem( -1, 'Errors\tCtrl+4', help='Logging window will display error-level messages.') criticalMenuItem = logMenu.AppendRadioItem( -1, 'Critical\tCtrl+5', help='Logging window will only display critical messages.') infoMenuItem.Check() self.GetMenuBar().Append(logMenu, 'Logging') advancedMenu = wx.Menu() #normalizeMenuItem = advancedMenu.Append(-1, 'Launch feature normalization tool', help='Launches a tool for generating normalized values for measurement columns in your tables.') queryMenuItem = advancedMenu.Append( -1, 'Launch SQL query tool', help= 'Opens a tool for making SQL queries to the CPA database. Advanced users only.' ) clearTableLinksMenuItem = advancedMenu.Append( -1, 'Clear table linking information', help= 'Removes the tables from your database that tell CPA how to link your tables.' ) self.GetMenuBar().Append(advancedMenu, 'Advanced') self.GetMenuBar().Append(cpa.helpmenu.make_help_menu(self), 'Help') # console and logging self.console = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2) self.console.SetFont( wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) # Black background and white font self.console.SetDefaultStyle(wx.TextAttr(wx.WHITE, wx.BLACK)) self.console.SetBackgroundColour('#000000') log_level = logging.INFO # INFO is the default log level self.logr = logging.getLogger() self.set_log_level(log_level) self.log_text = '' def update(x): self.log_text += x + '\n' hdlr = FuncLog(update) # hdlr.setFormatter(logging.Formatter('[%(levelname)s] %(message)s')) # hdlr.setFormatter(logging.Formatter('%(levelname)s | %(name)s | %(message)s [@ %(asctime)s in %(filename)s:%(lineno)d]')) self.logr.addHandler(hdlr) # log_levels are 10,20,30,40,50 logMenu.GetMenuItems()[(log_level / 10) - 1].Check() self.Bind(wx.EVT_MENU, lambda _: self.set_log_level(logging.DEBUG), debugMenuItem) self.Bind(wx.EVT_MENU, lambda _: self.set_log_level(logging.INFO), infoMenuItem) self.Bind(wx.EVT_MENU, lambda _: self.set_log_level(logging.WARN), warnMenuItem) self.Bind(wx.EVT_MENU, lambda _: self.set_log_level(logging.ERROR), errorMenuItem) self.Bind(wx.EVT_MENU, lambda _: self.set_log_level(logging.CRITICAL), criticalMenuItem) self.Bind(wx.EVT_MENU, self.on_save_properties, savePropertiesMenuItem) self.Bind(wx.EVT_MENU, self.on_save_workspace, saveWorkspaceMenuItem) self.Bind(wx.EVT_MENU, self.on_load_workspace, loadWorkspaceMenuItem) self.Bind(wx.EVT_MENU, self.save_log, saveLogMenuItem) self.Bind(wx.EVT_MENU, self.launch_normalization_tool, normalizeMenuItem) self.Bind(wx.EVT_MENU, self.clear_link_tables, clearTableLinksMenuItem) self.Bind(wx.EVT_MENU, self.launch_query_maker, queryMenuItem) self.Bind(wx.EVT_TOOL, self.launch_classifier, id=ID_CLASSIFIER) self.Bind(wx.EVT_TOOL, self.launch_plate_map_browser, id=ID_PLATE_VIEWER) self.Bind(wx.EVT_TOOL, self.launch_table_viewer, id=ID_TABLE_VIEWER) self.Bind(wx.EVT_TOOL, self.launch_image_viewer, id=ID_IMAGE_VIEWER) self.Bind(wx.EVT_TOOL, self.launch_image_gallery, id=ID_IMAGE_GALLERY) self.Bind(wx.EVT_TOOL, self.launch_scatter_plot, id=ID_SCATTER) self.Bind(wx.EVT_TOOL, self.launch_histogram_plot, id=ID_HISTOGRAM) self.Bind(wx.EVT_TOOL, self.launch_density_plot, id=ID_DENSITY) self.Bind(wx.EVT_TOOL, self.launch_box_plot, id=ID_BOXPLOT) self.Bind(wx.EVT_TOOL, self.launch_normalization_tool, id=ID_NORMALIZE) self.Bind(wx.EVT_MENU, self.on_close, self.exitMenuItem) self.Bind(wx.EVT_CLOSE, self.on_close) self.Bind(wx.EVT_IDLE, self.on_idle)
def __init__(self, title): wx.Frame.__init__(self, None, -1, title, pos=wx.DefaultPosition, size=(550, 500)) # Menu Bar # File Menu self.frame_menubar = wx.MenuBar() self.file_menu = wx.Menu() self.file_menu.Append(1, "&Open", "Open from file..") self.file_menu.AppendSeparator() self.file_menu.Append(2, "&Close", "Quit") self.Bind(wx.EVT_MENU, self.OnOpen, id=1) self.Bind(wx.EVT_MENU, self.OnExit, id=2) self.frame_menubar.Append(self.file_menu, "File") self.SetMenuBar(self.frame_menubar) # Panels # The first panel holds the video and it's all black self.videopanel = wx.Panel(self, -1) self.videopanel.SetBackgroundColour(wx.BLACK) # # The second panel holds controls ctrlpanel = wx.Panel(self, -1) self.timeslider = wx.Slider(ctrlpanel, -1, 0, 0, 1000) self.timeslider.SetRange(0, 1000) pause = wx.Button(ctrlpanel, label="Pause") play = wx.Button(ctrlpanel, label="Play") stop = wx.Button(ctrlpanel, label="Stop") volume = wx.Button(ctrlpanel, label="Volume") self.volslider = wx.Slider(ctrlpanel, -1, 0, 0, 100, size=(100, -1)) # # Bind controls to events self.Bind(wx.EVT_BUTTON, self.OnPlay, play) self.Bind(wx.EVT_BUTTON, self.OnPause, pause) self.Bind(wx.EVT_BUTTON, self.OnStop, stop) self.Bind(wx.EVT_BUTTON, self.OnToggleVolume, volume) self.Bind(wx.EVT_SLIDER, self.OnSetVolume, self.volslider) # Give a pretty layout to the controls ctrlbox = wx.BoxSizer(wx.VERTICAL) box1 = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) # # box1 contains the timeslider box1.Add(self.timeslider, 1) # # box2 contains some buttons and the volume controls box2.Add(play, flag=wx.RIGHT, border=5) box2.Add(pause) box2.Add(stop) box2.Add((-1, -1), 1) box2.Add(volume) box2.Add(self.volslider, flag=wx.TOP | wx.LEFT, border=5) # # Merge box1 and box2 to the ctrlsizer ctrlbox.Add(box1, flag=wx.EXPAND | wx.BOTTOM, border=10) ctrlbox.Add(box2, 1, wx.EXPAND) ctrlpanel.SetSizer(ctrlbox) # Put everything togheter sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.videopanel, 1, flag=wx.EXPAND) sizer.Add(ctrlpanel, flag=wx.EXPAND | wx.BOTTOM | wx.TOP, border=10) self.SetSizer(sizer) self.SetMinSize((350, 300)) # finally create the timer, which updates the timeslider self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.timer.Start() self.Bind(wx.EVT_CHAR_HOOK, self.onKeyPress) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() self.title = None # Server Thread self.thread = threading.Thread(target=self.serverConn, daemon=True) self.thread.start() # Create video folder self.createDefaultFolder()
def __LayoutPanel(self, panel, label, exstyle=False): """Puts a set of controls in the panel @param panel: panel to layout @param label: panels title @param exstyle: Set the PB_STYLE_NOBG or not """ # Bitmaps (32x32) and (16x16) devil = Devil.GetBitmap() # 32x32 monkey = Monkey.GetBitmap() # 32x32 address = Address.GetBitmap() # 16x16 folder = Home.GetBitmap() bookmark = Book.GetBitmap() # 16x16 vsizer = wx.BoxSizer(wx.VERTICAL) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add((15, 15)) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add((15, 15)) hsizer3 = wx.BoxSizer(wx.HORIZONTAL) hsizer3.Add((15, 15)) hsizer4 = wx.BoxSizer(wx.HORIZONTAL) hsizer4.Add((15, 15)) # Button Styles default = platebtn.PB_STYLE_DEFAULT square = platebtn.PB_STYLE_SQUARE sqgrad = platebtn.PB_STYLE_SQUARE | platebtn.PB_STYLE_GRADIENT gradient = platebtn.PB_STYLE_GRADIENT droparrow = platebtn.PB_STYLE_DROPARROW toggle = default | platebtn.PB_STYLE_TOGGLE # Create a number of different PlateButtons # Each button is created in the below loop by using the data set in this # lists tuple # (bmp, label, Style, Variant, Menu, Color, Enable) btype = [ (None, "Normal PlateButton", default, None, None, None, True), (devil, "Normal w/Bitmap", default, None, None, None, True), (devil, "Disabled", default, None, None, None, False), (None, "Normal w/Menu", default, None, True, None, True), (folder, "Home Folder", default, None, True, None, True), # Row 2 (None, "Square PlateButton", square, None, None, None, True), (address, "Square/Bitmap", square, None, None, None, True), (monkey, "Square/Gradient", sqgrad, None, None, None, True), (address, "Square/Small", square, wx.WINDOW_VARIANT_SMALL, True, None, True), (address, "Small Bitmap", default, wx.WINDOW_VARIANT_SMALL, None, wx.Colour(33, 33, 33), True), # Row 3 (devil, "Custom Color", default, None, None, wx.RED, True), (monkey, "Gradient Highlight", gradient, None, None, None, True), (monkey, "Custom Gradient", gradient, None, None, wx.Colour(245, 55, 245), True), (None, "Drop Arrow", droparrow, None, None, None, True), (devil, "", default, None, None, None, True), (bookmark, "", default, None, True, None, True), (monkey, "", square, None, None, None, True), # Row 4 (None, "Toggle PlateButton", toggle, None, None, None, True), (devil, "Toggle w/Bitmap", toggle, None, None, None, True), (None, "Toggle w/Menu", toggle, None, True, None, True), ] # Make and layout three rows of buttons in the panel for btn in btype: if exstyle: # With this style flag set the button can appear transparent on # on top of a background that is not solid in color, such as the # gradient panel in this demo. # # Note: This flag only has affect on wxMSW and should only be # set when the background is not a solid color. On wxMac # it is a no-op as this type of transparency is achieved # without any help needed. On wxGtk it doesn't hurt to # set but also unfortunatly doesn't help at all. bstyle = btn[2] | platebtn.PB_STYLE_NOBG else: bstyle = btn[2] if btype.index(btn) < 5: tsizer = hsizer1 elif btype.index(btn) < 10: tsizer = hsizer2 elif btype.index(btn) < 17: tsizer = hsizer3 else: tsizer = hsizer4 tbtn = platebtn.PlateButton(panel, wx.ID_ANY, btn[1], btn[0], style=bstyle) # Set a custom window size variant? if btn[3] is not None: tbtn.SetWindowVariant(btn[3]) # Make a menu for the button? if btn[4] is not None: menu = wx.Menu() if btn[0] is not None and btn[0] == folder: for fname in os.listdir(wx.GetHomeDir()): if not fname.startswith('.'): menu.Append(wx.NewId(), fname) elif btn[0] is not None and btn[0] == bookmark: for url in [ 'http://wxpython.org', 'http://slashdot.org', 'http://editra.org', 'http://xkcd.com' ]: menu.Append(wx.NewId(), url, "Open %s in your browser" % url) else: menu.Append(wx.NewId(), "Menu Item 1") menu.Append(wx.NewId(), "Menu Item 2") menu.Append(wx.NewId(), "Menu Item 3") tbtn.SetMenu(menu) # Set a custom colour? if btn[5] is not None: tbtn.SetPressColor(btn[5]) if btn[2] == droparrow: tbtn.Bind(platebtn.EVT_PLATEBTN_DROPARROW_PRESSED, self.OnDropArrowPressed) # Enable/Disable button state tbtn.Enable(btn[6]) tsizer.AddMany([(tbtn, 0, wx.ALIGN_CENTER), ((10, 10))]) txt_sz = wx.BoxSizer(wx.HORIZONTAL) txt_sz.AddMany([((5, 5)), (wx.StaticText(panel, label=label), 0, wx.ALIGN_LEFT)]) vsizer.AddMany([((10, 10)), (txt_sz, 0, wx.ALIGN_LEFT), ((10, 10)), (hsizer1, 0, wx.EXPAND), ((10, 10)), (hsizer2, 0, wx.EXPAND), ((10, 10)), (hsizer3, 0, wx.EXPAND), ((10, 10)), (hsizer4, 0, wx.EXPAND), ((10, 10))]) panel.SetSizer(vsizer)
def on_item_right_click(self, event): if not self.selected: return if not self.x or not self.y: return selected = self.GetPyData(self.selected) ### ### root node. ### if selected == None: return ### ### module node. ### elif type(selected) == pida.module: # we only have to do this once, that is what the hasattr() check is for. if not hasattr(self, "right_click_popup_remove_module"): self.right_click_popup_remove_module = wx.NewId() self.Bind(wx.EVT_MENU, self.on_right_click_popup_remove_module, id=self.right_click_popup_remove_module) # make a menu. menu = wx.Menu() menu.Append(self.right_click_popup_remove_module, "Remove Module") self.PopupMenu(menu, (self.x, self.y)) menu.Destroy() ### ### function node. ### elif type(selected) == pida.function: # we only have to do this once, that is what the hasattr() check is for. if not hasattr(self, "right_click_popup_graph_function"): self.right_click_popup_graph_function = wx.NewId() self.Bind(wx.EVT_MENU, self.on_right_click_popup_graph_function, id=self.right_click_popup_graph_function) # make a menu. menu = wx.Menu() menu.Append(self.right_click_popup_graph_function, "Graph Function") self.PopupMenu(menu, (self.x, self.y)) menu.Destroy() ### ### basic block node. ### elif type(selected) == pida.function: return
def __createMenus(self): # File Menu m = self.fileMenu = wx.Menu() m.Append(ID_NEW, '&New \tCtrl+N', 'New file') m.Append(ID_OPEN, '&Open... \tCtrl+O', 'Open file') m.AppendSeparator() m.Append(ID_REVERT, '&Revert \tCtrl+R', 'Revert to last saved version') m.Append(ID_CLOSE, '&Close \tCtrl+W', 'Close file') m.AppendSeparator() m.Append(ID_SAVE, '&Save... \tCtrl+S', 'Save file') m.Append(ID_SAVEAS, 'Save &As \tCtrl+Shift+S', 'Save file with new name') m.AppendSeparator() m.Append(ID_PRINT, '&Print... \tCtrl+P', 'Print file') m.AppendSeparator() m.Append(ID_NAMESPACE, '&Update Namespace \tCtrl+Shift+N', 'Update namespace for autocompletion and calltips') m.AppendSeparator() m.Append(ID_EXIT, 'E&xit\tCtrl+Q', 'Exit Program') # Edit m = self.editMenu = wx.Menu() m.Append(ID_UNDO, '&Undo \tCtrl+Z', 'Undo the last action') m.Append(ID_REDO, '&Redo \tCtrl+Y', 'Redo the last undone action') m.AppendSeparator() m.Append(ID_CUT, 'Cu&t \tCtrl+X', 'Cut the selection') m.Append(ID_COPY, '&Copy \tCtrl+C', 'Copy the selection') m.Append(ID_COPY_PLUS, 'Cop&y Plus \tCtrl+Shift+C', 'Copy the selection - retaining prompts') m.Append(ID_PASTE, '&Paste \tCtrl+V', 'Paste from clipboard') m.Append(ID_PASTE_PLUS, 'Past&e Plus \tCtrl+Shift+V', 'Paste and run commands') m.AppendSeparator() m.Append(ID_CLEAR, 'Cle&ar', 'Delete the selection') m.Append(ID_SELECTALL, 'Select A&ll \tCtrl+A', 'Select all text') m.AppendSeparator() m.Append(ID_EMPTYBUFFER, 'E&mpty Buffer...', 'Delete all the contents of the edit buffer') m.Append(ID_FIND, '&Find Text... \tCtrl+F', 'Search for text in the edit buffer') m.Append(ID_FINDNEXT, 'Find &Next \tF3', 'Find next/previous instance of the search text') # View m = self.viewMenu = wx.Menu() m.Append(ID_WRAP, '&Wrap Lines\tCtrl+Shift+W', 'Wrap lines at right edge', wx.ITEM_CHECK) m.Append(ID_SHOW_LINENUMBERS, '&Show Line Numbers\tCtrl+Shift+L', 'Show Line Numbers', wx.ITEM_CHECK) m.Append(ID_TOGGLE_MAXIMIZE, '&Toggle Maximize\tF11', 'Maximize/Restore Application') if hasattr(self, 'ToggleTools'): m.Append(ID_SHOWTOOLS, 'Show &Tools\tF4', 'Show the filling and other tools', wx.ITEM_CHECK) # Options m = self.autocompMenu = wx.Menu() m.Append(ID_AUTOCOMP_SHOW, 'Show &Auto Completion\tCtrl+Shift+A', 'Show auto completion list', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_MAGIC, 'Include &Magic Attributes\tCtrl+Shift+M', 'Include attributes visible to __getattr__ and __setattr__', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_SINGLE, 'Include Single &Underscores\tCtrl+Shift+U', 'Include attibutes prefixed by a single underscore', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_DOUBLE, 'Include &Double Underscores\tCtrl+Shift+D', 'Include attibutes prefixed by a double underscore', wx.ITEM_CHECK) m = self.calltipsMenu = wx.Menu() m.Append(ID_CALLTIPS_SHOW, 'Show Call &Tips\tCtrl+Shift+T', 'Show call tips with argument signature and docstring', wx.ITEM_CHECK) m.Append(ID_CALLTIPS_INSERT, '&Insert Call Tips\tCtrl+Shift+I', '&Insert Call Tips', wx.ITEM_CHECK) m = self.optionsMenu = wx.Menu() m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, 'Auto Completion Options') m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, 'Call Tip Options') if wx.Platform == "__WXMAC__": m.Append(ID_USEAA, '&Use AntiAliasing', 'Use anti-aliased fonts', wx.ITEM_CHECK) m.AppendSeparator() self.historyMenu = wx.Menu() self.historyMenu.Append(ID_SAVEHISTORY, '&Autosave History', 'Automatically save history on close', wx.ITEM_CHECK) self.historyMenu.Append(ID_SAVEHISTORYNOW, '&Save History Now', 'Save history') self.historyMenu.Append(ID_CLEARHISTORY, '&Clear History ', 'Clear history') m.AppendMenu(-1, "&History", self.historyMenu, "History Options") self.startupMenu = wx.Menu() self.startupMenu.Append(ID_EXECSTARTUPSCRIPT, 'E&xecute Startup Script', 'Execute Startup Script', wx.ITEM_CHECK) self.startupMenu.Append(ID_EDITSTARTUPSCRIPT, '&Edit Startup Script...', 'Edit Startup Script') m.AppendMenu(ID_STARTUP, '&Startup', self.startupMenu, 'Startup Options') self.settingsMenu = wx.Menu() self.settingsMenu.Append(ID_AUTO_SAVESETTINGS, '&Auto Save Settings', 'Automatically save settings on close', wx.ITEM_CHECK) self.settingsMenu.Append(ID_SAVESETTINGS, '&Save Settings', 'Save settings now') self.settingsMenu.Append(ID_DELSETTINGSFILE, '&Revert to default', 'Revert to the default settings') m.AppendMenu(ID_SETTINGS, '&Settings', self.settingsMenu, 'Settings Options') m = self.helpMenu = wx.Menu() m.Append(ID_HELP, '&Help\tF1', 'Help!') m.AppendSeparator() m.Append(ID_ABOUT, '&About...', 'About this program') b = self.menuBar = wx.MenuBar() b.Append(self.fileMenu, '&File') b.Append(self.editMenu, '&Edit') b.Append(self.viewMenu, '&View') b.Append(self.optionsMenu, '&Options') b.Append(self.helpMenu, '&Help') self.SetMenuBar(b) self.Bind(wx.EVT_MENU, self.OnFileNew, id=ID_NEW) self.Bind(wx.EVT_MENU, self.OnFileOpen, id=ID_OPEN) self.Bind(wx.EVT_MENU, self.OnFileRevert, id=ID_REVERT) self.Bind(wx.EVT_MENU, self.OnFileClose, id=ID_CLOSE) self.Bind(wx.EVT_MENU, self.OnFileSave, id=ID_SAVE) self.Bind(wx.EVT_MENU, self.OnFileSaveAs, id=ID_SAVEAS) self.Bind(wx.EVT_MENU, self.OnFileUpdateNamespace, id=ID_NAMESPACE) self.Bind(wx.EVT_MENU, self.OnFilePrint, id=ID_PRINT) self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT) self.Bind(wx.EVT_MENU, self.OnUndo, id=ID_UNDO) self.Bind(wx.EVT_MENU, self.OnRedo, id=ID_REDO) self.Bind(wx.EVT_MENU, self.OnCut, id=ID_CUT) self.Bind(wx.EVT_MENU, self.OnCopy, id=ID_COPY) self.Bind(wx.EVT_MENU, self.OnCopyPlus, id=ID_COPY_PLUS) self.Bind(wx.EVT_MENU, self.OnPaste, id=ID_PASTE) self.Bind(wx.EVT_MENU, self.OnPastePlus, id=ID_PASTE_PLUS) self.Bind(wx.EVT_MENU, self.OnClear, id=ID_CLEAR) self.Bind(wx.EVT_MENU, self.OnSelectAll, id=ID_SELECTALL) self.Bind(wx.EVT_MENU, self.OnEmptyBuffer, id=ID_EMPTYBUFFER) self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_ABOUT) self.Bind(wx.EVT_MENU, self.OnHelp, id=ID_HELP) self.Bind(wx.EVT_MENU, self.OnAutoCompleteShow, id=ID_AUTOCOMP_SHOW) self.Bind(wx.EVT_MENU, self.OnAutoCompleteMagic, id=ID_AUTOCOMP_MAGIC) self.Bind(wx.EVT_MENU, self.OnAutoCompleteSingle, id=ID_AUTOCOMP_SINGLE) self.Bind(wx.EVT_MENU, self.OnAutoCompleteDouble, id=ID_AUTOCOMP_DOUBLE) self.Bind(wx.EVT_MENU, self.OnCallTipsShow, id=ID_CALLTIPS_SHOW) self.Bind(wx.EVT_MENU, self.OnCallTipsInsert, id=ID_CALLTIPS_INSERT) self.Bind(wx.EVT_MENU, self.OnWrap, id=ID_WRAP) self.Bind(wx.EVT_MENU, self.OnUseAA, id=ID_USEAA) self.Bind(wx.EVT_MENU, self.OnToggleMaximize, id=ID_TOGGLE_MAXIMIZE) self.Bind(wx.EVT_MENU, self.OnShowLineNumbers, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_MENU, self.OnAutoSaveSettings, id=ID_AUTO_SAVESETTINGS) self.Bind(wx.EVT_MENU, self.OnSaveHistory, id=ID_SAVEHISTORY) self.Bind(wx.EVT_MENU, self.OnSaveHistoryNow, id=ID_SAVEHISTORYNOW) self.Bind(wx.EVT_MENU, self.OnClearHistory, id=ID_CLEARHISTORY) self.Bind(wx.EVT_MENU, self.OnSaveSettings, id=ID_SAVESETTINGS) self.Bind(wx.EVT_MENU, self.OnDelSettingsFile, id=ID_DELSETTINGSFILE) self.Bind(wx.EVT_MENU, self.OnEditStartupScript, id=ID_EDITSTARTUPSCRIPT) self.Bind(wx.EVT_MENU, self.OnExecStartupScript, id=ID_EXECSTARTUPSCRIPT) self.Bind(wx.EVT_MENU, self.OnFindText, id=ID_FIND) self.Bind(wx.EVT_MENU, self.OnFindNext, id=ID_FINDNEXT) self.Bind(wx.EVT_MENU, self.OnToggleTools, id=ID_SHOWTOOLS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NEW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_OPEN) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_REVERT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLOSE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEAS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NAMESPACE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PRINT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_UNDO) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_REDO) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CUT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_COPY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_COPY_PLUS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PASTE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PASTE_PLUS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLEAR) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SELECTALL) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EMPTYBUFFER) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_SHOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_MAGIC) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_SINGLE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_DOUBLE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CALLTIPS_SHOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CALLTIPS_INSERT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_WRAP) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_USEAA) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTO_SAVESETTINGS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVESETTINGS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_DELSETTINGSFILE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EXECSTARTUPSCRIPT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEHISTORY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEHISTORYNOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLEARHISTORY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EDITSTARTUPSCRIPT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FIND) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FINDNEXT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOWTOOLS) self.Bind(wx.EVT_ACTIVATE, self.OnActivate) self.Bind(wx.EVT_FIND, self.OnFindNext) self.Bind(wx.EVT_FIND_NEXT, self.OnFindNext) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title) monSysteme = FileSystem.FileManager() monBuilder = monSysteme.getBuilder() monBuilder.findRoots() p1 = TestPanel(self, monSysteme) #p1 = MyListCtrl(self, -1, monSysteme) #self.splitter = wx.SplitterWindow(self, ID_SPLITTER, style=wx.SP_BORDER) #self.splitter.SetMinimumPaneSize(50) #p1 = MyListCtrl(self.splitter, -1, monSysteme) #p2 = MyListCtrl(self.splitter, -1, monSysteme) #self.splitter.SplitVertically(p1, p2) self.Bind(wx.EVT_SIZE, self.OnSize) # self.Bind(wx.EVT_SPLITTER_DCLICK, self.OnDoubleClick, id=ID_SPLITTER) self.sb = self.CreateStatusBar() filemenu = wx.Menu() filemenu.Append(ID_EXIT, "E&xit", " Terminate the program") editmenu = wx.Menu() netmenu = wx.Menu() showmenu = wx.Menu() configmenu = wx.Menu() helpmenu = wx.Menu() menuBar = wx.MenuBar() menuBar.Append(filemenu, "&File") menuBar.Append(editmenu, "&Edit") menuBar.Append(netmenu, "&Net") menuBar.Append(showmenu, "&Show") menuBar.Append(configmenu, "&Config") menuBar.Append(helpmenu, "&Help") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT) tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT) #tb.AddSimpleTool(10, wx.Bitmap('images/previous.png'), 'Previous') #tb.AddSimpleTool(20, wx.Bitmap('images/up.png'), 'Up one directory') #tb.AddSimpleTool(30, wx.Bitmap('images/home.png'), 'Home') #tb.AddSimpleTool(40, wx.Bitmap('images/refresh.png'), 'Refresh') #tb.AddSeparator() #tb.AddSimpleTool(50, wx.Bitmap('images/write.png'), 'Editor') #tb.AddSimpleTool(60, wx.Bitmap('images/terminal.png'), 'Terminal') #tb.AddSeparator() #tb.AddSimpleTool(70, wx.Bitmap('images/help.png'), 'Help') tb.AddSimpleTool(10, wx.Bitmap('images/Class.png'), 'Previous') tb.AddSimpleTool(20, wx.Bitmap('images/Class.png'), 'Up one directory') tb.AddSimpleTool(30, wx.Bitmap('images/Class.png'), 'Home') tb.AddSimpleTool(40, wx.Bitmap('images/Class.png'), 'Refresh') tb.AddSeparator() tb.AddSimpleTool(50, wx.Bitmap('images/Class.png'), 'Editor') tb.AddSimpleTool(60, wx.Bitmap('images/Class.png'), 'Terminal') tb.AddSeparator() tb.AddSimpleTool(70, wx.Bitmap('images/Class.png'), 'Help') tb.Realize() self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) button1 = wx.Button(self, ID_BUTTON + 1, "F3 View") button2 = wx.Button(self, ID_BUTTON + 2, "F4 Edit") button3 = wx.Button(self, ID_BUTTON + 3, "F5 Copy") button4 = wx.Button(self, ID_BUTTON + 4, "F6 Move") button5 = wx.Button(self, ID_BUTTON + 5, "F7 Mkdir") button6 = wx.Button(self, ID_BUTTON + 6, "F8 Delete") button7 = wx.Button(self, ID_BUTTON + 7, "F9 Rename") button8 = wx.Button(self, ID_EXIT, "F10 Quit") self.sizer2.Add(button1, 1, wx.EXPAND) self.sizer2.Add(button2, 1, wx.EXPAND) self.sizer2.Add(button3, 1, wx.EXPAND) self.sizer2.Add(button4, 1, wx.EXPAND) self.sizer2.Add(button5, 1, wx.EXPAND) self.sizer2.Add(button6, 1, wx.EXPAND) self.sizer2.Add(button7, 1, wx.EXPAND) self.sizer2.Add(button8, 1, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.OnExit, id=ID_EXIT) #self.sizer = wx.BoxSizer(wx.VERTICAL) #self.sizer.Add(self.splitter,1,wx.EXPAND) #self.sizer.Add(self.sizer2,0,wx.EXPAND) #self.SetSizer(self.sizer) self.sizer = wx.BoxSizer() self.sizer.Add(p1, 1, wx.EXPAND) self.SetSizer(self.sizer) size = wx.DisplaySize() size = (size[0] - 100, size[1] - 100) self.SetSize(size) #self.sb = self.CreateStatusBar() self.sb.SetStatusText(os.getcwd()) self.Center() self.Show(True)
def __init__(self, parent, id=-1, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN): wx.Frame.__init__(self, parent, id, title, pos, size, style) # tell FrameManager to manage this frame self._mgr = aui.AuiManager() self._mgr.SetManagedWindow(self) self._perspectives = [] self.n = 0 self.x = 0 self.SetIcon(GetMondrianIcon()) # create menu mb = wx.MenuBar() file_menu = wx.Menu() file_menu.Append(wx.ID_EXIT, "Exit") view_menu = wx.Menu() view_menu.Append(ID_CreateText, "Create Text Control") view_menu.Append(ID_CreateHTML, "Create HTML Control") view_menu.Append(ID_CreateTree, "Create Tree") view_menu.Append(ID_CreateGrid, "Create Grid") view_menu.Append(ID_CreateSizeReport, "Create Size Reporter") view_menu.AppendSeparator() view_menu.Append(ID_GridContent, "Use a Grid for the Content Pane") view_menu.Append(ID_TextContent, "Use a Text Control for the Content Pane") view_menu.Append(ID_HTMLContent, "Use an HTML Control for the Content Pane") view_menu.Append(ID_TreeContent, "Use a Tree Control for the Content Pane") view_menu.Append(ID_SizeReportContent, "Use a Size Reporter for the Content Pane") options_menu = wx.Menu() options_menu.AppendRadioItem(ID_TransparentHint, "Transparent Hint") options_menu.AppendRadioItem(ID_VenetianBlindsHint, "Venetian Blinds Hint") options_menu.AppendRadioItem(ID_RectangleHint, "Rectangle Hint") options_menu.AppendRadioItem(ID_NoHint, "No Hint") options_menu.AppendSeparator() options_menu.AppendCheckItem(ID_HintFade, "Hint Fade-in") options_menu.AppendCheckItem(ID_AllowFloating, "Allow Floating") options_menu.AppendCheckItem(ID_NoVenetianFade, "Disable Venetian Blinds Hint Fade-in") options_menu.AppendCheckItem(ID_TransparentDrag, "Transparent Drag") options_menu.AppendCheckItem(ID_AllowActivePane, "Allow Active Pane") options_menu.AppendSeparator() options_menu.AppendRadioItem(ID_NoGradient, "No Caption Gradient") options_menu.AppendRadioItem(ID_VerticalGradient, "Vertical Caption Gradient") options_menu.AppendRadioItem(ID_HorizontalGradient, "Horizontal Caption Gradient") options_menu.AppendSeparator() options_menu.Append(ID_Settings, "Settings Pane") self._perspectives_menu = wx.Menu() self._perspectives_menu.Append(ID_CreatePerspective, "Create Perspective") self._perspectives_menu.Append(ID_CopyPerspective, "Copy Perspective Data To Clipboard") self._perspectives_menu.AppendSeparator() self._perspectives_menu.Append(ID_FirstPerspective + 0, "Default Startup") self._perspectives_menu.Append(ID_FirstPerspective + 1, "All Panes") self._perspectives_menu.Append(ID_FirstPerspective + 2, "Vertical Toolbar") help_menu = wx.Menu() help_menu.Append(ID_About, "About...") mb.Append(file_menu, "File") mb.Append(view_menu, "View") mb.Append(self._perspectives_menu, "Perspectives") mb.Append(options_menu, "Options") mb.Append(help_menu, "Help") self.SetMenuBar(mb) self.statusbar = self.CreateStatusBar(2, wx.STB_SIZEGRIP) self.statusbar.SetStatusWidths([-2, -3]) self.statusbar.SetStatusText("Ready", 0) self.statusbar.SetStatusText("Welcome To wxPython!", 1) # min size for the frame itself isn't completely done. # see the end up FrameManager::Update() for the test # code. For now, just hard code a frame minimum size self.SetMinSize(wx.Size(400, 300)) # create some toolbars tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) tb1.SetToolBitmapSize(wx.Size(48, 48)) tb1.AddLabelTool(101, "Test", wx.ArtProvider.GetBitmap(wx.ART_ERROR)) tb1.AddSeparator() tb1.AddLabelTool(102, "Test", wx.ArtProvider.GetBitmap(wx.ART_QUESTION)) tb1.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_INFORMATION)) tb1.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_WARNING)) tb1.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE)) tb1.Realize() tb2 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) tb2.SetToolBitmapSize(wx.Size(16, 16)) tb2_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16)) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddSeparator() tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddSeparator() tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.AddLabelTool(101, "Test", tb2_bmp1) tb2.Realize() tb3 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) tb3.SetToolBitmapSize(wx.Size(16, 16)) tb3_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16)) tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.AddSeparator() tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.AddLabelTool(101, "Test", tb3_bmp1) tb3.Realize() tb4 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_HORZ_TEXT) tb4.SetToolBitmapSize(wx.Size(16, 16)) tb4_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16)) tb4.AddLabelTool(101, "Item 1", tb4_bmp1) tb4.AddLabelTool(101, "Item 2", tb4_bmp1) tb4.AddLabelTool(101, "Item 3", tb4_bmp1) tb4.AddLabelTool(101, "Item 4", tb4_bmp1) tb4.AddSeparator() tb4.AddLabelTool(101, "Item 5", tb4_bmp1) tb4.AddLabelTool(101, "Item 6", tb4_bmp1) tb4.AddLabelTool(101, "Item 7", tb4_bmp1) tb4.AddLabelTool(101, "Item 8", tb4_bmp1) tb4.Realize() tb5 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_VERTICAL) tb5.SetToolBitmapSize(wx.Size(48, 48)) tb5.AddLabelTool(101, "Test", wx.ArtProvider.GetBitmap(wx.ART_ERROR)) tb5.AddSeparator() tb5.AddLabelTool(102, "Test", wx.ArtProvider.GetBitmap(wx.ART_QUESTION)) tb5.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_INFORMATION)) tb5.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_WARNING)) tb5.AddLabelTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE)) tb5.Realize() # add a bunch of panes self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test1").Caption( "Pane Caption").Top().CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test2").Caption("Client Size Reporter"). Bottom().Position(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test3").Caption("Client Size Reporter"). Bottom().CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test4").Caption( "Pane Caption").Left().CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test5").Caption( "Pane Caption").Right().CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test6").Caption("Client Size Reporter"). Right().Row(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test7").Caption("Client Size Reporter"). Left().Layer(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateTreeCtrl(), aui.AuiPaneInfo().Name("test8").Caption("Tree Pane").Left().Layer( 1).Position(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test9").Caption("Min Size 200x100"). BestSize(wx.Size(200, 100)).MinSize(wx.Size( 200, 100)).Bottom().Layer(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateTextCtrl(), aui.AuiPaneInfo().Name("test10").Caption("Text Pane").Bottom(). Layer(1).Position(1).CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test11").Caption( "Fixed Pane").Bottom().Layer(1).Position( 2).Fixed().CloseButton(True).MaximizeButton(True)) self._mgr.AddPane( SettingsPanel(self, self), aui.AuiPaneInfo().Name("settings").Caption( "Dock Manager Settings").Dockable(False).Float().Hide(). CloseButton(True).MaximizeButton(True)) # create some center panes self._mgr.AddPane( self.CreateGrid(), aui.AuiPaneInfo().Name("grid_content").CenterPane().Hide()) self._mgr.AddPane( self.CreateTreeCtrl(), aui.AuiPaneInfo().Name("tree_content").CenterPane().Hide()) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("sizereport_content").CenterPane().Hide()) self._mgr.AddPane( self.CreateTextCtrl(), aui.AuiPaneInfo().Name("text_content").CenterPane().Hide()) self._mgr.AddPane(self.CreateHTMLCtrl(), aui.AuiPaneInfo().Name("html_content").CenterPane()) # add the toolbars to the manager self._mgr.AddPane( tb1, aui.AuiPaneInfo().Name("tb1").Caption("Big Toolbar").ToolbarPane(). Top().LeftDockable(False).RightDockable(False)) self._mgr.AddPane( tb2, aui.AuiPaneInfo().Name("tb2").Caption("Toolbar 2").ToolbarPane(). Top().Row(1).LeftDockable(False).RightDockable(False)) self._mgr.AddPane( tb3, aui.AuiPaneInfo().Name("tb3").Caption("Toolbar 3").ToolbarPane(). Top().Row(1).Position(1).LeftDockable(False).RightDockable(False)) self._mgr.AddPane( tb4, aui.AuiPaneInfo().Name("tb4").Caption( "Sample Bookmark Toolbar").ToolbarPane().Top().Row( 2).LeftDockable(False).RightDockable(False)) self._mgr.AddPane( tb5, aui.AuiPaneInfo().Name("tbvert").Caption( "Sample Vertical Toolbar").ToolbarPane().Left().GripperTop(). TopDockable(False).BottomDockable(False)) self._mgr.AddPane( wx.Button(self, -1, "Test Button"), aui.AuiPaneInfo().Name("tb5").ToolbarPane().Top().Row(2).Position( 1).LeftDockable(False).RightDockable(False)) # make some default perspectives self._mgr.GetPane("tbvert").Hide() perspective_all = self._mgr.SavePerspective() all_panes = self._mgr.GetAllPanes() for ii in range(len(all_panes)): if not all_panes[ii].IsToolbar(): all_panes[ii].Hide() self._mgr.GetPane("tb1").Hide() self._mgr.GetPane("tb5").Hide() self._mgr.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0) self._mgr.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0) self._mgr.GetPane("html_content").Show() perspective_default = self._mgr.SavePerspective() for ii in range(len(all_panes)): if not all_panes[ii].IsToolbar(): all_panes[ii].Hide() self._mgr.GetPane("tb1").Hide() self._mgr.GetPane("tb5").Hide() self._mgr.GetPane("tbvert").Show() self._mgr.GetPane("grid_content").Show() self._mgr.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0) self._mgr.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0) self._mgr.GetPane("html_content").Show() perspective_vert = self._mgr.SavePerspective() self._perspectives.append(perspective_default) self._perspectives.append(perspective_all) self._perspectives.append(perspective_vert) self._mgr.GetPane("tbvert").Hide() self._mgr.GetPane("grid_content").Hide() # "commit" all changes made to FrameManager self._mgr.Update() self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_CLOSE, self.OnClose) # Show How To Use The Closing Panes Event self.Bind(aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose) self.Bind(wx.EVT_MENU, self.OnCreateTree, id=ID_CreateTree) self.Bind(wx.EVT_MENU, self.OnCreateGrid, id=ID_CreateGrid) self.Bind(wx.EVT_MENU, self.OnCreateText, id=ID_CreateText) self.Bind(wx.EVT_MENU, self.OnCreateHTML, id=ID_CreateHTML) self.Bind(wx.EVT_MENU, self.OnCreateSizeReport, id=ID_CreateSizeReport) self.Bind(wx.EVT_MENU, self.OnCreatePerspective, id=ID_CreatePerspective) self.Bind(wx.EVT_MENU, self.OnCopyPerspective, id=ID_CopyPerspective) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_AllowFloating) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_TransparentHint) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_VenetianBlindsHint) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_RectangleHint) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_NoHint) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_HintFade) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_NoVenetianFade) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_TransparentDrag) self.Bind(wx.EVT_MENU, self.OnManagerFlag, id=ID_AllowActivePane) self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_NoGradient) self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_VerticalGradient) self.Bind(wx.EVT_MENU, self.OnGradient, id=ID_HorizontalGradient) self.Bind(wx.EVT_MENU, self.OnSettings, id=ID_Settings) self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_GridContent) self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_TreeContent) self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_TextContent) self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_SizeReportContent) self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_HTMLContent) self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_About) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentHint) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_VenetianBlindsHint) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_RectangleHint) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_NoHint) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_HintFade) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_AllowFloating) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_NoVenetianFade) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentDrag) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_AllowActivePane) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_NoGradient) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_VerticalGradient) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_HorizontalGradient) self.Bind(wx.EVT_MENU_RANGE, self.OnRestorePerspective, id=ID_FirstPerspective, id2=ID_FirstPerspective + 1000)
def __init__(self, *args, **kwds): # begin wxGlade: PyOgg2_MyFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((600, 500)) self.SetTitle(_("mp3 2 ogg")) # Menu Bar self.Mp3_To_Ogg_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_OPEN, _("&Open"), "") self.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) wxglade_tmp_menu.Append(wx.ID_EXIT, _("&Quit"), "") self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT) self.Mp3_To_Ogg_menubar.Append(wxglade_tmp_menu, _("&File")) wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_ABOUT, _("&About"), _("About dialog")) self.Bind(wx.EVT_MENU, self.OnAboutDialog, id=wx.ID_ABOUT) self.Mp3_To_Ogg_menubar.Append(wxglade_tmp_menu, _("&Help")) self.SetMenuBar(self.Mp3_To_Ogg_menubar) # Menu Bar end self.Mp3_To_Ogg_statusbar = self.CreateStatusBar(2) self.Mp3_To_Ogg_statusbar.SetStatusWidths([-2, -1]) # statusbar fields Mp3_To_Ogg_statusbar_fields = [_("Mp3_To_Ogg_statusbar"), ""] for i in range(len(Mp3_To_Ogg_statusbar_fields)): self.Mp3_To_Ogg_statusbar.SetStatusText( Mp3_To_Ogg_statusbar_fields[i], i) # Tool Bar self.Mp3_To_Ogg_toolbar = wx.ToolBar(self, -1, style=wx.TB_TEXT) self.Mp3_To_Ogg_toolbar.AddTool( wx.ID_OPEN, _("&Open"), wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, _("Open a file"), _("Open a MP3 file to convert into OGG format")) self.Bind(wx.EVT_TOOL, self.OnOpen, id=wx.ID_OPEN) self.SetToolBar(self.Mp3_To_Ogg_toolbar) self.Mp3_To_Ogg_toolbar.Realize() # Tool Bar end sizer_1 = wx.FlexGridSizer(3, 1, 0, 0) self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=wx.NB_BOTTOM) sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0) self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY) self.notebook_1.AddPage(self.notebook_1_pane_1, _("Input File")) _gszr_pane1 = wx.FlexGridSizer(1, 3, 0, 0) _lbl_input_filename = wx.StaticText(self.notebook_1_pane_1, wx.ID_ANY, _("File name:")) _gszr_pane1.Add(_lbl_input_filename, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_pane_1, wx.ID_ANY, "") self.text_ctrl_1.SetBackgroundColour(wx.NullColour) _gszr_pane1.Add(self.text_ctrl_1, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.EXPAND, 5) self.button_3 = wx.Button(self.notebook_1_pane_1, wx.ID_OPEN, "") _gszr_pane1.Add(self.button_3, 0, wx.ALL, 5) self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY) self.notebook_1.AddPage(self.notebook_1_pane_2, _("Converting Options")) sizer_4 = wx.BoxSizer(wx.HORIZONTAL) self.rbx_sampling_rate = wx.RadioBox( self.notebook_1_pane_2, wx.ID_ANY, _("Sampling Rate"), choices=[_("44 kbit"), _("128 kbit")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) self.rbx_sampling_rate.SetSelection(0) sizer_4.Add(self.rbx_sampling_rate, 1, wx.ALL | wx.EXPAND, 5) sizer_3 = wx.StaticBoxSizer( wx.StaticBox(self.notebook_1_pane_2, wx.ID_ANY, _("Misc")), wx.HORIZONTAL) sizer_4.Add(sizer_3, 1, wx.ALL | wx.EXPAND, 5) self.cbx_love = wx.CheckBox(self.notebook_1_pane_2, wx.ID_ANY, _(u"♥ Love this song")) self.cbx_love.SetToolTipString(_(u"Yes!\nWe ♥ it!")) self.cbx_love.SetValue(1) sizer_3.Add(self.cbx_love, 0, wx.ALL | wx.SHAPED, 5) self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY) self.notebook_1.AddPage(self.notebook_1_pane_3, _("Converting Progress")) _szr_pane3 = wx.BoxSizer(wx.HORIZONTAL) self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_3, wx.ID_ANY, "", style=wx.TE_MULTILINE) _szr_pane3.Add(self.text_ctrl_2, 1, wx.ALL | wx.EXPAND, 5) self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY) self.notebook_1.AddPage(self.notebook_1_pane_4, _("Output File")) _gszr_pane4 = wx.FlexGridSizer(2, 3, 0, 0) self._lbl_output_filename = wx.StaticText(self.notebook_1_pane_4, wx.ID_ANY, _("File name:")) _gszr_pane4.Add(self._lbl_output_filename, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_pane_4, wx.ID_ANY, "") self.text_ctrl_3.SetToolTipString( _("File name of the output file\nAn existing file will be overwritten without futher information!" )) _gszr_pane4.Add(self.text_ctrl_3, 0, wx.ALL | wx.EXPAND, 5) self.button_4 = wx.Button(self.notebook_1_pane_4, wx.ID_OPEN, "") _gszr_pane4.Add(self.button_4, 0, wx.ALL, 5) _gszr_pane4.Add((20, 20), 0, 0, 0) self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_4, wx.ID_ANY, _("Overwrite existing file")) self.checkbox_1.SetToolTipString(_("Overwrite an existing file")) self.checkbox_1.SetValue(1) _gszr_pane4.Add(self.checkbox_1, 0, wx.ALL | wx.EXPAND, 5) _gszr_pane4.Add((20, 20), 0, 0, 0) self.notebook_1_pane_5 = wx.Panel(self.notebook_1, wx.ID_ANY) self.notebook_1.AddPage(self.notebook_1_pane_5, _("Some Text")) sizer_5 = wx.BoxSizer(wx.HORIZONTAL) self.label_1 = wx.StaticText( self.notebook_1_pane_5, wx.ID_ANY, _("Please check the format of those lines manually:\n\nSingle line without any special characters.\n\na line break between new and line: new\nline\na tab character between new and line: new\tline\ntwo backslash characters: \\\\ \nthree backslash characters: \\\\\\ \na double quote: \"\nan escaped new line sequence: \\n" )) sizer_5.Add(self.label_1, 1, wx.ALL | wx.EXPAND, 5) self.static_line_1 = wx.StaticLine(self, wx.ID_ANY) sizer_1.Add(self.static_line_1, 0, wx.ALL | wx.EXPAND, 5) sizer_2 = wx.FlexGridSizer(1, 3, 0, 0) sizer_1.Add(sizer_2, 0, wx.ALIGN_RIGHT, 0) self.button_5 = wx.Button(self, wx.ID_CLOSE, "") sizer_2.Add(self.button_5, 0, wx.ALIGN_RIGHT | wx.ALL, 5) self.button_2 = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_TOP) sizer_2.Add(self.button_2, 0, wx.ALIGN_RIGHT | wx.ALL, 5) self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP) sizer_2.Add(self.button_1, 0, wx.ALIGN_RIGHT | wx.ALL, 5) self.notebook_1_pane_5.SetSizer(sizer_5) _gszr_pane4.AddGrowableCol(1) self.notebook_1_pane_4.SetSizer(_gszr_pane4) self.notebook_1_pane_3.SetSizer(_szr_pane3) self.notebook_1_pane_2.SetSizer(sizer_4) _gszr_pane1.AddGrowableCol(1) self.notebook_1_pane_1.SetSizer(_gszr_pane1) sizer_1.AddGrowableRow(0) sizer_1.AddGrowableCol(0) self.SetSizer(sizer_1) sizer_1.SetSizeHints(self) self.Layout() self.Centre() self.button_1.Bind(wx.EVT_BUTTON, self.startConverting)
def mkSubMenu(root, parent, title, items): submenu = wx.Menu() for item in items: mkItem(root, submenu, item) parent.AppendMenu(wx.ID_ANY, title, submenu)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"FPrime Ground Station", pos=wx.DefaultPosition, size=wx.Size(800, 600), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) MainSizer = wx.BoxSizer(wx.VERTICAL) self.TabNotebook = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.TabNotebook.SetForegroundColour(wx.Colour(100, 100, 100)) self.TabNotebook.SetBackgroundColour(wx.Colour(184, 224, 216)) MainSizer.Add(self.TabNotebook, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(MainSizer) self.Layout() self.GroundStationStatusBar = self.CreateStatusBar( 3, wx.STB_SIZEGRIP, wx.ID_ANY) self.m_menubar1 = wx.MenuBar(0) self.FileMenu = wx.Menu() self.NewMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"New...", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.NewMenuItem) self.SaveMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"Save...", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.SaveMenuItem) self.LoadMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"Load...", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.LoadMenuItem) self.AboutMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"About...", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.AboutMenuItem) self.SaveWinCfgMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"Save Window Configuration", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.SaveWinCfgMenuItem) self.RestoreWinMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"Restore Windows", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.RestoreWinMenuItem) self.ExitMenuItem = wx.MenuItem(self.FileMenu, wx.ID_ANY, u"Exit", wx.EmptyString, wx.ITEM_NORMAL) self.FileMenu.Append(self.ExitMenuItem) self.m_menubar1.Append(self.FileMenu, u"File") self.SetMenuBar(self.m_menubar1) self.Centre(wx.BOTH) # Connect Events self.Bind(wx.EVT_MENU, self.onNewMenuItemClick, id=self.NewMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onSaveMenuItemClick, id=self.SaveMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onLoadMenuItemClick, id=self.LoadMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onAboutMenuItemClick, id=self.AboutMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onSaveWinCfgMenuItemClick, id=self.SaveWinCfgMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onRestoreWinMenuItemClick, id=self.RestoreWinMenuItem.GetId()) self.Bind(wx.EVT_MENU, self.onExitMenuItemClick, id=self.ExitMenuItem.GetId())
def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem): msw = True if 'wxMSW' in wx.PlatformInfo else False menu = wx.Menu() self.chargeEventMap = {} modType, chargeDict = Ammo.getInstance().getModuleStructuredAmmo(self.module, ammo=self.mainCharges) if modType == 'ddTurret': self._addSeparator(menu, _t('Long Range')) menuItems = [] for charges in chargeDict.values(): if len(charges) == 1: menuItems.append(self._addCharge(rootMenu if msw else menu, charges[0])) else: baseCharge = charges[0] menuItem = self._addCharge(rootMenu if msw else menu, baseCharge) menuItems.append(menuItem) subMenu = wx.Menu() subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch) menuItem.SetSubMenu(subMenu) self._addSeparator(subMenu, _t('Less Damage')) for charge in charges: subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge)) self._addSeparator(subMenu, _t('More Damage')) for menuItem in menuItems: menu.Append(menuItem) self._addSeparator(menu, _t('Short Range')) elif modType == 'ddMissile': menuItems = [] for chargeCatName, charges in chargeDict.items(): menuItem = wx.MenuItem(menu, wx.ID_ANY, self.ddMissileChargeCatTrans.get(chargeCatName, chargeCatName)) bitmap = BitmapLoader.getBitmap("%s_small" % chargeCatName, "gui") if bitmap is not None: menuItem.SetBitmap(bitmap) menuItems.append(menuItem) subMenu = wx.Menu() subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch) menuItem.SetSubMenu(subMenu) self._addSeparator(subMenu, _t('Less Damage')) for charge in charges: subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge)) self._addSeparator(subMenu, _t('More Damage')) for menuItem in menuItems: menu.Append(menuItem) elif modType == 'miner': menuItems = [] for catHandle, catLabel in self.oreChargeCatTrans.items(): charges = chargeDict.get(catHandle) if not charges: continue if len(charges) == 1: menuItems.append(self._addCharge(rootMenu if msw else menu, charges[0])) else: menuItem = wx.MenuItem(menu, wx.ID_ANY, catLabel) menuItems.append(menuItem) subMenu = wx.Menu() subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch) menuItem.SetSubMenu(subMenu) for charge in charges: subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge)) for menuItem in menuItems: menu.Append(menuItem) elif modType == 'general': for charge in chargeDict['general']: menu.Append(self._addCharge(rootMenu if msw else menu, charge)) menu.Append(self._addCharge(rootMenu if msw else menu, None)) return menu
def __init__(self, data=None, labels=None, grouping='Image', key_col_indices=[0], chMap=None, parent=None, title='Data Table', autosave=True): ''' Initialize the datagrid. Arguments: data -- the grid as a np object array labels -- text labels for each column Keyword arguments: grouping -- group name string, e.g., "Wells" key_col_indices -- column indexes for group IDs chMap -- channel-to-color map for ImageViewer, or None to disable parent -- wx parent window title -- # is launched. If None, no images will be displayed. ''' wx.Frame.__init__(self, parent, id=-1, title=title) self.SetName('DataTable') self.grid = None self.file = None if not (data is None or labels is None): self.grid = HugeTableGrid(self, data, labels, key_col_indices, grouping, chMap) if autosave and self.grid: # Autosave enrichments to temp dir logging.info('Auto saving data...') filename = gettempdir() + os.sep + 'CPA_enrichments_' + ctime( ).replace(' ', '_').replace(':', '-') + '.csv' self.SaveCSV(filename, self.grid.GetTable().data, self.grid.GetTable().col_labels) self.filemenu = wx.Menu() self.loadCSVMenuItem = \ wx.MenuItem(parentMenu=self.filemenu, id=ID_LOAD_CSV, text='Load data from CSV\tCtrl+O', help='Load data from CSV.') self.saveCSVMenuItem = \ wx.MenuItem(parentMenu=self.filemenu, id=ID_SAVE_CSV, text='Save data to CSV\tCtrl+S', help='Saves data as comma separated values.') self.savePerImageCountsToCSVMenuItem = \ wx.MenuItem(parentMenu=self.filemenu, id=-1, text='Save per-image counts to CSV', help='Saves per-image phenotype counts as comma separated values.') self.exitMenuItem = \ wx.MenuItem(parentMenu=self.filemenu, id=ID_EXIT, text='Exit\tCtrl+Q', help='Close the Data Table') self.filemenu.AppendItem(self.loadCSVMenuItem) self.filemenu.AppendItem(self.saveCSVMenuItem) self.filemenu.AppendItem(self.savePerImageCountsToCSVMenuItem) self.filemenu.AppendSeparator() self.filemenu.AppendItem(self.exitMenuItem) menuBar = wx.MenuBar() self.SetMenuBar(menuBar) self.GetMenuBar().Append(self.filemenu, 'File') self.dbmenu = wx.Menu() self.writeToTempTableMenuItem = \ wx.MenuItem(parentMenu=self.dbmenu, id=-1, text='Write temporary table for Plate Viewer', help='Writes this table to a temporary table in your database so Plate Viewer can access it.') self.dbmenu.AppendItem(self.writeToTempTableMenuItem) self.GetMenuBar().Append(self.dbmenu, 'Database') if self.grid: self.CreateColumnMenu() self.CreateStatusBar() self.SetSize((800, 500)) if self.grid: self.grid.SetSize(self.Size) self.Bind(wx.EVT_MENU, self.OnSaveCSV, self.saveCSVMenuItem) self.Bind(wx.EVT_MENU, self.OnLoadCSV, self.loadCSVMenuItem) self.Bind(wx.EVT_MENU, self.OnSavePerImageCountsToCSV, self.savePerImageCountsToCSVMenuItem) self.Bind(wx.EVT_MENU, self.OnWriteTempTableToDB, self.writeToTempTableMenuItem) self.Bind(wx.EVT_MENU, self.OnExit, self.exitMenuItem) wx.EVT_SIZE(self, self.OnSize) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('O'), ID_LOAD_CSV), (wx.ACCEL_CTRL, ord('S'), ID_SAVE_CSV), (wx.ACCEL_CTRL, ord('Q'), ID_EXIT), ]) self.SetAcceleratorTable(accelerator_table)
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(DEF_WIN_WIDTH, DEF_WIN_HEIGHT)) # setting up the 'File' menu fileMenu = wx.Menu() fileMenu.Append(ID_SAVE_IMAGE, "Save &Image...") fileMenu.AppendSeparator() fileMenu.Append(wx.ID_OPEN, "&Open Script...") fileMenu.Append(wx.ID_SAVE, "&Save Script") fileMenu.Append(wx.ID_SAVEAS, "Save Script &As...") fileMenu.AppendSeparator() fileMenu.Append(wx.ID_EXIT, "E&xit") # setting up the 'Edit' menu editMenu = wx.Menu() editMenu.Append(wx.ID_UNDO, "&Undo") editMenu.Append(wx.ID_REDO, "Re&do") editMenu.AppendSeparator() editMenu.Append(wx.ID_CUT, "Cu&t") editMenu.Append(wx.ID_COPY, "&Copy") editMenu.Append(wx.ID_PASTE, "&Paste") editMenu.AppendSeparator() editMenu.Append(wx.ID_SELECTALL, "Select &All") # setting up the 'Image' menu imageMenu = wx.Menu() imageMenu.AppendCheckItem(ID_RUN_SCRIPT, "&Run Script") # setting up the 'Help' menu helpMenu = wx.Menu() helpMenu.Append(wx.ID_HELP, "&Handbook") helpMenu.Append(wx.ID_ABOUT, "&About...") # creating the menubar self.menuBar = wx.MenuBar() self.menuBar.Append(fileMenu, "&File") self.menuBar.Append(editMenu, "&Edit") self.menuBar.Append(imageMenu, "&Image") self.menuBar.Append(helpMenu, "&Help") self.SetMenuBar(self.menuBar) # creating all necessary widgets self.toolBar = ToolBarCtrl(self) self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) self.imageCtrl = ImageCtrl(self.splitter) self.editorCtrl = EditorCtrl(parent=self.splitter, eventRecevier=self) self.splitter.SetMinimumPaneSize(20) self.splitter.SetSashGravity(0.8) self.splitter.SplitVertically(self.imageCtrl, self.editorCtrl, -DEF_WIN_WIDTH / 3) # use box sizer to set layout options self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.toolBar) self.sizer.Add(self.splitter, 1, wx.EXPAND) # layout sizers self.SetSizer(self.sizer) self.SetAutoLayout(1) self.Show(True) # set event handlers wx.EVT_MENU(self, ID_SAVE_IMAGE, self.OnSaveImage) wx.EVT_MENU(self, wx.ID_OPEN, self.OnOpenScript) wx.EVT_MENU(self, wx.ID_SAVE, self.OnSaveScript) wx.EVT_MENU(self, wx.ID_SAVEAS, self.OnSaveScriptAs) wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit) wx.EVT_MENU(self, ID_RUN_SCRIPT, self.OnRunScript) wx.EVT_MENU(self, wx.ID_HELP, self.OnHandbook) wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout) self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChange) self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChange) self.Bind(wx.EVT_MENU_OPEN, self.OnMenuOpen) self.Bind(wx.EVT_IDLE, self.OnIdle) # misc variables self.running = False self.filename = ""
def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False # Création du menu contextuel menuPop = wx.Menu() # Item Modifier item = wx.MenuItem(menuPop, 10, _(u"Ajouter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ajouter.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Ajouter, id=10) menuPop.AppendSeparator() # Item Ajouter item = wx.MenuItem(menuPop, 20, _(u"Modifier")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) if noSelection == True : item.Enable(False) # Item Supprimer item = wx.MenuItem(menuPop, 30, _(u"Supprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Supprimer.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Supprimer, id=30) if noSelection == True : item.Enable(False) menuPop.AppendSeparator() # Item Monter item = wx.MenuItem(menuPop, 60, _(u"Monter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_haut.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Monter, id=60) if noSelection == True : item.Enable(False) # Item Descendre item = wx.MenuItem(menuPop, 70, _(u"Descendre")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_bas.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Descendre, id=70) if noSelection == True : item.Enable(False) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=40) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=50) menuPop.AppendSeparator() # Item Export Texte item = wx.MenuItem(menuPop, 600, _(u"Exporter au format Texte")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Texte2.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportTexte, id=600) # Item Export Excel item = wx.MenuItem(menuPop, 700, _(u"Exporter au format Excel")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Excel.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportExcel, id=700) self.PopupMenu(menuPop) menuPop.Destroy()
def __init__(self, *args, **kwds): # begin wxGlade: Bar.__init__ wx.MenuBar.__init__(self, *args, **kwds) self.file = wx.Menu() self.file.Append(wx.ID_NEW, _("&New\tCtrl+N"), "", wx.ITEM_NORMAL) self.file.Append(wx.ID_OPEN, _("&Open file(s)...\tCtrl+O"), "", wx.ITEM_NORMAL) self.file.Append(wx.ID_SAVE, _("&Save\tCtrl+S"), "", wx.ITEM_NORMAL) self.file.Append(wx.ID_SAVEAS, _("Save &As...\tCtrl+Alt+S"), "", wx.ITEM_NORMAL) self.file.Append(SAVE_COPY, _("Sa&ve a Copy...\tShift+Ctrl+Alt+S"), "", wx.ITEM_NORMAL) self.file.AppendSeparator() self.file.Append(OPEN_WORKSPACE, _("Open &Workspace"), "", wx.ITEM_NORMAL) self.file.Append(SAVE_WORKSPACE, _("Save Workspace"), "", wx.ITEM_NORMAL) self.file.Append(SAVE_WORKSPACE_AS, _("Save Workspace As..."), "", wx.ITEM_NORMAL) self.file.AppendSeparator() self.file.Append(SAVE_UML_AS, _("Save Uml As...\tCtrl+Shift+S"), "", wx.ITEM_NORMAL) self.file.Append(PRINT_UML_SETUP, _("Page Uml Setup..."), "", wx.ITEM_NORMAL) self.file.Append(PRINT_UML_PREVIEW, _("Print Uml Preview..."), "", wx.ITEM_NORMAL) self.file.Append(PRINT_UML, _("Print Uml..."), "", wx.ITEM_NORMAL) self.file.AppendSeparator() self.file.Append(wx.ID_CLOSE, _("&Close\tCtrl+W"), "", wx.ITEM_NORMAL) self.file.Append(wx.ID_EXIT, _("&Exit\tAlt+F4"), "", wx.ITEM_NORMAL) self.file.AppendSeparator() self.file.Append(REMEMBER_OPEN_FILES, _("&Remember open file(s)"), "", wx.ITEM_CHECK) self.Append(self.file, _("&File")) self.edit = wx.Menu() self.edit.Append(wx.ID_UNDO, _("&Undo\tCtrl+Z"), "", wx.ITEM_NORMAL) self.edit.Append(wx.ID_REDO, _("&Redo\tCtrl+Y"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(wx.ID_CUT, _("Cut"), "", wx.ITEM_NORMAL) self.edit.Append(wx.ID_COPY, _("&Copy"), "", wx.ITEM_NORMAL) self.edit.Append(wx.ID_PASTE, _("&Paste"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(EXECUTE, _("&Execute in shell\tCtrl+Shift+E"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(wx.ID_REPLACE, _("&Find && replace...\tCtrl+F"), "", wx.ITEM_NORMAL) self.edit.Append(wx.ID_FIND, _("Find &Next\tF3"), "", wx.ITEM_NORMAL) self.edit.Append(GO_TO_LINE, _("&Go to line...\tCtrl+G"), "", wx.ITEM_NORMAL) self.edit.Append(BROWSE_SOURCE, _("&Browse source\tCtrl+Enter"), "", wx.ITEM_NORMAL) self.edit.Append(AUTO_COMPLETE, _("&Auto complete\tCtrl+Space"), "", wx.ITEM_NORMAL) self.edit.Append(SHOW_DOCSTRING, _("&Show docstring\tCtrl+Shift+Space"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(INDENT, _("&Indent"), "", wx.ITEM_NORMAL) self.edit.Append(DEDENT, _("&Dedent\tShift+Tab"), "", wx.ITEM_NORMAL) self.edit.Append(COMMENT, _("Co&mment\tAlt+3"), "", wx.ITEM_NORMAL) self.edit.Append(UNCOMMENT, _("U&nComment\tAlt+4"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(INSERT_SEPARATOR, _("Insert &separator...\tAlt+I"), "", wx.ITEM_NORMAL) self.edit.Append(INSERT_SIGNATURE, _("Insert &signature\tCtrl+Shift+I"), "", wx.ITEM_NORMAL) self.edit.AppendSeparator() self.edit.Append(PREFERENCES, _("&Preferences...\tCtrl+Alt+P"), "", wx.ITEM_NORMAL) self.Append(self.edit, _("&Edit")) self.view = wx.Menu() self.view.Append(WHITESPACE, _("&Whitespace"), "", wx.ITEM_CHECK) self.view.Append(INDENTATION_GUIDES, _("&Indentation guides"), "", wx.ITEM_CHECK) self.view.Append(RIGHT_EDGE_INDICATOR, _("Ri&ght edge indicator"), "", wx.ITEM_CHECK) self.view.Append(END_OF_LINE_MARKER, _("&End-of-line marker"), "", wx.ITEM_CHECK) self.view.AppendSeparator() self.view.Append(AS_NOTEBOOK, _("As ¬ebook"), "", wx.ITEM_NORMAL) self.view.Append(AS_COLUMNS, _("As &columns"), "", wx.ITEM_NORMAL) self.view.Append(AS_ROWS, _("As &rows"), "", wx.ITEM_NORMAL) self.view.AppendSeparator() self.view.Append(SIDEBAR, _("&Sidebar\tCtrl+F12"), "", wx.ITEM_CHECK) self.view.Append(SHELL, _("S&hell\tF12"), "", wx.ITEM_CHECK) self.view.AppendSeparator() self.view.Append(CLEAR_OUTPUT, _("Clear &output"), "", wx.ITEM_NORMAL) self.view.Append(REFRESH, _("&Refresh\tF5"), "", wx.ITEM_NORMAL) self.Append(self.view, _("&View")) self.tools = wx.Menu() self.tools.Append(RUN, _("Run\\Stop\tCtrl+R"), "", wx.ITEM_NORMAL) self.tools.Append(RUN_WITHOUT_ARGUMENTS, _("Run without arguments/Stop\tCtrl+Shift+R"), "", wx.ITEM_NORMAL) self.tools.AppendSeparator() self.tools.Append(RUN_DEBUG, _("Run/Stop with &WinPdb\tCtrl+F9"), "", wx.ITEM_NORMAL) self.tools.Append(DEBUG, _("&Debug with winpdb...\tAlt+F9"), "", wx.ITEM_NORMAL) self.tools.AppendSeparator() self.tools.Append(RUN_TERMINAL, _("&Run in terminal\tF9"), "", wx.ITEM_NORMAL) self.tools.Append(RUN_TERMINAL_WITHOUT_ARGUMENTS, _("Run in terminal without &arguments\tShift+F9"), "", wx.ITEM_NORMAL) self.tools.Append(RUN_TERMINAL_WITHOUT_ARGUMENTS_EXIT, _("Run in terminal without &arguments && exit\tCtrl+Shift+F9"), "", wx.ITEM_NORMAL) self.tools.AppendSeparator() self.tools.Append(IMPORT, _("&Import in shell\tF10"), "", wx.ITEM_NORMAL) self.tools.AppendSeparator() self.tools.Append(BROWSE_OBJECT_WITH_PYFILLING, _("&Browse object with PyFilling...\tCtrl+Alt+F"), "", wx.ITEM_NORMAL) self.tools.Append(TEST_REGULAR_EXPRESSION_WITH_KIKI, _("Test regular expression with &Kiki...\tCtrl+K"), "", wx.ITEM_NORMAL) self.tools.Append(DESIGN_A_GUI_WITH_WXGLADE, _("Design a &gui with wxGlade...\tCtrl+Alt+G"), "", wx.ITEM_NORMAL) self.tools.Append(DESIGN_A_GUI_WITH_XRC, _("Design a gui with &XRC...\tCtrl+Alt+X"), "", wx.ITEM_NORMAL) self.tools.Append(CHECK_SOURCE_WITH_PYCHECKER, _("&Check source with PyChecker\tCtrl+Alt+C"), "", wx.ITEM_NORMAL) self.tools.AppendSeparator() self.tools.Append(BROWSE_FOLDER, _("Browse &folder\tCtrl+Shift+F"), "", wx.ITEM_NORMAL) self.tools.Append(OPEN_TERMINAL_EMULATOR, _("Open &terminal...\tCtrl+Shift+T"), "", wx.ITEM_NORMAL) self.Append(self.tools, _("&Tools")) self.blender = wx.Menu() self.blender.Append(LOAD_IN_BLENDER, _("&Load into Blender\tCtrl+B"), "", wx.ITEM_NORMAL) self.blender.Append(REFERENCE_IN_BLENDER, _("&Reference in Blender\tCtrl+Alt+B"), "", wx.ITEM_NORMAL) self.blender.AppendSeparator() self.blender.Append(REDRAW_BLENDER_WINDOW, _("Re&draw Blender window\tF5"), "", wx.ITEM_NORMAL) self.blender.AppendSeparator() self.blender.Append(BLENDER_PYTHON_MANUAL, _("Blender Python &manual..."), "", wx.ITEM_NORMAL) self.blender.Append(BLENDER_PYTHON_TUTORIAL, _("Blender Python &tutorial..."), "", wx.ITEM_NORMAL) self.blender.AppendSeparator() self.blender.Append(BLENDER_HOMEPAGE, _("Blender &homepage..."), "", wx.ITEM_NORMAL) self.blender.Append(DOWNLOAD_BLENDER, _("&Download Blender..."), "", wx.ITEM_NORMAL) self.blender.Append(FORUM_BLENDER_PYTHON, _("Forum &Blender Python..."), "", wx.ITEM_NORMAL) self.blender.Append(FORUM_ELYSIUN_PYTHON, _("Forum &Blenderartists Python..."), "", wx.ITEM_NORMAL) self.blender.AppendSeparator() self.blender.Append(ADD_SPE_TO_BLENDER, _("&Add SPE and Winpdb to Blender menu..."), "", wx.ITEM_NORMAL) self.Append(self.blender, _("&Blender")) self.links = wx.Menu() self.links.Append(SPE_HOMEPAGE, _("&Spe homepage..."), "", wx.ITEM_NORMAL) self.links.Append(FORUM_SPE, _("&Forum spe..."), "", wx.ITEM_NORMAL) self.links.AppendSeparator() self.links.Append(PYTHON_HOMEPAGE, _("&Python homepage..."), "", wx.ITEM_NORMAL) self.links.Append(PYTHON_ANNOUNCEMENTS, _("Python &announcements..."), "", wx.ITEM_NORMAL) self.links.Append(PYTHON_COOKBOOK, _("Python cook&book..."), "", wx.ITEM_NORMAL) self.links.Append(PYTHON_DAILY, _("Python &daily..."), "", wx.ITEM_NORMAL) self.links.Append(PYTHON_PACKAGE_INDEX, _("Python package &index..."), "", wx.ITEM_NORMAL) self.links.AppendSeparator() self.links.Append(AUTHORS_HOMEPAGE, _("&Authors homepage"), "", wx.ITEM_NORMAL) self.Append(self.links, _("&Links")) self.window = wx.Menu() self.window.Append(NEXT, _("&Next\tCtrl+`"), "", wx.ITEM_NORMAL) self.window.Append(PREVIOUS, _("&Previous\tCtrl+Shift+`"), "", wx.ITEM_NORMAL) self.Append(self.window, _("&Window")) self.help = wx.Menu() self.help.Append(MANUAL, _("&Manual..."), "", wx.ITEM_NORMAL) self.help.Append(KEYBOARD_SHORTCUTS, _("&Keyboard shortcuts..."), "", wx.ITEM_NORMAL) self.help.AppendSeparator() self.help.Append(PYTHON_LIBRARY, _("Python &library..."), "", wx.ITEM_NORMAL) self.help.Append(PYTHON_REFERENCE, _("Python &reference..."), "", wx.ITEM_NORMAL) self.help.Append(PYTHON_DOCUMENTATION_SERVER, _("Python documentation &server..."), "", wx.ITEM_NORMAL) self.help.AppendSeparator() self.help.Append(WXGLADE_MANUAL, _("wxGlade manual..."), "", wx.ITEM_NORMAL) self.help.Append(WXGLADE_TUTORIAL, _("wx&Glade tutorial..."), "", wx.ITEM_NORMAL) self.help.Append(WXWINDOWS_DOCUMENTATION, _("wxWindows documentation..."), "", wx.ITEM_NORMAL) self.help.AppendSeparator() self.help.Append(DONATE, _("&Donate..."), "", wx.ITEM_NORMAL) self.help.Append(ABOUT, _("&About..."), "", wx.ITEM_NORMAL) self.Append(self.help, _("&Help")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_MENU, self.menu_new, id=wx.ID_NEW) self.Bind(wx.EVT_MENU, self.menu_open_files, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.menu_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.menu_save_as, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.menu_save_copy, id=SAVE_COPY) self.Bind(wx.EVT_MENU, self.menu_open_workspace, id=OPEN_WORKSPACE) self.Bind(wx.EVT_MENU, self.menu_save_workspace, id=SAVE_WORKSPACE) self.Bind(wx.EVT_MENU, self.menu_save_workspace_as, id=SAVE_WORKSPACE_AS) self.Bind(wx.EVT_MENU, self.menu_save_uml_as, id=SAVE_UML_AS) self.Bind(wx.EVT_MENU, self.menu_print_uml_setup, id=PRINT_UML_SETUP) self.Bind(wx.EVT_MENU, self.menu_print_uml_preview, id=PRINT_UML_PREVIEW) self.Bind(wx.EVT_MENU, self.menu_print_uml, id=PRINT_UML) self.Bind(wx.EVT_MENU, self.menu_close, id=wx.ID_CLOSE) self.Bind(wx.EVT_MENU, self.menu_exit, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.menu_remember_open_files, id=REMEMBER_OPEN_FILES) self.Bind(wx.EVT_MENU, self.menu_undo, id=wx.ID_UNDO) self.Bind(wx.EVT_MENU, self.menu_redo, id=wx.ID_REDO) self.Bind(wx.EVT_MENU, self.menu_cut, id=wx.ID_CUT) self.Bind(wx.EVT_MENU, self.menu_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.menu_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.menu_execute, id=EXECUTE) self.Bind(wx.EVT_MENU, self.menu_find__replace, id=wx.ID_REPLACE) self.Bind(wx.EVT_MENU, self.menu_find_next, id=wx.ID_FIND) self.Bind(wx.EVT_MENU, self.menu_go_to_line, id=GO_TO_LINE) self.Bind(wx.EVT_MENU, self.menu_browse_source, id=BROWSE_SOURCE) self.Bind(wx.EVT_MENU, self.menu_auto_complete, id=AUTO_COMPLETE) self.Bind(wx.EVT_MENU, self.menu_show_docstring, id=SHOW_DOCSTRING) self.Bind(wx.EVT_MENU, self.menu_indent, id=INDENT) self.Bind(wx.EVT_MENU, self.menu_dedent, id=DEDENT) self.Bind(wx.EVT_MENU, self.menu_comment, id=COMMENT) self.Bind(wx.EVT_MENU, self.menu_uncomment, id=UNCOMMENT) self.Bind(wx.EVT_MENU, self.menu_insert_separator, id=INSERT_SEPARATOR) self.Bind(wx.EVT_MENU, self.menu_insert_signature, id=INSERT_SIGNATURE) self.Bind(wx.EVT_MENU, self.menu_preferences, id=PREFERENCES) self.Bind(wx.EVT_MENU, self.menu_whitespace, id=WHITESPACE) self.Bind(wx.EVT_MENU, self.menu_indentation, id=INDENTATION_GUIDES) self.Bind(wx.EVT_MENU, self.menu_right_edge_indicator, id=RIGHT_EDGE_INDICATOR) self.Bind(wx.EVT_MENU, self.menu_end_of_line_marker, id=END_OF_LINE_MARKER) self.Bind(wx.EVT_MENU, self.menu_as_notebook, id=AS_NOTEBOOK) self.Bind(wx.EVT_MENU, self.menu_as_columns, id=AS_COLUMNS) self.Bind(wx.EVT_MENU, self.menu_as_rows, id=AS_ROWS) self.Bind(wx.EVT_MENU, self.menu_sidebar, id=SIDEBAR) self.Bind(wx.EVT_MENU, self.menu_shell, id=SHELL) self.Bind(wx.EVT_MENU, self.menu_clear_output, id=CLEAR_OUTPUT) self.Bind(wx.EVT_MENU, self.menu_refresh, id=REFRESH) self.Bind(wx.EVT_MENU, self.menu_run, id=RUN) self.Bind(wx.EVT_MENU, self.menu_run_without_arguments, id=RUN_WITHOUT_ARGUMENTS) self.Bind(wx.EVT_MENU, self.menu_run_debug, id=RUN_DEBUG) self.Bind(wx.EVT_MENU, self.menu_debug, id=DEBUG) self.Bind(wx.EVT_MENU, self.menu_run_terminal, id=RUN_TERMINAL) self.Bind(wx.EVT_MENU, self.menu_run_terminal_without_arguments, id=RUN_TERMINAL_WITHOUT_ARGUMENTS) self.Bind(wx.EVT_MENU, self.menu_run_terminal_without_arguments_exit, id=RUN_TERMINAL_WITHOUT_ARGUMENTS_EXIT) self.Bind(wx.EVT_MENU, self.menu_import, id=IMPORT) self.Bind(wx.EVT_MENU, self.menu_browse_object_with_pyfilling, id=BROWSE_OBJECT_WITH_PYFILLING) self.Bind(wx.EVT_MENU, self.menu_test_regular_expression_with_kiki, id=TEST_REGULAR_EXPRESSION_WITH_KIKI) self.Bind(wx.EVT_MENU, self.menu_design_a_gui_with_wxglade, id=DESIGN_A_GUI_WITH_WXGLADE) self.Bind(wx.EVT_MENU, self.menu_design_a_gui_with_xrc, id=DESIGN_A_GUI_WITH_XRC) self.Bind(wx.EVT_MENU, self.menu_check_source_with_pychecker, id=CHECK_SOURCE_WITH_PYCHECKER) self.Bind(wx.EVT_MENU, self.menu_browse_folder, id=BROWSE_FOLDER) self.Bind(wx.EVT_MENU, self.menu_open_terminal_emulator, id=OPEN_TERMINAL_EMULATOR) self.Bind(wx.EVT_MENU, self.menu_load_in_blender, id=LOAD_IN_BLENDER) self.Bind(wx.EVT_MENU, self.menu_reference_in_blender, id=REFERENCE_IN_BLENDER) self.Bind(wx.EVT_MENU, self.menu_blender_python_manual, id=BLENDER_PYTHON_MANUAL) self.Bind(wx.EVT_MENU, self.menu_blender_python_tutorial, id=BLENDER_PYTHON_TUTORIAL) self.Bind(wx.EVT_MENU, self.menu_blender_homepage, id=BLENDER_HOMEPAGE) self.Bind(wx.EVT_MENU, self.menu_download_blender, id=DOWNLOAD_BLENDER) self.Bind(wx.EVT_MENU, self.menu_forum_blender_python, id=FORUM_BLENDER_PYTHON) self.Bind(wx.EVT_MENU, self.menu_forum_elysiun_python, id=FORUM_ELYSIUN_PYTHON) self.Bind(wx.EVT_MENU, self.menu_add_spe_to_blender, id=ADD_SPE_TO_BLENDER) self.Bind(wx.EVT_MENU, self.menu_spe_homepage, id=SPE_HOMEPAGE) self.Bind(wx.EVT_MENU, self.menu_forum_spe, id=FORUM_SPE) self.Bind(wx.EVT_MENU, self.menu_python_announcements, id=PYTHON_ANNOUNCEMENTS) self.Bind(wx.EVT_MENU, self.menu_python_cookbook, id=PYTHON_COOKBOOK) self.Bind(wx.EVT_MENU, self.menu_python_daily, id=PYTHON_DAILY) self.Bind(wx.EVT_MENU, self.menu_python_package_index, id=PYTHON_PACKAGE_INDEX) self.Bind(wx.EVT_MENU, self.menu_authors_homepage, id=AUTHORS_HOMEPAGE) self.Bind(wx.EVT_MENU, self.menu_next, id=NEXT) self.Bind(wx.EVT_MENU, self.menu_previous, id=PREVIOUS) self.Bind(wx.EVT_MENU, self.menu_manual, id=MANUAL) self.Bind(wx.EVT_MENU, self.menu_keyboard_shortcuts, id=KEYBOARD_SHORTCUTS) self.Bind(wx.EVT_MENU, self.menu_python_library, id=PYTHON_LIBRARY) self.Bind(wx.EVT_MENU, self.menu_python_reference, id=PYTHON_REFERENCE) self.Bind(wx.EVT_MENU, self.menu_python_documentation_server, id=PYTHON_DOCUMENTATION_SERVER) self.Bind(wx.EVT_MENU, self.menu_wxglade_manual, id=WXGLADE_MANUAL) self.Bind(wx.EVT_MENU, self.menu_wxglade_tutorial, id=WXGLADE_TUTORIAL) self.Bind(wx.EVT_MENU, self.menu_wxwindows_documentation, id=WXWINDOWS_DOCUMENTATION) self.Bind(wx.EVT_MENU, self.menu_donate, id=DONATE) self.Bind(wx.EVT_MENU, self.menu_about, id=ABOUT)
def OnInit(self): self.frame = wx.Frame(None, -1, self.title, wx.DefaultPosition, self.default_size) self.frame.Bind(wx.EVT_CLOSE, self.OnFrameClose) self.frame.CreateStatusBar() tb = self.frame.CreateToolBar(style=wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT) isinstance(tb, wx.ToolBar) tb.SetToolBitmapSize((32, 32)) import gltbx.wx_viewers_images as images tb.Bind(wx.EVT_TOOL, self.OnToolClick) self.mcs_center_id = wx.NewId() tb.AddSimpleTool( self.mcs_center_id, images.mcs_img.as_wx_Bitmap(), "Rotate around MCS center", "Object are to be rotated around the Minimum Covering Sphere (MCS)" "centre." " Keyboard shortcut: m", ) self.center_on_screen_id = wx.NewId() tb.AddSimpleTool( self.center_on_screen_id, images.centre_img.as_wx_Bitmap(), "Center in window", "Shifts object so that centre of rotation is centered in window." " Keyboard shortcut: c", ) self.fit_on_screen_id = wx.NewId() tb.AddSimpleTool( self.fit_on_screen_id, images.fit_img.as_wx_Bitmap(), "Fit in window", "Resizes and shifts object to fit into window." " Keyboard shortcut: f", ) self.mark_snap_back_id = wx.NewId() tb.AddSimpleTool( self.mark_snap_back_id, images.mark_snap_back_img.as_wx_Bitmap(), "Mark orientation for snap-back", "Marks object orientation as the target of a subsequent snap-back." " Keyboard shortcut: k", ) self.snap_back_id = wx.NewId() tb.AddSimpleTool( self.snap_back_id, images.snap_back_img.as_wx_Bitmap(), "Snap back orientation", "Rotates object back to the last marked orientation." " Keyboard shortcut: a", ) self.toggle_spin_id = wx.NewId() tb.AddCheckTool( self.toggle_spin_id, images.spin_img.as_wx_Bitmap(), shortHelp="Spin on/off", longHelp="Turns auto-spin on/off. Keyboard shortcut: s", ) tb.Realize() menuBar = wx.MenuBar() file_menu = wx.Menu() item = file_menu.Append(-1, "E&xit\tAlt-X", "Exit demo") self.Bind(wx.EVT_MENU, self.OnExitApp, item) menuBar.Append(file_menu, "&File") self.frame.SetMenuBar(menuBar) self.init_view_objects() self.update_status_bar() self.view_objects.SetFocus() self.SetTopWindow(self.frame) self.frame.Show(True) return True