本文整理汇总了Python中buffer.Buffer.addEditor方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.addEditor方法的具体用法?Python Buffer.addEditor怎么用?Python Buffer.addEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.addEditor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditorShellNotebook
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import addEditor [as 别名]
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()
示例2: bufferCreate
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import addEditor [as 别名]
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()
示例3: EditorShellNotebook
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import addEditor [as 别名]
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()