Merged modifications from the 2.6 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-12-30 23:02:03 +00:00
parent a780a8dc19
commit 02b800ce7c
104 changed files with 14102 additions and 46560 deletions

View File

@@ -8,6 +8,7 @@ import wx
import os
import pprint
import re
import sys
import dispatcher
@@ -23,55 +24,95 @@ class Crust(wx.SplitterWindow):
name = 'Crust'
revision = __revision__
sashoffset = 300
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D,
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D|wx.SP_LIVE_UPDATE,
name='Crust Window', rootObject=None, rootLabel=None,
rootIsNamespace=True, intro='', locals=None,
InterpClass=None, *args, **kwds):
rootIsNamespace=True, intro='', locals=None,
InterpClass=None,
startupScript=None, execStartupScript=True,
*args, **kwds):
"""Create Crust instance."""
wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.shell = Shell(parent=self, introText=intro,
locals=locals, InterpClass=InterpClass,
self.shell = Shell(parent=self, introText=intro,
locals=locals, InterpClass=InterpClass,
startupScript=startupScript,
execStartupScript=execStartupScript,
*args, **kwds)
self.editor = self.shell
if rootObject is None:
rootObject = self.shell.interp.locals
self.notebook = wx.Notebook(parent=self, id=-1)
self.shell.interp.locals['notebook'] = self.notebook
self.filling = Filling(parent=self.notebook,
rootObject=rootObject,
rootLabel=rootLabel,
self.filling = Filling(parent=self.notebook,
rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace)
# Add 'filling' to the interpreter's locals.
self.shell.interp.locals['filling'] = self.filling
self.notebook.AddPage(page=self.filling, text='Namespace', select=True)
self.display = Display(parent=self.notebook)
self.notebook.AddPage(page=self.display, text='Display')
# Add 'pp' (pretty print) to the interpreter's locals.
self.shell.interp.locals['pp'] = self.display.setItem
self.display.nbTab = self.notebook.GetPageCount()-1
self.calltip = Calltip(parent=self.notebook)
self.notebook.AddPage(page=self.calltip, text='Calltip')
self.sessionlisting = SessionListing(parent=self.notebook)
self.notebook.AddPage(page=self.sessionlisting, text='Session')
self.dispatcherlisting = DispatcherListing(parent=self.notebook)
self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher')
## from wxd import wx_
## self.wxdocs = Filling(parent=self.notebook,
## rootObject=wx_,
## rootLabel='wx',
## rootIsNamespace=False,
## static=True)
## self.notebook.AddPage(page=self.wxdocs, text='wxPython Docs')
## from wxd import stc_
## self.stcdocs = Filling(parent=self.notebook,
## rootObject=stc_.StyledTextCtrl,
## rootLabel='StyledTextCtrl',
## rootIsNamespace=False,
## static=True)
## self.notebook.AddPage(page=self.stcdocs, text='StyledTextCtrl Docs')
self.SplitHorizontally(self.shell, self.notebook, 300)
self.SetMinimumPaneSize(1)
self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset)
self.SetMinimumPaneSize(100)
self.Bind(wx.EVT_SIZE, self.SplitterOnSize)
self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
def OnChanged(self, event):
"""update sash offset from the bottom of the window"""
self.sashoffset = self.GetSize().height - event.GetSashPosition()
event.Skip()
# Make the splitter expand the top window when resized
def SplitterOnSize(self, event):
splitter = event.GetEventObject()
sz = splitter.GetSize()
splitter.SetSashPosition(sz.height - self.sashoffset, True)
event.Skip()
def LoadSettings(self, config):
self.shell.LoadSettings(config)
self.filling.LoadSettings(config)
pos = config.ReadInt('Sash/CrustPos', 400)
wx.CallAfter(self.SetSashPosition, pos)
def _updateSashPosValue():
sz = self.GetSize()
self.sashoffset = sz.height - self.GetSashPosition()
wx.CallAfter(_updateSashPosValue)
zoom = config.ReadInt('View/Zoom/Display', -99)
if zoom != -99:
self.display.SetZoom(zoom)
def SaveSettings(self, config):
self.shell.SaveSettings(config)
self.filling.SaveSettings(config)
config.WriteInt('Sash/CrustPos', self.GetSashPosition())
config.WriteInt('View/Zoom/Display', self.display.GetZoom())
class Display(editwindow.EditWindow):
@@ -105,15 +146,20 @@ class Display(editwindow.EditWindow):
"""Set item to pretty print in the notebook Display tab."""
self.item = item
self.Refresh()
if self.GetParent().GetSelection() != self.nbTab:
focus = wx.Window.FindFocus()
self.GetParent().SetSelection(self.nbTab)
wx.CallAfter(focus.SetFocus)
# TODO: Switch this to a editwindow.EditWindow
class Calltip(wx.TextCtrl):
"""Text control containing the most recent shell calltip."""
def __init__(self, parent=None, id=-1):
style = (wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2)
wx.TextCtrl.__init__(self, parent, id, style=style)
self.SetBackgroundColour(wx.Colour(255, 255, 232))
self.SetBackgroundColour(wx.Colour(255, 255, 208))
dispatcher.connect(receiver=self.display, signal='Shell.calltip')
def display(self, calltip):
@@ -123,6 +169,7 @@ class Calltip(wx.TextCtrl):
self.AppendText(calltip)
# TODO: Switch this to a editwindow.EditWindow
class SessionListing(wx.TextCtrl):
"""Text control containing all commands for session."""
@@ -161,44 +208,58 @@ class DispatcherListing(wx.TextCtrl):
self.AppendText(text + '\n')
class CrustFrame(frame.Frame):
class CrustFrame(frame.Frame, frame.ShellFrameMixin):
"""Frame containing all the PyCrust components."""
name = 'CrustFrame'
revision = __revision__
def __init__(self, parent=None, id=-1, title='PyCrust',
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=True,
locals=None, InterpClass=None, *args, **kwds):
locals=None, InterpClass=None,
config=None, dataDir=None,
*args, **kwds):
"""Create CrustFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style)
frame.ShellFrameMixin.__init__(self, config, dataDir)
if size == wx.DefaultSize:
self.SetSize((800, 600))
intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION
intro += '\nSponsored by Orbtech - '
intro += 'Your source for Python programming expertise.'
self.SetStatusText(intro.replace('\n', ', '))
self.crust = Crust(parent=self, intro=intro,
rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace,
locals=locals,
InterpClass=InterpClass, *args, **kwds)
InterpClass=InterpClass,
startupScript=self.startupScript,
execStartupScript=self.execStartupScript,
*args, **kwds)
self.shell = self.crust.shell
# Override the filling so that status messages go to the status bar.
self.crust.filling.tree.setStatusText = self.SetStatusText
# Override the shell so that status messages go to the status bar.
self.shell.setStatusText = self.SetStatusText
# Fix a problem with the sash shrinking to nothing.
self.crust.filling.SetSashPosition(200)
# Set focus to the shell editor.
self.shell.SetFocus()
self.LoadSettings()
def OnClose(self, event):
"""Event handler for closing."""
self.SaveSettings()
self.crust.shell.destroy()
self.Destroy()
def OnAbout(self, event):
"""Display an About window."""
title = 'About PyCrust'
@@ -211,8 +272,33 @@ class CrustFrame(frame.Frame):
'Platform: %s\n' % sys.platform + \
'Python Version: %s\n' % sys.version.split()[0] + \
'wxPython Version: %s\n' % wx.VERSION_STRING + \
('\t(%s)\n' % ", ".join(wx.PlatformInfo[1:]))
('\t(%s)\n' % ", ".join(wx.PlatformInfo[1:]))
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def LoadSettings(self):
if self.config is not None:
frame.ShellFrameMixin.LoadSettings(self)
frame.Frame.LoadSettings(self, self.config)
self.crust.LoadSettings(self.config)
def SaveSettings(self):
if self.config is not None:
frame.ShellFrameMixin.SaveSettings(self)
if self.autoSaveSettings:
frame.Frame.SaveSettings(self, self.config)
self.crust.SaveSettings(self.config)
def DoSaveSettings(self):
if self.config is not None:
self.SaveSettings()
self.config.Flush()