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