]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/PyCrust/crust.py
23235b2619402b01c8e8f2001d3e2abee9860e4a
1 """PyCrust Crust combines the shell and filling into one control."""
3 __author__
= "Patrick K. O'Brien <pobrien@orbtech.com>"
5 __revision__
= "$Revision$"[11:-2]
7 from wxPython
.wx
import *
8 from shell
import Shell
9 from filling
import Filling
10 from version
import VERSION
13 class Crust(wxSplitterWindow
):
14 """PyCrust Crust based on wxSplitterWindow."""
16 name
= 'PyCrust Crust'
17 revision
= __revision__
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
, \
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)
38 # Temporary hack to share menus between PyCrust and PyShell.
39 from shell
import ShellMenu
41 class CrustFrame(wxFrame
, ShellMenu
):
42 """Frame containing all the PyCrust components."""
44 name
= 'PyCrust Frame'
45 revision
= __revision__
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', ', '))
60 filename
= os
.path
.join(os
.path
.dirname(__file__
), 'PyCrust.ico')
61 icon
= wxIcon(filename
, wxBITMAP_TYPE_ICO
)
64 self
.crust
= Crust(parent
=self
, intro
=intro
, \
65 rootObject
=rootObject
, \
66 rootLabel
=rootLabel
, \
67 rootIsNamespace
=rootIsNamespace
, \
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