1
2
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
15 from mathbench.lab.logbook import LogBook
16 from mathbench.lab.apparatus import ApparatusTree
17
18
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
43
44
45 self.apparatus = ApparatusTree(parent=self,
46 rootObject=rootObject,
47 rootLabel=rootLabel,
48 rootIsNamespace=rootIsNamespace)
49
50
51
52
53
54
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
64 """update sash offset from the bottom of the window"""
65 self.sashoffset = self.GetSize().height - event.GetSashPosition()
66 event.Skip()
67
68
69
71 splitter = event.GetEventObject()
72 sz = splitter.GetSize()
73
74 event.Skip()
75
76 - def saveHistory(self):
77 """
78 Save the command history in a file.
79 """
80 pass
81