Added pretty-print Display tab.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20471 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Patrick K. O'Brien
2003-05-04 16:51:46 +00:00
parent 4ff30320ce
commit 1152dd24a2

View File

@@ -7,9 +7,11 @@ __revision__ = "$Revision$"[11:-2]
import wx import wx
import os import os
import pprint
import sys import sys
import dispatcher import dispatcher
import editwindow
from filling import Filling from filling import Filling
import frame import frame
from shell import Shell from shell import Shell
@@ -50,6 +52,10 @@ class Crust(wx.SplitterWindow):
# Add 'filling' to the interpreter's locals. # Add 'filling' to the interpreter's locals.
self.shell.interp.locals['filling'] = self.filling self.shell.interp.locals['filling'] = self.filling
self.notebook.AddPage(page=self.filling, text='Namespace', select=True) 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.calltip = Calltip(parent=self.notebook) self.calltip = Calltip(parent=self.notebook)
self.notebook.AddPage(page=self.calltip, text='Calltip') self.notebook.AddPage(page=self.calltip, text='Calltip')
self.sessionlisting = SessionListing(parent=self.notebook) self.sessionlisting = SessionListing(parent=self.notebook)
@@ -74,6 +80,39 @@ class Crust(wx.SplitterWindow):
self.SetMinimumPaneSize(1) self.SetMinimumPaneSize(1)
class Display(editwindow.EditWindow):
"""STC used to display an object using Pretty Print."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER,
static=False):
"""Create Display instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
# Configure various defaults and user preferences.
self.SetReadOnly(True)
self.SetWrapMode(False)
if not static:
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
self.Refresh()
def Refresh(self):
if not hasattr(self, "item"):
return
self.SetReadOnly(False)
text = pprint.pformat(self.item)
self.SetText(text)
self.SetReadOnly(True)
def setItem(self, item):
"""Set item to pretty print in the notebook Display tab."""
self.item = item
self.Refresh()
class Calltip(wx.TextCtrl): class Calltip(wx.TextCtrl):
"""Text control containing the most recent shell calltip.""" """Text control containing the most recent shell calltip."""
@@ -174,7 +213,7 @@ class CrustFrame(frame.Frame):
'Shell Revision: %s\n' % self.shell.revision + \ 'Shell Revision: %s\n' % self.shell.revision + \
'Interpreter Revision: %s\n\n' % self.shell.interp.revision + \ 'Interpreter Revision: %s\n\n' % self.shell.interp.revision + \
'Python Version: %s\n' % sys.version.split()[0] + \ 'Python Version: %s\n' % sys.version.split()[0] + \
'wxPython Version: %s\n' % wx.__version__ + \ 'wxPython Version: %s\n' % wx.VERSION_STRING + \
'Platform: %s\n' % sys.platform 'Platform: %s\n' % sys.platform
dialog = wx.MessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)