]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/PyCrust/crust.py
45de8b585ad561f8bda474691f91f0385c032a98
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
14 class Crust(wxSplitterWindow
):
15 """PyCrust Crust based on wxSplitterWindow."""
17 name
= 'PyCrust Crust'
18 revision
= __revision__
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
, \
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)
39 # Temporary hack to share menus between PyCrust and PyShell.
40 from shell
import ShellMenu
42 class CrustFrame(wxFrame
, ShellMenu
):
43 """Frame containing all the PyCrust components."""
45 name
= 'PyCrust Frame'
46 revision
= __revision__
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 filename
= os
.path
.join(os
.path
.dirname(__file__
), 'PyCrust.ico')
60 icon
= wxIcon(filename
, wxBITMAP_TYPE_ICO
)
62 self
.crust
= Crust(parent
=self
, intro
=intro
, \
63 rootObject
=rootObject
, \
64 rootLabel
=rootLabel
, \
65 rootIsNamespace
=rootIsNamespace
, \
67 InterpClass
=InterpClass
, *args
, **kwds
)
68 # Override the filling so that status messages go to the status bar.
69 self
.crust
.filling
.fillingTree
.setStatusText
= self
.SetStatusText
70 # Override the shell so that status messages go to the status bar.
71 self
.crust
.shell
.setStatusText
= self
.SetStatusText
72 # Fix a problem with the sash shrinking to nothing.
73 self
.crust
.filling
.SetSashPosition(200)
74 # Set focus to the shell editor.
75 self
.crust
.shell
.SetFocus()
76 # Temporary hack to share menus between PyCrust and PyShell.
77 self
.shell
= self
.crust
.shell
79 EVT_CLOSE(self
, self
.OnCloseWindow
)
81 def OnCloseWindow(self
, event
):
82 self
.crust
.shell
.destroy()