class EditorShellNotebook(wx.Notebook): """A notebook containing an editor page and a shell page.""" def __init__(self, parent, filename=None): """Create EditorShellNotebook instance.""" wx.Notebook.__init__(self, parent, id=-1) usePanels = True if usePanels: editorparent = editorpanel = wx.Panel(self, -1) shellparent = shellpanel = wx.Panel(self, -1) else: editorparent = self shellparent = self self.buffer = Buffer() self.editor = Editor(parent=editorparent) self.buffer.addEditor(self.editor) self.buffer.open(filename) self.shell = Shell(parent=shellparent, locals=self.buffer.interp.locals, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER) self.buffer.interp.locals.clear() if usePanels: self.AddPage(page=editorpanel, text='Editor', select=True) self.AddPage(page=shellpanel, text='Shell') # Setup sizers editorsizer = wx.BoxSizer(wx.VERTICAL) editorsizer.Add(self.editor.window, 1, wx.EXPAND) editorpanel.SetSizer(editorsizer) editorpanel.SetAutoLayout(True) shellsizer = wx.BoxSizer(wx.VERTICAL) shellsizer.Add(self.shell, 1, wx.EXPAND) shellpanel.SetSizer(shellsizer) shellpanel.SetAutoLayout(True) else: self.AddPage(page=self.editor.window, text='Editor', select=True) self.AddPage(page=self.shell, text='Shell') self.editor.setFocus() self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged, id=self.GetId()) def OnPageChanged(self, event): """Page changed event handler.""" selection = event.GetSelection() if selection == 0: self.editor.setFocus() else: self.shell.SetFocus() event.Skip() def SetFocus(self): wx.Notebook.SetFocus(self) selection = self.GetSelection() if selection == 0: self.editor.setFocus() else: self.shell.SetFocus()
class EditorShellNotebook(wx.Notebook): """A notebook containing an editor page and a shell page.""" def __init__(self, parent, filename=None): """Create EditorShellNotebook instance.""" wx.Notebook.__init__(self, parent, id=-1) usePanels = True if usePanels: editorparent = editorpanel = wx.Panel(self, -1) shellparent = shellpanel = wx.Panel(self, -1) else: editorparent = self shellparent = self self.buffer = Buffer() self.editor = Editor(parent=editorparent) self.buffer.addEditor(self.editor) self.buffer.open(filename) self.shell = Shell( parent=shellparent, locals=self.buffer.interp.locals, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER ) self.buffer.interp.locals.clear() if usePanels: self.AddPage(page=editorpanel, text="Editor", select=True) self.AddPage(page=shellpanel, text="Shell") # Setup sizers editorsizer = wx.BoxSizer(wx.VERTICAL) editorsizer.Add(self.editor.window, 1, wx.EXPAND) editorpanel.SetSizer(editorsizer) editorpanel.SetAutoLayout(True) shellsizer = wx.BoxSizer(wx.VERTICAL) shellsizer.Add(self.shell, 1, wx.EXPAND) shellpanel.SetSizer(shellsizer) shellpanel.SetAutoLayout(True) else: self.AddPage(page=self.editor.window, text="Editor", select=True) self.AddPage(page=self.shell, text="Shell") self.editor.setFocus() self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged, id=self.GetId()) def OnPageChanged(self, event): """Page changed event handler.""" selection = event.GetSelection() if selection == 0: self.editor.setFocus() else: self.shell.SetFocus() event.Skip() def SetFocus(self): wx.Notebook.SetFocus(self) selection = self.GetSelection() if selection == 0: self.editor.setFocus() else: self.shell.SetFocus()
def bufferCreate(self, filename=None): """Create new buffer.""" buffer = Buffer() panel = wx.Panel(parent=self.notebook, id=-1) panel.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: x) editor = Editor(parent=panel) panel.editor = editor sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(editor.window, 1, wx.EXPAND) panel.SetSizer(sizer) panel.SetAutoLayout(True) sizer.Layout() buffer.addEditor(editor) buffer.open(filename) self.setEditor(editor) self.notebook.AddPage(page=panel, text=self.buffer.name, select=True) self.editor.setFocus()
def bufferCreate(self, filename=None): """Create new buffer.""" self.bufferDestroy() buffer = Buffer() self.panel = panel = wx.Panel(parent=self, id=-1) panel.Bind (wx.EVT_ERASE_BACKGROUND, lambda x: x) editor = Editor(parent=panel) panel.editor = editor sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(editor.window, 1, wx.EXPAND) panel.SetSizer(sizer) panel.SetAutoLayout(True) sizer.Layout() buffer.addEditor(editor) buffer.open(filename) self.setEditor(editor) self.editor.setFocus() self.SendSizeEvent()
def bufferCreate(self, filename=None): """Create new buffer.""" self.bufferDestroy() buffer = Buffer() self.panel = panel = wx.Panel(parent=self, id=-1) panel.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: x) editor = Editor(parent=panel) panel.editor = editor sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(editor.window, 1, wx.EXPAND) panel.SetSizer(sizer) panel.SetAutoLayout(True) sizer.Layout() buffer.addEditor(editor) buffer.open(filename) self.setEditor(editor) self.editor.setFocus() self.SendSizeEvent()
class EditorShellNotebook(wx.Notebook): """A notebook containing an editor page and a shell page.""" #----------------- def __init__(self, parent, filename=None): """Create EditorShellNotebook instance.""" if DEBUG : print "EditorShellNotebook" self.parent=parent wx.Notebook.__init__(self, parent, id=-1) editorparent = editorpanel = wx.Panel(self, -1) logparent = logpanel = wx.Panel(self, -1) plotparent = plotpanel = wx.Panel(self, -1) self.buffer = Buffer() self.editor = Editor(parent=editorparent) self.buffer.addEditor(self.editor) self.buffer.open(filename) self.log= ViewLog(parent=logparent) self.editor.log = self.log self.plot = PlotFigure(parent=plotparent,filename=filename) self.editor.plot = self.plot # Set the log target to be this textctrl using our own class wx.Log_SetActiveTarget(MyLog(self.log, 0)) # for serious debugging if SERIOUSDEBUG: wx.Log_SetActiveTarget(wx.LogStderr()) wx.Log_SetTraceMask(wx.TraceMessages) self.AddPage(page=editorpanel, text='Editor', select=True) self.AddPage(page=logpanel, text='Log') self.AddPage(page=plotpanel, text='Plot') # Setup sizers editorsizer = wx.BoxSizer(wx.VERTICAL) editorsizer.Add(self.editor.window, 1, wx.EXPAND) editorpanel.SetSizer(editorsizer) editorpanel.SetAutoLayout(True) logsizer = wx.BoxSizer(wx.VERTICAL) logsizer.Add(self.log.window, 1, wx.EXPAND) logpanel.SetSizer(logsizer) logpanel.SetAutoLayout(True) plotsizer1 = wx.BoxSizer(wx.HORIZONTAL) plotsizer1.Add(self.plot.canvas, 1, wx.EXPAND) plotsizer1.Add(self.plot.choice, 0, wx.EXPAND) plotsizer = wx.BoxSizer(wx.VERTICAL) plotsizer.Add(plotsizer1, 1, wx.EXPAND) plotsizer.Add(self.plot.toolbar, 0, wx.GROW) plotpanel.SetSizer(plotsizer) self.plot.Fit() # Plot the spectra read from filename if self.plot.plot_data() : self.SetSelection(2) self.plot.Show() wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged) #----------------- def OnPageChanged(self, event): """Page changed event handler.""" if DEBUG : print "EditorShellNotebook","OnPageChanged" selection = event.GetSelection() if selection == 0: self.editor.setFocus() ## if selection == 1: ## self.log.setFocus() ## if selection == 2: ## self.plot.setFocus() event.Skip() #----------------- def SetFocus(self): if DEBUG : print "EditorShellNotebook","SetFocus" wx.Notebook.SetFocus(self) selection = self.GetSelection() if selection == 0: self.editor.setFocus()