def __init__(self, parent): wx.Panel.__init__(self, parent) style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT |wx.TR_MULTIPLE |\ wx.TR_HAS_VARIABLE_ROW_HEIGHT # no need to sort the commands, as they are naturally sorted by # execution time self.tree = FastLoadTreeCtrl(self, getchildren=self.get_children, style=style, sort=False) self.history = {} sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.tree, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(sizer) dp.connect(receiver=self.AddHistory, signal='Shell.addHistory') self.root = self.tree.AddRoot('The Root Item') self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree) self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRightClick, self.tree) self.Bind(wx.EVT_MENU, self.OnProcessEvent, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.OnProcessEvent, id=wx.ID_CUT) self.Bind(wx.EVT_MENU, self.OnProcessEvent, id=self.ID_EXECUTE) self.Bind(wx.EVT_MENU, self.OnProcessEvent, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.OnProcessEvent, id=wx.ID_CLEAR) accel = [ (wx.ACCEL_CTRL, ord('C'), wx.ID_COPY), (wx.ACCEL_CTRL, ord('X'), wx.ID_CUT), (wx.ACCEL_CTRL, ord('E'), self.ID_EXECUTE), (wx.ACCEL_NORMAL, wx.WXK_DELETE, wx.ID_DELETE), ] self.accel = wx.AcceleratorTable(accel) self.SetAcceleratorTable(self.accel) self.LoadHistory()
def __init__(self, bond_table_base, *args, **kwds): kwds["style"] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.bond_num_col_label = wx.StaticText(self, -1, "Interaction Number") self.tie_col_label = wx.StaticText(self, -1, "Tie Parameters") self.edit_col_label = wx.StaticText(self, -1, "Edit Parameters") #self.Type_of_Param_RadioBox = wx.RadioBox(self, -1, "Type of Parameter", choices=["Fixed Value", "Variable"], majorDimension=1, style=wx.RA_SPECIFY_ROWS) self.main_grid_sizer = wx.FlexGridSizer(1, 3, 10, 10)#Initially has no matrices self.__set_properties() self.__do_layout() #self.Bind(wx.EVT_RADIOBOX, self.OnTypeChange, self.Type_of_Param_RadioBox) self.bond_table_base = bond_table_base #self.sized_items = []#keep a reference to all items added to the main #sizer so that they can be removed later. self.labels = [] self.tie_grids = [] self.edit_grids = [] self.selected_parameter = None #for click tying self.bond_table_base.AddParamPanel(self) self.colors = [] self.currentColor = 0 self.colorMappings = [] self.__populateColorList() connect(self.OnParamChange, signal = "Parameter Values Changed") connect(self.UpdateTables, signal = "File Load")
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.CLIP_CHILDREN, static=False, tree=None): """Create FillingText instance.""" wx.html.HtmlWindow.__init__(self, parent, id, pos, size, style) if not static: dispatcher.connect(receiver=self.push, signal='Interpreter.push') self.tree = tree self.currentHTML = ""
async def load(self): # create a menu object self.exampleMenu = wx.Menu() # add an item to it, and save it exampleItem = self.exampleMenu.Append(18, 'Example Item', 'This is the example item description') # bind the press of that item to a function self.exampleMenu.Bind(wx.EVT_MENU, self.pressed, exampleItem) # listen for the RegisterMenus event with the registerMenu method as callback dispatcher.connect( self.registerHandler, Events.RegisterEvent )
def __init__(self): Compile.__init__(self) #the number of lines to remove from the traceback line count, #for multi line hack in compilation stage self._lineadjust = 0 #source buffer to get print line of source in exception self._buffer = '' #register message handlers dp.connect(self.future_flag, 'debugger.futureflag')
def initialize(cls, frame): if cls.frame: return cls.frame = frame if not frame: return dp.connect(cls.uninitialize, 'frame.exit') # waves panel cls.panel = cls(frame) dp.send(signal='frame.add_panel', panel=cls.panel, title="wave", showhidemenu='View:Panels:Wave')
def bindEvents(self): self.window.Bind(wx.EVT_KEY_DOWN, self.OnKeyEvent) # connect(self.OnCellChange, signal = "Cell Change") # connect(self.OnBondChange, signal = "Bond Change") connect(self.OnPick, signal = "Pick Event") connect(self.OnModelChange, signal = "Model Change") connect(self.OnSaveImage, signal = "Save Image") connect(self.OnAnalyticDispCalc, signal = "Analytic Dispersion Complete")
def Initialize(cls, frame, **kwargs): cls.frame = frame dp.connect(receiver=cls.Uninitialize, signal='frame.exit') ns = {} ns['wx'] = wx ns['app'] = wx.GetApp() ns['frame'] = cls.frame intro = 'Welcome To bsmedit ' + __version__ cls.panelShell = Shell(cls.frame, introText=intro, locals=ns) active = kwargs.get('active', True) direction = kwargs.get('direction', 'top') dp.send(signal="frame.add_panel", panel=cls.panelShell, active=active, title="Shell", showhidemenu="View:Panels:Console", direction=direction)
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE, rootObject=None, rootLabel=None, rootIsNamespace=False, static=False): """Create FillingTree instance.""" self.installFavourites(rootObject) wx.TreeCtrl.__init__(self, parent, id, pos, size, style) self.rootIsNamespace = rootIsNamespace import __main__ if rootObject is None: rootObject = __main__.__dict__ self.rootIsNamespace = True if rootObject is __main__.__dict__ and rootLabel is None: rootLabel = 'locals()' if not rootLabel: rootLabel = 'Ingredients' rootData = wx.TreeItemData(rootObject) self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData) self.SetItemHasChildren(self.root, self.objHasChildren(rootObject)) self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding, id=self.GetId()) self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, id=self.GetId()) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=self.GetId()) self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated, id=self.GetId()) if not static: dispatcher.connect(receiver=self.push, signal='Interpreter.push') self.showPrivateMembers = False self.showModules = False self.showClasses = False self.showTypes = False self.showMethods = False
def Initialize(cls, frame, **kwargs): if cls.isInitialized: return cls.isInitialized = True cls.clsFrame = frame cls.kwargs = kwargs resp = dp.send('frame.add_menu', path='File:New:Figure', rxsignal='bsm.figure') if resp: cls.clsID_new_figure = resp[0][1] if cls.clsID_new_figure is not wx.NOT_FOUND: dp.connect(cls.ProcessCommand, 'bsm.figure') dp.connect(cls.Uninitialize, 'frame.exit') dp.connect(cls.Initialized, 'frame.initialized') dp.connect(cls.setactive, 'frame.activate_panel') dp.connect(cls.OnBufferChanged, 'sim.buffer_changed')
def __init__(self, parent, title=None, num=-1, thisFig=None): # set the size to positive value, otherwise the toolbar will assert # wxpython/ext/wxWidgets/src/gtk/bitmap.cpp(539): assert ""width > 0 && # height > 0"" failed in Create(): invalid bitmap size wx.Panel.__init__(self, parent, size=(100, 100)) # initialize matplotlib stuff self.figure = thisFig if not self.figure: self.figure = Figure(None, None) self.canvas = FigureCanvas(self, -1, self.figure) # since matplotlib 3.2, it does not allow canvas size to become smaller # than MinSize in wx backend. So the canvas size (e.g., (640, 480))may # be large than the window size. self.canvas.SetMinSize((1, 1)) #self.canvas.manager = self self.num = num if title is None: title = 'Figure %d' % self.num self.title = title self.isdestory = False szAll = wx.BoxSizer(wx.VERTICAL) self.figure.set_label(title) self.toolbar = Toolbar(self.canvas, self.figure) szAll.Add(self.toolbar, 0, wx.EXPAND) szAll.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.toolbar.update() self.SetSizer(szAll) self.figmgr = FigureManagerWx(self.canvas, num, self) self.Bind(wx.EVT_CLOSE, self._onClose) self.canvas.mpl_connect('button_press_event', self._onClick) dp.connect(self.simLoad, 'sim.loaded') self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) self.Bind(wx.EVT_MENU, self.OnProcessCommand, id=self.clsID_delete_datatip) self.Bind(wx.EVT_MENU, self.OnProcessCommand, id=self.clsID_clear_datatip) self.Bind(wx.EVT_MENU, self.OnProcessCommand, id=wx.ID_NEW)
def Initialize(cls, frame, **kwargs): if cls.isInitialized: return cls.isInitialized = True cls.frame = frame # stack panel cls.panelStack = StackPanel(frame) dp.send('frame.add_panel', panel=cls.panelStack, title="Call Stack", active=False, showhidemenu='View:Panels:Call Stack') # debugger toolbar dp.send('frame.add_menu', path='Tools:Debug', rxsignal='', kind='Popup') cls.tbDebug = aui.AuiToolBar(frame, style=wx.TB_FLAT | wx.TB_HORIZONTAL) items = ( ('Run\tF5', 'resume', run_svg, run_grey_svg, 'paused'), ('Stop\tShift-F5', 'stop', stop_svg, stop_grey_svg, 'paused'), ('Step\tF10', 'step', step_over_svg, step_over_grey_svg, 'paused'), ('Step Into\tF11', 'step_into', step_into_svg, step_into_grey_svg, 'can_stepin'), ('Step Out\tShift-F11', 'step_out', step_out_svg, step_out_grey_svg, 'can_stepout'), ) cls.menus = {} for label, signal, xpm, xpm_grey, status in items: resp = dp.send('frame.add_menu', path='Tools:Debug:' + label, rxsignal='debugger.' + signal, updatesignal='debugtool.updateui') if not resp: continue cls.menus[resp[0][1]] = status cls.tbDebug.AddTool(resp[0][1], label, svg_to_bitmap(xpm), svg_to_bitmap(xpm_grey), wx.ITEM_NORMAL, label) cls.tbDebug.Realize() dp.send('frame.add_panel', panel=cls.tbDebug, title='Debugger', active=False, paneInfo=aui.AuiPaneInfo().Name('debugger').Caption( 'Debugger').ToolbarPane().Top(), showhidemenu='View:Toolbars:Debugger') dp.connect(cls.OnUpdateMenuUI, 'debugtool.updateui') dp.connect(cls.OnDebugPaused, 'debugger.paused') dp.connect(cls.OnDebugEnded, 'debugger.ended') dp.connect(cls.Uninitialize, 'frame.exit')
def __init__(self, parent, id, session): wx.Frame.__init__(self, parent, id, 'Magnetic Cell', size= (700,700)) self.session = session self.vtkPanel = vtkPanel(self, -1, session) self.procManager = self.vtkPanel.procManager #Add Menus self.AddMenus() #Create other windows self.showAtomFrame() self.showBondFrame() self.showProcessFrame() #Add custom status bar self.sb = wx.StatusBar(self) self.SetStatusBar(self.sb) self.sb.SetFieldsCount(2) self.sb.SetStatusWidths([-1, -3]) self.sb.SetStatusText("Normal Selection Mode" , 0) connect(self.OnPick, signal = "Pick Event")
def Initialize(cls, frame, **kwargs): if cls.frame: return cls.frame = frame if not frame: return active = kwargs.get('active', True) direction = kwargs.get('direction', 'top') # history panel cls.panelHistory = HistoryPanel(frame) dp.send(signal='frame.add_panel', panel=cls.panelHistory, title="History", showhidemenu='View:Panels:Command History', active=active, direction=direction) # help panel cls.panelHelp = HelpPanel(frame) dp.send(signal='frame.add_panel', panel=cls.panelHelp, title="Help", target='History', showhidemenu='View:Panels:Command Help', active=active, direction=direction) # directory panel cls.panelDir = DirPanel(frame) dp.send(signal='frame.add_panel', panel=cls.panelDir, title="Browsing", target="History", showhidemenu='View:Panels:Browsing', active=active, direction=direction) dp.connect(receiver=cls.Uninitialize, signal='frame.exit')
def __init__(self, parent): wx.Panel.__init__(self, parent) sizer = wx.BoxSizer(wx.VERTICAL) self.listctrl = StackListCtrl(self, style=wx.LC_REPORT | wx.BORDER_NONE | wx.LC_EDIT_LABELS | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL) # | wx.BORDER_SUNKEN # | wx.LC_SORT_ASCENDING # | wx.LC_NO_HEADER self.listctrl.InsertColumn(0, 'Name') self.listctrl.InsertColumn(1, 'Line') self.listctrl.InsertColumn(2, 'File') sizer.Add(self.listctrl, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer(sizer) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.listctrl) dp.connect(self.OnDebugEnded, 'debugger.ended') dp.connect(self.OnDebugUpdateScopes, 'debugger.update_scopes') dp.connect(self.OnDebugUpdateScopes, 'debugger.paused')
def __init__(self, parent, id, session): wx.Panel.__init__(self, parent, id) self.session = session #Create the table of bonds self.bondList = bondListGrid(self, -1, session) #Create the spinner which controls the length of the bond list self.bondSpinner = wx.SpinCtrl(self, -1, "") self.bondSpinner.SetRange(1,100) self.bondSpinner.SetValue(1) self.bondSpinner.Bind(wx.EVT_TEXT, self.OnGridResize, self.bondSpinner) #Create the generate button self.genButton = wx.Button(self, -1, "Generate") topSizer = wx.BoxSizer(wx.HORIZONTAL) topSizer.Add(self.bondSpinner) topSizer.Add(self.genButton) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(topSizer) sizer.Add(self.bondList, 1, wx.EXPAND) self.SetSizer(sizer) self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.genButton) connect(self.OnBondAddition, signal = "Bond Added") connect(self.OnFileLoad, signal = "File Load") #Create the parameter editing frame paramFrame = wx.Frame(self.GetParent(), -1, "Parameters") param_panel = ParameterPanel(self.bondList.table, paramFrame, -1) paramFrame.Show() #Fit this window self.Fit() self.GetParent().Fit()#Fit the frame containing this panel self.GetParent().SetMinSize(self.GetParent().GetSize()) connect(self.OnParamChange, signal = "Parameter Values Changed")
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.CLIP_CHILDREN, introText='', locals=None, InterpClass=None, startupScript=None, execStartupScript=True, *args, **kwds): # variables used in push, which may be called by # wx.py.shell.Shell.__init__ when execStartupScript is True self.enable_debugger = False self.silent = True pyshell.Shell.__init__(self, parent, id, pos, size, style, introText, locals, InterpClass, startupScript, execStartupScript, useStockId=False, *args, **kwds) wx.CallAfter(self.redirectStdout, True) wx.CallAfter(self.redirectStderr, True) #self.redirectStdout(True) #self.redirectStderr(True) # the default sx function (!cmd to run external command) does not work # on windows __builtin__.sx = sx self.callTipInsert = False self.searchHistory = True self.silent = False self.autoIndent = True self.running = False self.debugger = EngineDebugger() self.LoadHistory() self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(wx.EVT_MENU, self.OnProcessMenu) self.interp.locals['clear'] = self.clear self.interp.locals['help'] = _help self.interp.locals['on'] = True self.interp.locals['off'] = False dp.connect(self.writeOut, 'shell.write_out') dp.connect(self.runCommand, 'shell.run') dp.connect(self.debugPrompt, 'shell.prompt') dp.connect(self.addHistory, 'shell.add_to_history') dp.connect(self.IsDebuggerOn, 'debugger.debugging') dp.connect(self.getAutoCompleteList, 'shell.auto_complete_list') dp.connect(self.getAutoCompleteKeys, 'shell.auto_complete_keys') dp.connect(self.getAutoCallTip, 'shell.auto_call_tip') dp.connect(self.OnActivatePanel, 'frame.activate_panel') dp.connect(self.OnActivate, 'frame.activate') dp.connect(self.OnFrameClosing, 'frame.closing')
# Define a message receiver class Receiver(wx.Button): def onHello(self, who=None): print 'hi to', self.GetLabel(), 'from', who # Create the app with buttons for sending and slots for receiving app = wx.App(redirect=False) root = wx.Frame(None) bs = wx.BoxSizer(wx.HORIZONTAL) # Create slot and tell to expect connections from signal special and # extraspecial; it accepts signals from any sender f1 = Receiver(root, -1, 'Receiver 1') bs.Add(f1) connect(f1.onHello, signal='special') connect(f1.onHello, signal='extraspecial') # Create slot for 'special' from catalog_sender, whatever that is. f3 = Receiver(root, -1, 'Receiver 2') bs.Add(f3) connect(f3.onHello, signal='special', sender=catalog_sender) # Define a parameterized event handler which can produce the # appropriate signal type given a button press event. def signaller(signal, who, sender=Anonymous): def sendsignal(event): send(signal, sender=sender, who=who) return sendsignal
def fix_underscore_in_builtin(): import wx.py.dispatcher as d # it helpfully sends out this signal when a statement has just been # executed d.connect(handle, signal='Interpreter.push', weak=False)
# Define a message receiver class Receiver(wx.Button): def onHello(self,who=None): print 'hi to',self.GetLabel(),'from',who # Create the app with buttons for sending and slots for receiving app = wx.App(redirect=False) root = wx.Frame(None) bs = wx.BoxSizer(wx.HORIZONTAL) # Create slot and tell to expect connections from signal special and # extraspecial; it accepts signals from any sender f1 = Receiver(root,-1,'Receiver 1') bs.Add(f1) connect(f1.onHello,signal='special') connect(f1.onHello,signal='extraspecial') # Create slot for 'special' from catalog_sender, whatever that is. f3 = Receiver(root,-1,'Receiver 2') bs.Add(f3) connect(f3.onHello,signal='special',sender=catalog_sender) # Define a parameterized event handler which can produce the # appropriate signal type given a button press event. def signaller(signal,who,sender=Anonymous): def sendsignal(event): send(signal,sender=sender,who=who) return sendsignal f2 = wx.Button(root,-1,'Sender 1') f2.Bind(wx.EVT_BUTTON,signaller('special','Sender 1',plottable_sender))
def __init__(self, parent, id=wx.ID_ANY, title=u'bsmedit', pos=wx.DefaultPosition, size=wx.Size(800, 600), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL): wx.Frame.__init__(self, parent, id=id, title=title, pos=pos, size=size, style=style) self._mgr = AuiManagerPlus() self._mgr.SetManagedWindow(self) self.menuAddon = {} self.paneAddon = {} self._pane_num = 0 dp.connect(self.AddMenu, 'frame.add_menu') dp.connect(self.DeleteMenu, 'frame.delete_menu') dp.connect(self.AddPanel, 'frame.add_panel') dp.connect(self.DeletePanel, 'frame.delete_panel') dp.connect(self.ShowPanel, 'frame.show_panel') dp.connect(self.TogglePanel, 'frame.check_menu') dp.connect(self.UpdateMenu, 'frame.update_menu') self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, parent, id, session): wx.Panel.__init__(self, parent, id) self.session = session #Add Space Group spaceGroupLabel = wx.StaticText(self, -1, "Space Group:") self.spaceGroupSpinner = wx.SpinCtrl(self, -1, "") self.spaceGroupSpinner.SetRange(1,230) self.spaceGroupSpinner.SetValue(1) #Add Atom List self.atomList = atomListGrid(self, -1, session = self.session) #Add a button on upper right to generate new image self.genButton = wx.Button(self, -1, "Generate") #Add a, b, c, Alpha, gamma, beta, Na, Nb, Nc aLabel = wx.StaticText(self, -1, "a:") self.aText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) aSizer = wx.BoxSizer(wx.VERTICAL) aSizer.Add(aLabel, 0) aSizer.Add(self.aText, 0) bLabel = wx.StaticText(self, -1, "b:") self.bText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) bSizer = wx.BoxSizer(wx.VERTICAL) bSizer.Add(bLabel, 0) bSizer.Add(self.bText, 0) cLabel = wx.StaticText(self, -1, "c:") self.cText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) cSizer = wx.BoxSizer(wx.VERTICAL) cSizer.Add(cLabel, 0) cSizer.Add(self.cText, 0) alphaLabel = wx.StaticText(self, -1, "alpha:") self.alphaText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) alphaSizer = wx.BoxSizer(wx.VERTICAL) alphaSizer.Add(alphaLabel, 0) alphaSizer.Add(self.alphaText, 0) betaLabel = wx.StaticText(self, -1, "beta:") self.betaText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) betaSizer = wx.BoxSizer(wx.VERTICAL) betaSizer.Add(betaLabel, 0) betaSizer.Add(self.betaText, 0) gammaLabel = wx.StaticText(self, -1, "gamma:") self.gammaText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) gammaSizer = wx.BoxSizer(wx.VERTICAL) gammaSizer.Add(gammaLabel, 0) gammaSizer.Add(self.gammaText, 0) #Magnetic Cell naLabel = wx.StaticText(self, -1, "Na:") self.naText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) naSizer = wx.BoxSizer(wx.VERTICAL) naSizer.Add(naLabel, 0) naSizer.Add(self.naText, 0) nbLabel = wx.StaticText(self, -1, "Nb:") self.nbText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) nbSizer = wx.BoxSizer(wx.VERTICAL) nbSizer.Add(nbLabel, 0) nbSizer.Add(self.nbText, 0) ncLabel = wx.StaticText(self, -1, "Nc:") self.ncText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) ncSizer = wx.BoxSizer(wx.VERTICAL) ncSizer.Add(ncLabel, 0) ncSizer.Add(self.ncText, 0) #Cutoff cutoffNaLabel = wx.StaticText(self, -1, "Na:") self.cutoffNaText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) cutoffNaSizer = wx.BoxSizer(wx.VERTICAL) cutoffNaSizer.Add(cutoffNaLabel, 0) cutoffNaSizer.Add(self.cutoffNaText, 0) cutoffNbLabel = wx.StaticText(self, -1, "Nb:") self.cutoffNbText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) cutoffNbSizer = wx.BoxSizer(wx.VERTICAL) cutoffNbSizer.Add(cutoffNbLabel, 0) cutoffNbSizer.Add(self.cutoffNbText, 0) cutoffNcLabel = wx.StaticText(self, -1, "Nc:") self.cutoffNcText = wx.TextCtrl(self, -1, size = (60, -1), style = wx.TE_RICH2) cutoffNcSizer = wx.BoxSizer(wx.VERTICAL) cutoffNcSizer.Add(cutoffNcLabel, 0) cutoffNcSizer.Add(self.cutoffNcText, 0) #Organize a,b,c and alpha, gamma, beta , Na, Nb, Nc into a grid dimSizer = wx.GridSizer(cols = 3, hgap = 15, vgap = 5) dimSizer.Add(aSizer) dimSizer.Add(bSizer) dimSizer.Add(cSizer) dimSizer.Add(alphaSizer) dimSizer.Add(betaSizer) dimSizer.Add(gammaSizer) unitCellBox = wx.StaticBox(self, -1, "Unit Cell") unitCellSizer = wx.StaticBoxSizer(unitCellBox, wx.VERTICAL) unitCellSizer.Add(dimSizer) leftTopSizer = wx.GridBagSizer(2,2) leftTopSizer.Add(unitCellSizer, (0,0), (1,2)) leftTopSizer.Add(wx.StaticText(self, -1, "Atoms:"), (1,0)) self.atomSpinner = wx.SpinCtrl(self, -1, "") self.atomSpinner.SetRange(1,100) self.atomSpinner.SetValue(1) self.atomSpinner.Bind(wx.EVT_TEXT, self.OnGridResize, self.atomSpinner) leftTopSizer.Add(self.atomSpinner, (1,1)) magCellBox = wx.StaticBox(self, -1, "Magnetic Cell") magCellSizer = wx.StaticBoxSizer(magCellBox, wx.HORIZONTAL) magCellSizer.Add(naSizer) magCellSizer.Add(nbSizer) magCellSizer.Add(ncSizer) cutoffBox = wx.StaticBox(self, -1, "Cutoff") cutoffSizer = wx.StaticBoxSizer(cutoffBox, wx.HORIZONTAL) cutoffSizer.Add(cutoffNaSizer) cutoffSizer.Add(cutoffNbSizer) cutoffSizer.Add(cutoffNcSizer) spaceGroupSizer = wx.BoxSizer(wx.HORIZONTAL) spaceGroupSizer.Add(spaceGroupLabel, 0) spaceGroupSizer.Add(self.spaceGroupSpinner, 0) MagCutoffSizer = wx.BoxSizer(wx.VERTICAL) MagCutoffSizer.Add(magCellSizer) MagCutoffSizer.Add(cutoffSizer) topSizer = wx.FlexGridSizer(cols = 2, hgap = 5, vgap = 5) topSizer.Add(spaceGroupSizer) topSizer.Add(self.genButton, 0, wx.ALIGN_RIGHT) topSizer.Add(leftTopSizer) topSizer.Add(MagCutoffSizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(topSizer, 0) sizer.Add(self.atomList, 1, wx.EXPAND) self.SetSizer(sizer) self.Fit() self.GetParent().Fit() self.GetParent().SetMinSize(self.GetParent().GetSize()) #execute the function OnGenerate when the generate button is pressed self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.genButton) connect(self.OnFileLoad, signal = "File Load")
def __init__(self, parent, **kwargs): FramePlus.__init__(self, parent, title='bsmedit', size=wx.Size(800, 600), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.InitMenu() self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() | aui.AUI_MGR_ALLOW_ACTIVE_PANE | aui.AUI_MGR_SMOOTH_DOCKING | aui.AUI_MGR_USE_NATIVE_MINIFRAMES | aui.AUI_MGR_LIVE_RESIZE) # set mainframe icon icon = wx.Icon() icon.CopyFromBitmap(wx.Bitmap(to_byte(bsmedit_xpm))) self.SetIcon(icon) # status bar self.statusbar = wx.StatusBar(self) self.SetStatusBar(self.statusbar) self.statusbar_width = [-1] self.statusbar.SetStatusWidths(self.statusbar_width) # persistent configuration conf = kwargs.get('config', 'bsmedit') self.config = wx.FileConfig(conf, style=wx.CONFIG_USE_LOCAL_FILE) # recent file list self.filehistory = wx.FileHistory(8) self.config.SetPath('/FileHistory') self.filehistory.Load(self.config) self.filehistory.UseMenu(self.menuRecentFiles) self.filehistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnMenuFileHistory, id=wx.ID_FILE1, id2=wx.ID_FILE9) self.closing = False # Create & Link the Drop Target Object to main window self.SetDropTarget(FileDropTarget()) self.Bind(wx.EVT_ACTIVATE, self.OnActivate) self.Bind(aui.EVT_AUI_PANE_ACTIVATED, self.OnPaneActivated) dp.connect(self.SetPanelTitle, 'frame.set_panel_title') dp.connect(self.ShowStatusText, 'frame.show_status_text') dp.connect(self.AddFileHistory, 'frame.add_file_history') dp.connect(self.SetConfig, 'frame.set_config') dp.connect(self.GetConfig, 'frame.get_config') # append sys path sys.path.append('.') for p in kwargs.get('path', []): sys.path.append(p) self.bsm_packages = auto_load_module self.addon = {} self.InitAddOn(kwargs.get('module', ())) # initialization done, broadcasting the message so plugins can do some # after initialization processing. dp.send('frame.initialized') # load the perspective if not kwargs.get('ignore_perspective', False): perspective = self.GetConfig('mainframe', 'perspective') if perspective and not wx.GetKeyState(wx.WXK_SHIFT): self._mgr.LoadPerspective(perspective) self.UpdatePaneMenuLabel() self.Bind(aui.EVT_AUINOTEBOOK_TAB_RIGHT_DOWN, self.OnPageRightDown) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
def __init__(self): self.compiler = EngineCompiler() #debugger state self._paused = False #is paused. self._can_stepin = False #debugger is about to enter a new scope self._can_stepout = False #debugger can be stepped out of a scope #debugger command flags self._resume = False #debugging was resumed. self._end = False #stop debugging, finish running code self._stop = False #stop running code self._stepin = False #debugger step in to scope self._stepout = False #debugger step out of scope #event used to wake the trace function when paused self._resume_event = PseudoEvent() #user commands to execute when the debugger is paused #this is check in the trace function and executed in the active scope. self._cmd = None #debugger scopes: #keep track of the different scopes available for tools to query self._scopes = [] #list of scope (function) names self._frames = [] #list of scope frames self._active_scope = 0 #the current scope level used for exec/eval/commands self._paused_active_scope = 0 #internal variable used to keep track of where wer started debugging self._bottom_frame = None #files to look for when tracing... self._fncache = {} #absolute filename cache self._block_files = [ ] #list of filepaths not to trace in (or any further) #prevent trace in all engine module files to avoid locks blocking comms threads. self.set_block_file(os.path.dirname(__file__) + os.sep + '*.*') # break points - info on breakpoints is stored in an DictList instance # which allows items (the breakpoint data dict) to be retrieved by #filename or id. The key tcount is the breakpoint counters for hits, # and is reset before each user command. self.bpoints = DictList() self._bp_hcount = {} # hit counter {id: hcount} self._bp_tcount = {} # trigger counter {id: tcount} #Register message handlers for the debugger dp.connect(self.pause, 'debugger.pause') dp.connect(self.resume, 'debugger.resume') dp.connect(self.stop_code, 'debugger.stop') dp.connect(self.end, 'debugger.end') dp.connect(self.step, 'debugger.step') dp.connect(self.step_in, 'debugger.step_into') dp.connect(self.step_out, 'debugger.step_out') dp.connect(self.set_scope, 'debugger.set_scope') dp.connect(self.set_breakpoint, 'debugger.set_breakpoint') dp.connect(self.clear_breakpoint, 'debugger.clear_breakpoint') dp.connect(self.edit_breakpoint, 'debugger.edit_breakpoint') dp.connect(self.get_breakpoint, 'debugger.get_breakpoint') dp.connect(self.get_status, 'debugger.get_status')
def __init__(self): # load plugins super().__init__( None, title=f'BEE Manipulator {str(config.version)}' ) # sets the app icon self.SetIcon(utilities.icon) # init the logging window asyncio.run( logWindow.init() ) asyncio.run( appDateCheck() ) # set the utilities.root pointer to the object of this class root.instance = self try: self.SetPosition(wx.Point(config.load('mainWindowPos'))) except config.ConfigError: self.CenterOnScreen() self.SetSize(width=600, height=500) self.SetMinSize( wx.Size(width=600, height=500) ) LOGGER.info(f'internet connected: {utilities.isonline()}') pluginSystem.systemObj.startSync() """ A menu bar is composed of menus, which are composed of menu items. This section builds the menu bar and binds actions to them """ # file menu bar self.fileMenu = wx.Menu() openPortalDirItem = self.fileMenu.Append(0, loc('menu.file.openportaldir.name')+'\tCtrl-P', loc('menu.file.openportaldir.description') ) openBeeDirItem = self.fileMenu.Append(1, loc('menu.file.openbeedir.name')+"\tCtrl-B", loc('menu.file.openbeedir.description') ) syncGamesItem = self.fileMenu.Append(2, loc('menu.file.syncgames.name'), loc('menu.file.syncgames.description') ) exitItem = self.fileMenu.Append(3, loc('menu.file.exit.name'), loc('menu.file.exit.description') ) # options menu bar self.optionsMenu = wx.Menu() settingsItem = self.optionsMenu.Append(4, loc('menu.options.settings.name')+'\tCtrl-S', loc('menu.options.settings.description') ) toggleLogWindowItem = self.optionsMenu.Append(5, loc('menu.options.logtoggle.name')+'\tCtrl-L', loc('menu.options.logtoggle.description') ) reloadPluginsItem = self.optionsMenu.Append(6, loc('menu.options.reloadplugins.name'), loc('menu.options.reloadplugins.description') ) reloadPackagesItem = self.optionsMenu.Append(7, loc('menu.options.reloadpackages.name'), loc('menu.options.reloadpackages.description') ) # portal 2 menu bar self.portalMenu = wx.Menu() verifyGameFilesItem = self.portalMenu.Append(8, loc('menu.portal.vgf.name'), loc('menu.portal.vgf.description') ) uninstallBeeItem = self.portalMenu.Append(9, loc('menu.portal.uninstallbee.name'), loc('menu.portal.uninstallbee.description') ) installBeeItem = self.portalMenu.Append(10, loc('menu.portal.installbee.name'), loc('menu.portal.installbee.description') ) openP2Item = self.portalMenu.Append( 11, loc( 'menu.portal.openp2.name' ), loc( 'menu.portal.openp2.description' ) ) openBeeItem = self.portalMenu.Append( 12, loc( 'menu.portal.openbee.name' ), loc( 'menu.portal.openbee.description' ) ) # help menu bar self.helpMenu = wx.Menu() aboutItem = self.helpMenu.Append(13, loc('menu.help.about.name'), loc('menu.help.about.description') ) checkUpdatesItem = self.helpMenu.Append(14, loc('menu.help.cupdates.name'), loc('menu.help.cupdates.description') ) wikiItem = self.helpMenu.Append(15, loc('menu.help.wiki.name'), loc('menu.help.wiki.description') ) githubItem = self.helpMenu.Append(16, loc('menu.help.github.name'), loc('menu.help.github.description') ) discordItem = self.helpMenu.Append(17, loc('menu.help.discord.name'), loc('menu.help.discord.description') ) # set menu item icons self.helpMenu.FindItemById(13).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_bm.png') ) self.helpMenu.FindItemById(14).SetBitmap( wx.Bitmap( f'{config.assetsPath}icons/materialdesign/menu_update_black.png' ) ) self.helpMenu.FindItemById(15).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_github.png') ) self.helpMenu.FindItemById(16).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_github.png') ) self.helpMenu.FindItemById(17).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_discord.png') ) # makes the menu bar self.menuBar = wx.MenuBar() self.menuBar.Append(self.fileMenu, loc('menu.file.name') ) self.menuBar.Append(self.optionsMenu, loc('menu.options.name') ) self.menuBar.Append(self.portalMenu, loc('menu.portal.name') ) self.menuBar.Append(self.helpMenu, loc('menu.help.name') ) # Give the menu bar to the frame self.SetMenuBar(self.menuBar) self.CreateStatusBar() self.SetStatusText( loc('statusbar.text').replace('{username}', config.steamUsername() ) ) # file menu self.Bind( wx.EVT_MENU, self.openp2dir, openPortalDirItem ) self.Bind( wx.EVT_MENU, self.openBEEdir, openBeeDirItem ) self.Bind( wx.EVT_MENU, self.syncGames, syncGamesItem ) self.Bind( wx.EVT_MENU, self.exit, exitItem ) # options menu self.Bind( wx.EVT_MENU, self.openSettingsWindow, settingsItem ) self.Bind( wx.EVT_MENU, logWindow.toggleVisibility, toggleLogWindowItem ) self.Bind( wx.EVT_MENU, self.reloadPlugins, reloadPluginsItem ) self.Bind( wx.EVT_MENU, self.reloadPackages, reloadPackagesItem ) # portal 2 menu self.Bind( wx.EVT_MENU, self.verifyGameFiles, verifyGameFilesItem ) self.Bind( wx.EVT_MENU, self.uninstallBee, uninstallBeeItem ) self.Bind( wx.EVT_MENU, self.installBee, installBeeItem ) self.Bind( wx.EVT_MENU, self.openP2, openP2Item ) self.Bind( wx.EVT_MENU, self.openBee, openBeeItem ) # help menu self.Bind( wx.EVT_MENU, self.openAboutWindow, aboutItem ) self.Bind( wx.EVT_MENU, self.checkUpdates, checkUpdatesItem ) self.Bind( wx.EVT_MENU, self.openWiki, wikiItem ) self.Bind( wx.EVT_MENU, self.openGithub, githubItem ) self.Bind( wx.EVT_MENU, self.openDiscord, discordItem ) # other events self.Bind( wx.EVT_CLOSE, self.OnClose, self ) self.Bind( wx.EVT_SIZING, self.OnResize, self ) self.Bind( wx.EVT_MAXIMIZE, self.OnMaximize, self ) if config.load('beePath') is None: self.portalMenu.Enable(9, False) self.fileMenu.Enable(1, False) else: self.portalMenu.Enable(10, False) # register event handlers dispatcher.connect( receiver=self.RemoveMenu, signal=Events.UnregisterMenu ) # trigger the registerMenu event dispatcher.send( Events.RegisterEvent, RegisterHandler=pluginSystem.RegisterHandler() ) """ A notebook is a controller which manages multiple windows with associated tabs. This section makes the notebook """ self.book = wx.Notebook( self, name="Main Menu", size=wx.Size( self.GetSize().GetWidth(), self.GetSize().GetHeight() ) ) self.browserTab = PackageBrowserPage(self.book) self.book.AddPage(self.browserTab, "Package Browser")