Package mathbench :: Package lab :: Module labbench
[hide private]

Source Code for Module mathbench.lab.labbench

 1  #!/usr/bin/python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  """ 
 5  Inspired by 
 6  PyAlaCarte and PyAlaMode editors from WxPython 
 7   
 8  Combines the shell and filling into one control. 
 9  """ 
10   
11  import wx 
12  from wx.py.shell import Shell 
13   
14  # for the session's history 
15  from mathbench.lab.logbook import LogBook 
16  from mathbench.lab.apparatus import ApparatusTree 
17   
18   
19 -class LabBench(wx.SplitterWindow):
20 """LabBench based on SplitterWindow.""" 21 sashoffset = 300 22
23 - def __init__(self, parent, id=-1, pos=wx.DefaultPosition, 24 size=wx.DefaultSize, style=wx.SP_3D|wx.SP_LIVE_UPDATE, 25 name='LabBench Window', rootObject=None, rootLabel=None, 26 rootIsNamespace=True, intro='', locals=None, 27 InterpClass=None, 28 startupScript=None, execStartupScript=True, 29 *args, **kwds):
30 """Create LabBench instance.""" 31 wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) 32 self.shell = Shell(parent=self, introText=intro, 33 locals=locals, InterpClass=InterpClass, 34 startupScript=startupScript, 35 execStartupScript=execStartupScript, 36 *args, **kwds) 37 38 self.editor = self.shell 39 if rootObject is None: 40 rootObject = self.shell.interp.locals 41 42 # Maybe one may this could come back ? 43 # self.choicebook = wx.Choicebook(parent=self, id=-1) 44 45 self.apparatus = ApparatusTree(parent=self, 46 rootObject=rootObject, 47 rootLabel=rootLabel, 48 rootIsNamespace=rootIsNamespace) 49 # self.shell.interp.locals['apparatus'] = self.apparatus 50 # self.choicebook.AddPage(page=self.apparatus, text='WorkSpace', select=True) 51 52 # self.logBook = LogBook(parent=self.choicebook) 53 # self.shell.interp.locals['history'] = self.logBook 54 # self.choicebook.AddPage(page=self.logBook, text='History') 55 self.SizeWindows() 56 self.SplitVertically(self.apparatus, self.shell, self.sashoffset) 57 self.SetMinimumPaneSize(200) 58 59 self.Bind(wx.EVT_SIZE, self.SplitterOnSize) 60 self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
61 62
63 - def OnChanged(self, event):
64 """update sash offset from the bottom of the window""" 65 self.sashoffset = self.GetSize().height - event.GetSashPosition() 66 event.Skip()
67 68 69 # Make the splitter expand the top window when resized
70 - def SplitterOnSize(self, event):
71 splitter = event.GetEventObject() 72 sz = splitter.GetSize() 73 # splitter.SetSashPosition(sz.width + self.sashoffset, True) 74 event.Skip()
75
76 - def saveHistory(self):
77 """ 78 Save the command history in a file. 79 """ 80 pass
81