]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/PyCrust/crust.py
23235b2619402b01c8e8f2001d3e2abee9860e4a
[wxWidgets.git] / wxPython / wxPython / lib / PyCrust / crust.py
1 """PyCrust Crust combines the shell and filling into one control."""
2
3 __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
4 __cvsid__ = "$Id$"
5 __revision__ = "$Revision$"[11:-2]
6
7 from wxPython.wx import *
8 from shell import Shell
9 from filling import Filling
10 from version import VERSION
11
12
13 class Crust(wxSplitterWindow):
14 """PyCrust Crust based on wxSplitterWindow."""
15
16 name = 'PyCrust Crust'
17 revision = __revision__
18
19 def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
20 size=wxDefaultSize, style=wxSP_3D, name='Crust Window', \
21 rootObject=None, rootLabel=None, rootIsNamespace=1, \
22 intro='', locals=None, \
23 InterpClass=None, *args, **kwds):
24 """Create a PyCrust Crust instance."""
25 wxSplitterWindow.__init__(self, parent, id, pos, size, style, name)
26 self.shell = Shell(parent=self, introText=intro, \
27 locals=locals, InterpClass=InterpClass, \
28 *args, **kwds)
29 self.filling = Filling(parent=self, \
30 rootObject=self.shell.interp.locals, \
31 rootLabel=rootLabel, rootIsNamespace=1)
32 """Add 'filling' to the interpreter's locals."""
33 self.shell.interp.locals['filling'] = self.filling
34 self.SplitHorizontally(self.shell, self.filling, 300)
35 self.SetMinimumPaneSize(1)
36
37
38 # Temporary hack to share menus between PyCrust and PyShell.
39 from shell import ShellMenu
40
41 class CrustFrame(wxFrame, ShellMenu):
42 """Frame containing all the PyCrust components."""
43
44 name = 'PyCrust Frame'
45 revision = __revision__
46
47 def __init__(self, parent=None, id=-1, title='PyCrust', \
48 pos=wxDefaultPosition, size=wxDefaultSize, \
49 style=wxDEFAULT_FRAME_STYLE, \
50 rootObject=None, rootLabel=None, rootIsNamespace=1, \
51 locals=None, InterpClass=None, *args, **kwds):
52 """Create a PyCrust CrustFrame instance."""
53 wxFrame.__init__(self, parent, id, title, pos, size, style)
54 intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % VERSION
55 intro += '\nSponsored by Orbtech - Your source for Python programming expertise.'
56 self.CreateStatusBar()
57 self.SetStatusText(intro.replace('\n', ', '))
58
59 import os
60 filename = os.path.join(os.path.dirname(__file__), 'PyCrust.ico')
61 icon = wxIcon(filename, wxBITMAP_TYPE_ICO)
62 self.SetIcon(icon)
63
64 self.crust = Crust(parent=self, intro=intro, \
65 rootObject=rootObject, \
66 rootLabel=rootLabel, \
67 rootIsNamespace=rootIsNamespace, \
68 locals=locals, \
69 InterpClass=InterpClass, *args, **kwds)
70 # Override the filling so that status messages go to the status bar.
71 self.crust.filling.fillingTree.setStatusText = self.SetStatusText
72 # Override the shell so that status messages go to the status bar.
73 self.crust.shell.setStatusText = self.SetStatusText
74 # Fix a problem with the sash shrinking to nothing.
75 self.crust.filling.SetSashPosition(200)
76 # Set focus to the shell editor.
77 self.crust.shell.SetFocus()
78 # Temporary hack to share menus between PyCrust and PyShell.
79 self.shell = self.crust.shell
80 self.createMenus()
81
82
83