import wx

Changed some strings to refer to "Py" rather than "PyCrust".


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Patrick K. O'Brien
2003-05-03 16:01:41 +00:00
parent f9940dab60
commit 35825a5dcc
15 changed files with 316 additions and 307 deletions

View File

@@ -2,7 +2,7 @@
0.9.2 (5/3/2003 to //2003) 0.9.2 (5/3/2003 to //2003)
----------------------------- -----------------------------
Changed to new "wx" package:: Changed to the new prefix-less "wx" package::
import wx import wx
@@ -10,6 +10,15 @@ instead of::
from wxPython import wx from wxPython import wx
Fixed typo in ``PyWrap.py``::
if __name__ == '__main__':
main(sys.argv)
should have been::
if __name__ == '__main__':
main()
0.9.1 (3/21/2003 to 5/2/2003) 0.9.1 (3/21/2003 to 5/2/2003)

View File

@@ -4,7 +4,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
import os import os
import sys import sys
@@ -17,15 +17,15 @@ except NameError:
True = 1==1 True = 1==1
False = 1==0 False = 1==0
class App(wx.wxApp): class App(wx.App):
"""PyAlaCarte standalone application.""" """PyAlaCarte standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.wxApp.__init__(self, redirect=False) wx.App.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
self.frame = editor.EditorFrame(filename=self.filename) self.frame = editor.EditorFrame(filename=self.filename)
self.frame.Show() self.frame.Show()
self.SetTopWindow(self.frame) self.SetTopWindow(self.frame)

View File

@@ -4,7 +4,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
import os import os
import sys import sys
@@ -17,15 +17,15 @@ except NameError:
True = 1==1 True = 1==1
False = 1==0 False = 1==0
class App(wx.wxApp): class App(wx.App):
"""PyAlaMode standalone application.""" """PyAlaMode standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.wxApp.__init__(self, redirect=False) wx.App.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
self.frame = editor.EditorNotebookFrame(filename=self.filename) self.frame = editor.EditorNotebookFrame(filename=self.filename)
self.frame.Show() self.frame.Show()
self.SetTopWindow(self.frame) self.SetTopWindow(self.frame)

View File

@@ -4,7 +4,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
import os import os
import sys import sys
@@ -17,15 +17,15 @@ except NameError:
True = 1==1 True = 1==1
False = 1==0 False = 1==0
class App(wx.wxApp): class App(wx.App):
"""PyAlaModeTest standalone application.""" """PyAlaModeTest standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.wxApp.__init__(self, redirect=False) wx.App.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
self.frame = editor.EditorShellNotebookFrame(filename=self.filename) self.frame = editor.EditorShellNotebookFrame(filename=self.filename)
self.frame.Show() self.frame.Show()
self.SetTopWindow(self.frame) self.SetTopWindow(self.frame)

View File

@@ -11,7 +11,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
try: try:
True True
@@ -20,12 +20,12 @@ except NameError:
False = 1==0 False = 1==0
class App(wx.wxApp): class App(wx.App):
"""PyCrust standalone application.""" """PyCrust standalone application."""
def OnInit(self): def OnInit(self):
from wxPython import wx import wx
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
locals = __main__.__dict__ locals = __main__.__dict__
from crust import CrustFrame from crust import CrustFrame
self.frame = CrustFrame(locals=locals) self.frame = CrustFrame(locals=locals)

View File

@@ -15,9 +15,8 @@ import interpreter
import introspect import introspect
import pseudo import pseudo
import shell import shell
import sys import sys
from wxPython import wx import wx
try: try:
True True

View File

@@ -11,7 +11,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
try: try:
True True
@@ -20,12 +20,12 @@ except NameError:
False = 1==0 False = 1==0
class App(wx.wxApp): class App(wx.App):
"""PyShell standalone application.""" """PyShell standalone application."""
def OnInit(self): def OnInit(self):
from wxPython import wx import wx
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
locals = __main__.__dict__ locals = __main__.__dict__
from shell import ShellFrame from shell import ShellFrame
self.frame = ShellFrame(locals=locals) self.frame = ShellFrame(locals=locals)

View File

@@ -7,7 +7,7 @@ __revision__ = "$Revision$"[11:-2]
import os import os
import sys import sys
from wxPython import wx import wx
from crust import CrustFrame as Frame from crust import CrustFrame as Frame
try: try:
@@ -18,7 +18,7 @@ except NameError:
def wrap(app): def wrap(app):
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
frame = Frame() frame = Frame()
frame.SetSize((750, 525)) frame.SetSize((750, 525))
frame.Show(True) frame.Show(True)
@@ -41,7 +41,7 @@ def main(modulename=None):
d = module.__dict__ d = module.__dict__
for item in d.keys(): for item in d.keys():
try: try:
if issubclass(d[item], wx.wxApp): if issubclass(d[item], wx.App):
App = d[item] App = d[item]
except (NameError, TypeError): except (NameError, TypeError):
pass pass
@@ -53,4 +53,4 @@ def main(modulename=None):
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv) main()

View File

@@ -1,10 +1,10 @@
"""PyCrust Crust combines the shell and filling into one control.""" """Crust combines the shell and filling into one control."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
import os import os
import sys import sys
@@ -22,26 +22,26 @@ except NameError:
False = 1==0 False = 1==0
class Crust(wx.wxSplitterWindow): class Crust(wx.SplitterWindow):
"""PyCrust Crust based on wxSplitterWindow.""" """Crust based on SplitterWindow."""
name = 'PyCrust Crust' name = 'Crust'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxSP_3D, size=wx.DefaultSize, style=wx.SP_3D,
name='Crust Window', rootObject=None, rootLabel=None, name='Crust Window', rootObject=None, rootLabel=None,
rootIsNamespace=True, intro='', locals=None, rootIsNamespace=True, intro='', locals=None,
InterpClass=None, *args, **kwds): InterpClass=None, *args, **kwds):
"""Create a PyCrust Crust instance.""" """Create Crust instance."""
wx.wxSplitterWindow.__init__(self, parent, id, pos, size, style, name) wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.shell = Shell(parent=self, introText=intro, self.shell = Shell(parent=self, introText=intro,
locals=locals, InterpClass=InterpClass, locals=locals, InterpClass=InterpClass,
*args, **kwds) *args, **kwds)
self.editor = self.shell self.editor = self.shell
if rootObject is None: if rootObject is None:
rootObject = self.shell.interp.locals rootObject = self.shell.interp.locals
self.notebook = wx.wxNotebook(parent=self, id=-1) self.notebook = wx.Notebook(parent=self, id=-1)
self.shell.interp.locals['notebook'] = self.notebook self.shell.interp.locals['notebook'] = self.notebook
self.filling = Filling(parent=self.notebook, self.filling = Filling(parent=self.notebook,
rootObject=rootObject, rootObject=rootObject,
@@ -74,13 +74,13 @@ class Crust(wx.wxSplitterWindow):
self.SetMinimumPaneSize(1) self.SetMinimumPaneSize(1)
class Calltip(wx.wxTextCtrl): class Calltip(wx.TextCtrl):
"""Text control containing the most recent shell calltip.""" """Text control containing the most recent shell calltip."""
def __init__(self, parent=None, id=-1): def __init__(self, parent=None, id=-1):
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | wx.wxTE_RICH2 style = wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style) wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.wxColour(255, 255, 232)) self.SetBackgroundColour(wx.Colour(255, 255, 232))
dispatcher.connect(receiver=self.display, signal='Shell.calltip') dispatcher.connect(receiver=self.display, signal='Shell.calltip')
def display(self, calltip): def display(self, calltip):
@@ -88,13 +88,13 @@ class Calltip(wx.wxTextCtrl):
self.SetValue(calltip) self.SetValue(calltip)
class SessionListing(wx.wxTextCtrl): class SessionListing(wx.TextCtrl):
"""Text control containing all commands for session.""" """Text control containing all commands for session."""
def __init__(self, parent=None, id=-1): def __init__(self, parent=None, id=-1):
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \ style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.wxTE_RICH2 | wx.wxTE_DONTWRAP wx.TE_RICH2 | wx.TE_DONTWRAP
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style) wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.push, signal='Interpreter.push') dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more): def push(self, command, more):
@@ -107,13 +107,13 @@ class SessionListing(wx.wxTextCtrl):
self.AppendText(command + '\n') self.AppendText(command + '\n')
class DispatcherListing(wx.wxTextCtrl): class DispatcherListing(wx.TextCtrl):
"""Text control containing all dispatches for session.""" """Text control containing all dispatches for session."""
def __init__(self, parent=None, id=-1): def __init__(self, parent=None, id=-1):
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \ style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.wxTE_RICH2 | wx.wxTE_DONTWRAP wx.TE_RICH2 | wx.TE_DONTWRAP
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style) wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.spy) dispatcher.connect(receiver=self.spy)
def spy(self, signal, sender): def spy(self, signal, sender):
@@ -129,15 +129,15 @@ class DispatcherListing(wx.wxTextCtrl):
class CrustFrame(frame.Frame): class CrustFrame(frame.Frame):
"""Frame containing all the PyCrust components.""" """Frame containing all the PyCrust components."""
name = 'PyCrust Frame' name = 'CrustFrame'
revision = __revision__ revision = __revision__
def __init__(self, parent=None, id=-1, title='PyCrust', def __init__(self, parent=None, id=-1, title='PyCrust',
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.wxDEFAULT_FRAME_STYLE, style=wx.DEFAULT_FRAME_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=True, rootObject=None, rootLabel=None, rootIsNamespace=True,
locals=None, InterpClass=None, *args, **kwds): locals=None, InterpClass=None, *args, **kwds):
"""Create a PyCrust CrustFrame instance.""" """Create CrustFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style) frame.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION
intro += '\nSponsored by Orbtech - ' intro += '\nSponsored by Orbtech - '
@@ -176,7 +176,7 @@ class CrustFrame(frame.Frame):
'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__ + \
'Platform: %s\n' % sys.platform 'Platform: %s\n' % sys.platform
dialog = wx.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()

View File

@@ -4,7 +4,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
from buffer import Buffer from buffer import Buffer
import crust import crust
@@ -25,8 +25,8 @@ class EditorFrame(frame.Frame):
"""Frame containing one editor.""" """Frame containing one editor."""
def __init__(self, parent=None, id=-1, title='PyAlaCarte', def __init__(self, parent=None, id=-1, title='PyAlaCarte',
pos=wx.wxDefaultPosition, size=(800, 600), pos=wx.DefaultPosition, size=(800, 600),
style=wx.wxDEFAULT_FRAME_STYLE, filename=None): style=wx.DEFAULT_FRAME_STYLE, filename=None):
"""Create EditorFrame instance.""" """Create EditorFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style) frame.Frame.__init__(self, parent, id, title, pos, size, style)
self.buffers = {} self.buffers = {}
@@ -55,8 +55,8 @@ class EditorFrame(frame.Frame):
"""Display an About window.""" """Display an About window."""
title = 'About PyAlaCarte' title = 'About PyAlaCarte'
text = 'Another fine, flaky program.' text = 'Another fine, flaky program.'
dialog = wx.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -141,11 +141,11 @@ class EditorFrame(frame.Frame):
"""Create new buffer.""" """Create new buffer."""
self.bufferDestroy() self.bufferDestroy()
buffer = Buffer() buffer = Buffer()
self.panel = panel = wx.wxPanel(parent=self, id=-1) self.panel = panel = wx.Panel(parent=self, id=-1)
editor = Editor(parent=panel) editor = Editor(parent=panel)
panel.editor = editor panel.editor = editor
sizer = wx.wxBoxSizer(wx.wxVERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(editor.window, 1, wx.wxEXPAND) sizer.Add(editor.window, 1, wx.EXPAND)
panel.SetSizer(sizer) panel.SetSizer(sizer)
panel.SetAutoLayout(True) panel.SetAutoLayout(True)
sizer.Layout() sizer.Layout()
@@ -255,8 +255,8 @@ class EditorNotebookFrame(EditorFrame):
"""Frame containing one or more editors in a notebook.""" """Frame containing one or more editors in a notebook."""
def __init__(self, parent=None, id=-1, title='PyAlaMode', def __init__(self, parent=None, id=-1, title='PyAlaMode',
pos=wx.wxDefaultPosition, size=(800, 600), pos=wx.DefaultPosition, size=(800, 600),
style=wx.wxDEFAULT_FRAME_STYLE, filename=None): style=wx.DEFAULT_FRAME_STYLE, filename=None):
"""Create EditorNotebookFrame instance.""" """Create EditorNotebookFrame instance."""
self.notebook = None self.notebook = None
EditorFrame.__init__(self, parent, id, title, pos, EditorFrame.__init__(self, parent, id, title, pos,
@@ -270,7 +270,7 @@ class EditorNotebookFrame(EditorFrame):
Called automatically by base class during init.""" Called automatically by base class during init."""
self.notebook = EditorNotebook(parent=self) self.notebook = EditorNotebook(parent=self)
intro = 'PyCrust %s' % version.VERSION intro = 'Py %s' % version.VERSION
import imp import imp
module = imp.new_module('__main__') module = imp.new_module('__main__')
import __builtin__ import __builtin__
@@ -284,7 +284,7 @@ class EditorNotebookFrame(EditorFrame):
self.shell.setStatusText = self.SetStatusText self.shell.setStatusText = self.SetStatusText
# Fix a problem with the sash shrinking to nothing. # Fix a problem with the sash shrinking to nothing.
self.crust.filling.SetSashPosition(200) self.crust.filling.SetSashPosition(200)
self.notebook.AddPage(page=self.crust, text='PyCrust', select=True) self.notebook.AddPage(page=self.crust, text='*Shell*', select=True)
self.setEditor(self.crust.editor) self.setEditor(self.crust.editor)
self.crust.editor.SetFocus() self.crust.editor.SetFocus()
@@ -296,8 +296,8 @@ class EditorNotebookFrame(EditorFrame):
"""Display an About window.""" """Display an About window."""
title = 'About PyAlaMode' title = 'About PyAlaMode'
text = 'Another fine, flaky program.' text = 'Another fine, flaky program.'
dialog = wx.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -317,11 +317,11 @@ class EditorNotebookFrame(EditorFrame):
def bufferCreate(self, filename=None): def bufferCreate(self, filename=None):
"""Create new buffer.""" """Create new buffer."""
buffer = Buffer() buffer = Buffer()
panel = wx.wxPanel(parent=self.notebook, id=-1) panel = wx.Panel(parent=self.notebook, id=-1)
editor = Editor(parent=panel) editor = Editor(parent=panel)
panel.editor = editor panel.editor = editor
sizer = wx.wxBoxSizer(wx.wxVERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(editor.window, 1, wx.wxEXPAND) sizer.Add(editor.window, 1, wx.EXPAND)
panel.SetSizer(sizer) panel.SetSizer(sizer)
panel.SetAutoLayout(True) panel.SetAutoLayout(True)
sizer.Layout() sizer.Layout()
@@ -359,12 +359,12 @@ class EditorNotebookFrame(EditorFrame):
return cancel return cancel
class EditorNotebook(wx.wxNotebook): class EditorNotebook(wx.Notebook):
"""A notebook containing a page for each editor.""" """A notebook containing a page for each editor."""
def __init__(self, parent): def __init__(self, parent):
"""Create EditorNotebook instance.""" """Create EditorNotebook instance."""
wx.wxNotebook.__init__(self, parent, id=-1) wx.Notebook.__init__(self, parent, id=-1)
wx.EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), wx.EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(),
self.OnPageChanging) self.OnPageChanging)
wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(),
@@ -430,8 +430,8 @@ class EditorShellNotebookFrame(EditorNotebookFrame):
"""Frame containing a notebook containing EditorShellNotebooks.""" """Frame containing a notebook containing EditorShellNotebooks."""
def __init__(self, parent=None, id=-1, title='PyAlaModeTest', def __init__(self, parent=None, id=-1, title='PyAlaModeTest',
pos=wx.wxDefaultPosition, size=(600, 400), pos=wx.DefaultPosition, size=(600, 400),
style=wx.wxDEFAULT_FRAME_STYLE, style=wx.DEFAULT_FRAME_STYLE,
filename=None, singlefile=False): filename=None, singlefile=False):
"""Create EditorShellNotebookFrame instance.""" """Create EditorShellNotebookFrame instance."""
self._singlefile = singlefile self._singlefile = singlefile
@@ -449,8 +449,8 @@ class EditorShellNotebookFrame(EditorNotebookFrame):
"""Display an About window.""" """Display an About window."""
title = 'About PyAlaModePlus' title = 'About PyAlaModePlus'
text = 'Another fine, flaky program.' text = 'Another fine, flaky program.'
dialog = wx.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -515,16 +515,16 @@ class EditorShellNotebookFrame(EditorNotebookFrame):
return cancel return cancel
class EditorShellNotebook(wx.wxNotebook): class EditorShellNotebook(wx.Notebook):
"""A notebook containing an editor page and a shell page.""" """A notebook containing an editor page and a shell page."""
def __init__(self, parent, filename=None): def __init__(self, parent, filename=None):
"""Create EditorShellNotebook instance.""" """Create EditorShellNotebook instance."""
wx.wxNotebook.__init__(self, parent, id=-1) wx.Notebook.__init__(self, parent, id=-1)
usePanels = True usePanels = True
if usePanels: if usePanels:
editorparent = editorpanel = wx.wxPanel(self, -1) editorparent = editorpanel = wx.Panel(self, -1)
shellparent = shellpanel = wx.wxPanel(self, -1) shellparent = shellpanel = wx.Panel(self, -1)
else: else:
editorparent = self editorparent = self
shellparent = self shellparent = self
@@ -533,18 +533,18 @@ class EditorShellNotebook(wx.wxNotebook):
self.buffer.addEditor(self.editor) self.buffer.addEditor(self.editor)
self.buffer.open(filename) self.buffer.open(filename)
self.shell = Shell(parent=shellparent, locals=self.buffer.interp.locals, self.shell = Shell(parent=shellparent, locals=self.buffer.interp.locals,
style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_BORDER) style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)
self.buffer.interp.locals.clear() self.buffer.interp.locals.clear()
if usePanels: if usePanels:
self.AddPage(page=editorpanel, text='Editor', select=True) self.AddPage(page=editorpanel, text='Editor', select=True)
self.AddPage(page=shellpanel, text='Shell') self.AddPage(page=shellpanel, text='Shell')
# Setup sizers # Setup sizers
editorsizer = wx.wxBoxSizer(wx.wxVERTICAL) editorsizer = wx.BoxSizer(wx.VERTICAL)
editorsizer.Add(self.editor.window, 1, wx.wxEXPAND) editorsizer.Add(self.editor.window, 1, wx.EXPAND)
editorpanel.SetSizer(editorsizer) editorpanel.SetSizer(editorsizer)
editorpanel.SetAutoLayout(True) editorpanel.SetAutoLayout(True)
shellsizer = wx.wxBoxSizer(wx.wxVERTICAL) shellsizer = wx.BoxSizer(wx.VERTICAL)
shellsizer.Add(self.shell, 1, wx.wxEXPAND) shellsizer.Add(self.shell, 1, wx.EXPAND)
shellpanel.SetSizer(shellsizer) shellpanel.SetSizer(shellsizer)
shellpanel.SetAutoLayout(True) shellpanel.SetAutoLayout(True)
else: else:
@@ -563,7 +563,7 @@ class EditorShellNotebook(wx.wxNotebook):
event.Skip() event.Skip()
def SetFocus(self): def SetFocus(self):
wx.wxNotebook.SetFocus(self) wx.Notebook.SetFocus(self)
selection = self.GetSelection() selection = self.GetSelection()
if selection == 0: if selection == 0:
self.editor.setFocus() self.editor.setFocus()
@@ -574,9 +574,9 @@ class EditorShellNotebook(wx.wxNotebook):
class Editor: class Editor:
"""Editor having an EditWindow.""" """Editor having an EditWindow."""
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, size=wx.DefaultSize,
style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_BORDER): style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create Editor instance.""" """Create Editor instance."""
self.window = EditWindow(self, parent, id, pos, size, style) self.window = EditWindow(self, parent, id, pos, size, style)
self.id = self.window.GetId() self.id = self.window.GetId()
@@ -732,9 +732,9 @@ class Editor:
class EditWindow(editwindow.EditWindow): class EditWindow(editwindow.EditWindow):
"""EditWindow based on StyledTextCtrl.""" """EditWindow based on StyledTextCtrl."""
def __init__(self, editor, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, editor, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, size=wx.DefaultSize,
style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_BORDER): style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create EditWindow instance.""" """Create EditWindow instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style) editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
self.editor = editor self.editor = editor
@@ -746,7 +746,7 @@ class DialogResults:
def __init__(self, returned): def __init__(self, returned):
"""Create wrapper for results returned by dialog.""" """Create wrapper for results returned by dialog."""
self.returned = returned self.returned = returned
self.positive = returned in (wx.wxID_OK, wx.wxID_YES) self.positive = returned in (wx.ID_OK, wx.ID_YES)
self.text = self._asString() self.text = self._asString()
@@ -755,22 +755,22 @@ class DialogResults:
def _asString(self): def _asString(self):
returned = self.returned returned = self.returned
if returned == wx.wxID_OK: if returned == wx.ID_OK:
return "Ok" return "Ok"
elif returned == wx.wxID_CANCEL: elif returned == wx.ID_CANCEL:
return "Cancel" return "Cancel"
elif returned == wx.wxID_YES: elif returned == wx.ID_YES:
return "Yes" return "Yes"
elif returned == wx.wxID_NO: elif returned == wx.ID_NO:
return "No" return "No"
def fileDialog(parent=None, title='Open', directory='', filename='', def fileDialog(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*', wildcard='All Files (*.*)|*.*',
style=wx.wxOPEN | wx.wxMULTIPLE): style=wx.OPEN | wx.MULTIPLE):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.wxFileDialog(parent, title, directory, filename, dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style) wildcard, style)
result = DialogResults(dialog.ShowModal()) result = DialogResults(dialog.ShowModal())
if result.positive: if result.positive:
result.paths = dialog.GetPaths() result.paths = dialog.GetPaths()
@@ -781,10 +781,10 @@ def fileDialog(parent=None, title='Open', directory='', filename='',
def openSingle(parent=None, title='Open', directory='', filename='', def openSingle(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*', style=wx.wxOPEN): wildcard='All Files (*.*)|*.*', style=wx.OPEN):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.wxFileDialog(parent, title, directory, filename, dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style) wildcard, style)
result = DialogResults(dialog.ShowModal()) result = DialogResults(dialog.ShowModal())
if result.positive: if result.positive:
result.path = dialog.GetPath() result.path = dialog.GetPath()
@@ -796,17 +796,17 @@ def openSingle(parent=None, title='Open', directory='', filename='',
def openMultiple(parent=None, title='Open', directory='', filename='', def openMultiple(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*', wildcard='All Files (*.*)|*.*',
style=wx.wxOPEN | wx.wxMULTIPLE): style=wx.OPEN | wx.MULTIPLE):
"""File dialog wrapper function.""" """File dialog wrapper function."""
return fileDialog(parent, title, directory, filename, wildcard, style) return fileDialog(parent, title, directory, filename, wildcard, style)
def saveSingle(parent=None, title='Save', directory='', filename='', def saveSingle(parent=None, title='Save', directory='', filename='',
wildcard='All Files (*.*)|*.*', wildcard='All Files (*.*)|*.*',
style=wx.wxSAVE | wx.wxHIDE_READONLY | wx.wxOVERWRITE_PROMPT): style=wx.SAVE | wx.HIDE_READONLY | wx.OVERWRITE_PROMPT):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.wxFileDialog(parent, title, directory, filename, dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style) wildcard, style)
result = DialogResults(dialog.ShowModal()) result = DialogResults(dialog.ShowModal())
if result.positive: if result.positive:
result.path = dialog.GetPath() result.path = dialog.GetPath()
@@ -817,9 +817,9 @@ def saveSingle(parent=None, title='Save', directory='', filename='',
def directory(parent=None, message='Choose a directory', path='', style=0, def directory(parent=None, message='Choose a directory', path='', style=0,
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize): pos=wx.DefaultPosition, size=wx.DefaultSize):
"""Dir dialog wrapper function.""" """Dir dialog wrapper function."""
dialog = wx.wxDirDialog(parent, message, path, style, pos, size) dialog = wx.DirDialog(parent, message, path, style, pos, size)
result = DialogResults(dialog.ShowModal()) result = DialogResults(dialog.ShowModal())
if result.positive: if result.positive:
result.path = dialog.GetPath() result.path = dialog.GetPath()
@@ -830,10 +830,10 @@ def directory(parent=None, message='Choose a directory', path='', style=0,
def messageDialog(parent=None, message='', title='Message box', def messageDialog(parent=None, message='', title='Message box',
style=wx.wxYES_NO | wx.wxCANCEL | wx.wxCENTRE | wx.wxICON_QUESTION, style=wx.YES_NO | wx.CANCEL | wx.CENTRE | wx.ICON_QUESTION,
pos=wx.wxDefaultPosition): pos=wx.DefaultPosition):
"""Message dialog wrapper function.""" """Message dialog wrapper function."""
dialog = wx.wxMessageDialog(parent, message, title, style, pos) dialog = wx.MessageDialog(parent, message, title, style, pos)
result = DialogResults(dialog.ShowModal()) result = DialogResults(dialog.ShowModal())
dialog.Destroy() dialog.Destroy()
return result return result

View File

@@ -4,8 +4,8 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
from wxPython import stc from wx import stc
import keyword import keyword
import os import os
@@ -21,7 +21,7 @@ except NameError:
True = 1==1 True = 1==1
False = 1==0 False = 1==0
if wx.wxPlatform == '__WXMSW__': if wx.Platform == '__WXMSW__':
FACES = { 'times' : 'Times New Roman', FACES = { 'times' : 'Times New Roman',
'mono' : 'Courier New', 'mono' : 'Courier New',
'helv' : 'Lucida Console', 'helv' : 'Lucida Console',
@@ -42,15 +42,15 @@ else: # GTK
} }
class EditWindow(stc.wxStyledTextCtrl): class EditWindow(stc.StyledTextCtrl):
"""EditWindow based on StyledTextCtrl.""" """EditWindow based on StyledTextCtrl."""
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_BORDER): size=wx.DefaultSize, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create EditWindow instance.""" """Create EditWindow instance."""
stc.wxStyledTextCtrl.__init__(self, parent, id, pos, size, style) stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style)
self.__config() self.__config()
stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI) stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease') dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease')
@@ -70,10 +70,10 @@ class EditWindow(stc.wxStyledTextCtrl):
def __config(self): def __config(self):
"""Configure shell based on user preferences.""" """Configure shell based on user preferences."""
self.SetMarginType(1, stc.wxSTC_MARGIN_NUMBER) self.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.SetMarginWidth(1, 40) self.SetMarginWidth(1, 40)
self.SetLexer(stc.wxSTC_LEX_PYTHON) self.SetLexer(stc.STC_LEX_PYTHON)
self.SetKeyWords(0, ' '.join(keyword.kwlist)) self.SetKeyWords(0, ' '.join(keyword.kwlist))
self.setStyles(FACES) self.setStyles(FACES)
@@ -91,7 +91,7 @@ class EditWindow(stc.wxStyledTextCtrl):
self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`') self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`')
# Do we want to automatically pop up command argument help? # Do we want to automatically pop up command argument help?
self.autoCallTip = True self.autoCallTip = True
self.CallTipSetBackground(wx.wxColour(255, 255, 232)) self.CallTipSetBackground(wx.Colour(255, 255, 232))
self.SetWrapMode(False) self.SetWrapMode(False)
try: try:
self.SetEndAtLastLine(False) self.SetEndAtLastLine(False)
@@ -102,50 +102,50 @@ class EditWindow(stc.wxStyledTextCtrl):
"""Configure font size, typeface and color for lexer.""" """Configure font size, typeface and color for lexer."""
# Default style # Default style
self.StyleSetSpec(stc.wxSTC_STYLE_DEFAULT, self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(mono)s,size:%(size)d,back:%(backcol)s" % \ "face:%(mono)s,size:%(size)d,back:%(backcol)s" % \
faces) faces)
self.StyleClearAll() self.StyleClearAll()
# Built in styles # Built in styles
self.StyleSetSpec(stc.wxSTC_STYLE_LINENUMBER, self.StyleSetSpec(stc.STC_STYLE_LINENUMBER,
"back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces) "back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces)
self.StyleSetSpec(stc.wxSTC_STYLE_CONTROLCHAR, self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR,
"face:%(mono)s" % faces) "face:%(mono)s" % faces)
self.StyleSetSpec(stc.wxSTC_STYLE_BRACELIGHT, self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,
"fore:#0000FF,back:#FFFF88") "fore:#0000FF,back:#FFFF88")
self.StyleSetSpec(stc.wxSTC_STYLE_BRACEBAD, self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,
"fore:#FF0000,back:#FFFF88") "fore:#FF0000,back:#FFFF88")
# Python styles # Python styles
self.StyleSetSpec(stc.wxSTC_P_DEFAULT, self.StyleSetSpec(stc.STC_P_DEFAULT,
"face:%(mono)s" % faces) "face:%(mono)s" % faces)
self.StyleSetSpec(stc.wxSTC_P_COMMENTLINE, self.StyleSetSpec(stc.STC_P_COMMENTLINE,
"fore:#007F00,face:%(mono)s" % faces) "fore:#007F00,face:%(mono)s" % faces)
self.StyleSetSpec(stc.wxSTC_P_NUMBER, self.StyleSetSpec(stc.STC_P_NUMBER,
"") "")
self.StyleSetSpec(stc.wxSTC_P_STRING, self.StyleSetSpec(stc.STC_P_STRING,
"fore:#7F007F,face:%(mono)s" % faces) "fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.wxSTC_P_CHARACTER, self.StyleSetSpec(stc.STC_P_CHARACTER,
"fore:#7F007F,face:%(mono)s" % faces) "fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.wxSTC_P_WORD, self.StyleSetSpec(stc.STC_P_WORD,
"fore:#00007F,bold") "fore:#00007F,bold")
self.StyleSetSpec(stc.wxSTC_P_TRIPLE, self.StyleSetSpec(stc.STC_P_TRIPLE,
"fore:#7F0000") "fore:#7F0000")
self.StyleSetSpec(stc.wxSTC_P_TRIPLEDOUBLE, self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE,
"fore:#000033,back:#FFFFE8") "fore:#000033,back:#FFFFE8")
self.StyleSetSpec(stc.wxSTC_P_CLASSNAME, self.StyleSetSpec(stc.STC_P_CLASSNAME,
"fore:#0000FF,bold") "fore:#0000FF,bold")
self.StyleSetSpec(stc.wxSTC_P_DEFNAME, self.StyleSetSpec(stc.STC_P_DEFNAME,
"fore:#007F7F,bold") "fore:#007F7F,bold")
self.StyleSetSpec(stc.wxSTC_P_OPERATOR, self.StyleSetSpec(stc.STC_P_OPERATOR,
"") "")
self.StyleSetSpec(stc.wxSTC_P_IDENTIFIER, self.StyleSetSpec(stc.STC_P_IDENTIFIER,
"") "")
self.StyleSetSpec(stc.wxSTC_P_COMMENTBLOCK, self.StyleSetSpec(stc.STC_P_COMMENTBLOCK,
"fore:#7F7F7F") "fore:#7F7F7F")
self.StyleSetSpec(stc.wxSTC_P_STRINGEOL, self.StyleSetSpec(stc.STC_P_STRINGEOL,
"fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces) "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces)
def OnUpdateUI(self, event): def OnUpdateUI(self, event):
@@ -163,7 +163,7 @@ class EditWindow(stc.wxStyledTextCtrl):
# Check before. # Check before.
if charBefore and chr(charBefore) in '[]{}()' \ if charBefore and chr(charBefore) in '[]{}()' \
and styleBefore == stc.wxSTC_P_OPERATOR: and styleBefore == stc.STC_P_OPERATOR:
braceAtCaret = caretPos - 1 braceAtCaret = caretPos - 1
# Check after. # Check after.
@@ -171,7 +171,7 @@ class EditWindow(stc.wxStyledTextCtrl):
charAfter = self.GetCharAt(caretPos) charAfter = self.GetCharAt(caretPos)
styleAfter = self.GetStyleAt(caretPos) styleAfter = self.GetStyleAt(caretPos)
if charAfter and chr(charAfter) in '[]{}()' \ if charAfter and chr(charAfter) in '[]{}()' \
and styleAfter == stc.wxSTC_P_OPERATOR: and styleAfter == stc.STC_P_OPERATOR:
braceAtCaret = caretPos braceAtCaret = caretPos
if braceAtCaret >= 0: if braceAtCaret >= 0:

View File

@@ -1,11 +1,11 @@
"""PyCrust Filling is the gui tree control through which a user can """Filling is the gui tree control through which a user can navigate
navigate the local namespace or any object.""" the local namespace or any object."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
import dispatcher import dispatcher
import editwindow import editwindow
@@ -40,18 +40,18 @@ except AttributeError:
pass pass
class FillingTree(wx.wxTreeCtrl): class FillingTree(wx.TreeCtrl):
"""PyCrust FillingTree based on wxTreeCtrl.""" """FillingTree based on TreeCtrl."""
name = 'PyCrust Filling Tree' name = 'Filling Tree'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxTR_DEFAULT_STYLE, size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=False, rootObject=None, rootLabel=None, rootIsNamespace=False,
static=False): static=False):
"""Create a PyCrust FillingTree instance.""" """Create FillingTree instance."""
wx.wxTreeCtrl.__init__(self, parent, id, pos, size, style) wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
self.rootIsNamespace = rootIsNamespace self.rootIsNamespace = rootIsNamespace
import __main__ import __main__
if rootObject is None: if rootObject is None:
@@ -61,7 +61,7 @@ class FillingTree(wx.wxTreeCtrl):
rootLabel = 'locals()' rootLabel = 'locals()'
if not rootLabel: if not rootLabel:
rootLabel = 'Ingredients' rootLabel = 'Ingredients'
rootData = wx.wxTreeItemData(rootObject) rootData = wx.TreeItemData(rootObject)
self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData) self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData)
self.SetItemHasChildren(self.root, self.objHasChildren(rootObject)) self.SetItemHasChildren(self.root, self.objHasChildren(rootObject))
wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding) wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
@@ -77,7 +77,7 @@ class FillingTree(wx.wxTreeCtrl):
def OnItemExpanding(self, event): def OnItemExpanding(self, event):
"""Add children to the item.""" """Add children to the item."""
busy = wx.wxBusyCursor() busy = wx.BusyCursor()
item = event.GetItem() item = event.GetItem()
if self.IsExpanded(item): if self.IsExpanded(item):
return return
@@ -86,7 +86,7 @@ class FillingTree(wx.wxTreeCtrl):
def OnItemCollapsed(self, event): def OnItemCollapsed(self, event):
"""Remove all children from the item.""" """Remove all children from the item."""
busy = wx.wxBusyCursor() busy = wx.BusyCursor()
item = event.GetItem() item = event.GetItem()
# self.CollapseAndReset(item) # self.CollapseAndReset(item)
# self.DeleteChildren(item) # self.DeleteChildren(item)
@@ -94,7 +94,7 @@ class FillingTree(wx.wxTreeCtrl):
def OnSelChanged(self, event): def OnSelChanged(self, event):
"""Display information about the item.""" """Display information about the item."""
busy = wx.wxBusyCursor() busy = wx.BusyCursor()
self.item = event.GetItem() self.item = event.GetItem()
self.display() self.display()
@@ -116,7 +116,7 @@ class FillingTree(wx.wxTreeCtrl):
def objGetChildren(self, obj): def objGetChildren(self, obj):
"""Return dictionary with attributes or contents of object.""" """Return dictionary with attributes or contents of object."""
busy = wx.wxBusyCursor() busy = wx.BusyCursor()
otype = type(obj) otype = type(obj)
if otype is types.DictType \ if otype is types.DictType \
or str(otype)[17:23] == 'BTrees' and hasattr(obj, 'keys'): or str(otype)[17:23] == 'BTrees' and hasattr(obj, 'keys'):
@@ -156,7 +156,7 @@ class FillingTree(wx.wxTreeCtrl):
or (item == self.root and not self.rootIsNamespace)): or (item == self.root and not self.rootIsNamespace)):
itemtext = repr(key) itemtext = repr(key)
child = children[key] child = children[key]
data = wx.wxTreeItemData(child) data = wx.TreeItemData(child)
branch = self.AppendItem(parent=item, text=itemtext, data=data) branch = self.AppendItem(parent=item, text=itemtext, data=data)
self.SetItemHasChildren(branch, self.objHasChildren(child)) self.SetItemHasChildren(branch, self.objHasChildren(child))
@@ -166,7 +166,7 @@ class FillingTree(wx.wxTreeCtrl):
self.addChildren(item) self.addChildren(item)
self.setText('') self.setText('')
obj = self.GetPyData(item) obj = self.GetPyData(item)
if wx.wxPlatform == '__WXMSW__': if wx.Platform == '__WXMSW__':
if obj is None: # Windows bug fix. if obj is None: # Windows bug fix.
return return
self.SetItemHasChildren(item, self.objHasChildren(obj)) self.SetItemHasChildren(item, self.objHasChildren(obj))
@@ -248,13 +248,13 @@ class FillingTree(wx.wxTreeCtrl):
class FillingText(editwindow.EditWindow): class FillingText(editwindow.EditWindow):
"""FillingText based on StyledTextCtrl.""" """FillingText based on StyledTextCtrl."""
name = 'PyFilling Text' name = 'Filling Text'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN, size=wx.DefaultSize, style=wx.CLIP_CHILDREN,
static=False): static=False):
"""Create a FillingText instance.""" """Create FillingText instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style) editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
# Configure various defaults and user preferences. # Configure various defaults and user preferences.
self.SetReadOnly(True) self.SetReadOnly(True)
@@ -273,18 +273,18 @@ class FillingText(editwindow.EditWindow):
self.SetReadOnly(True) self.SetReadOnly(True)
class Filling(wx.wxSplitterWindow): class Filling(wx.SplitterWindow):
"""Filling based on wxSplitterWindow.""" """Filling based on wxSplitterWindow."""
name = 'PyFilling' name = 'Filling'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxSP_3D, size=wx.DefaultSize, style=wx.SP_3D,
name='Filling Window', rootObject=None, name='Filling Window', rootObject=None,
rootLabel=None, rootIsNamespace=False, static=False): rootLabel=None, rootIsNamespace=False, static=False):
"""Create a Filling instance.""" """Create a Filling instance."""
wx.wxSplitterWindow.__init__(self, parent, id, pos, size, style, name) wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.tree = FillingTree(parent=self, rootObject=rootObject, self.tree = FillingTree(parent=self, rootObject=rootObject,
rootLabel=rootLabel, rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace, rootIsNamespace=rootIsNamespace,
@@ -299,23 +299,23 @@ class Filling(wx.wxSplitterWindow):
self.tree.display() self.tree.display()
class FillingFrame(wx.wxFrame): class FillingFrame(wx.Frame):
"""Frame containing the namespace tree component.""" """Frame containing the namespace tree component."""
name = 'PyFilling Frame' name = 'Filling Frame'
revision = __revision__ revision = __revision__
def __init__(self, parent=None, id=-1, title='PyFilling', def __init__(self, parent=None, id=-1, title='PyFilling',
pos=wx.wxDefaultPosition, size=(600, 400), pos=wx.DefaultPosition, size=(600, 400),
style=wx.wxDEFAULT_FRAME_STYLE, rootObject=None, style=wx.DEFAULT_FRAME_STYLE, rootObject=None,
rootLabel=None, rootIsNamespace=False, static=False): rootLabel=None, rootIsNamespace=False, static=False):
"""Create a FillingFrame instance.""" """Create FillingFrame instance."""
wx.wxFrame.__init__(self, parent, id, title, pos, size, style) wx.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyFilling - The Tastiest Namespace Inspector' intro = 'PyFilling - The Tastiest Namespace Inspector'
self.CreateStatusBar() self.CreateStatusBar()
self.SetStatusText(intro) self.SetStatusText(intro)
import images import images
self.SetIcon(images.getPyCrustIcon()) self.SetIcon(images.getPyIcon())
self.filling = Filling(parent=self, rootObject=rootObject, self.filling = Filling(parent=self, rootObject=rootObject,
rootLabel=rootLabel, rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace, rootIsNamespace=rootIsNamespace,
@@ -324,11 +324,11 @@ class FillingFrame(wx.wxFrame):
self.filling.tree.setStatusText = self.SetStatusText self.filling.tree.setStatusText = self.SetStatusText
class App(wx.wxApp): class App(wx.App):
"""PyFilling standalone application.""" """PyFilling standalone application."""
def OnInit(self): def OnInit(self):
wx.wxInitAllImageHandlers() wx.InitAllImageHandlers()
self.fillingFrame = FillingFrame() self.fillingFrame = FillingFrame()
self.fillingFrame.Show(True) self.fillingFrame.Show(True)
self.SetTopWindow(self.fillingFrame) self.SetTopWindow(self.fillingFrame)

View File

@@ -4,7 +4,7 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2] __revision__ = "$Revision$"[11:-2]
from wxPython import wx import wx
from version import VERSION from version import VERSION
try: try:
@@ -13,49 +13,49 @@ except NameError:
True = 1==1 True = 1==1
False = 1==0 False = 1==0
ID_NEW = wx.wxID_NEW ID_NEW = wx.ID_NEW
ID_OPEN = wx.wxID_OPEN ID_OPEN = wx.ID_OPEN
ID_REVERT = wx.wxID_REVERT ID_REVERT = wx.ID_REVERT
ID_CLOSE = wx.wxID_CLOSE ID_CLOSE = wx.ID_CLOSE
ID_SAVE = wx.wxID_SAVE ID_SAVE = wx.ID_SAVE
ID_SAVEAS = wx.wxID_SAVEAS ID_SAVEAS = wx.ID_SAVEAS
ID_PRINT = wx.wxID_PRINT ID_PRINT = wx.ID_PRINT
ID_EXIT = wx.wxID_EXIT ID_EXIT = wx.ID_EXIT
ID_UNDO = wx.wxID_UNDO ID_UNDO = wx.ID_UNDO
ID_REDO = wx.wxID_REDO ID_REDO = wx.ID_REDO
ID_CUT = wx.wxID_CUT ID_CUT = wx.ID_CUT
ID_COPY = wx.wxID_COPY ID_COPY = wx.ID_COPY
ID_PASTE = wx.wxID_PASTE ID_PASTE = wx.ID_PASTE
ID_CLEAR = wx.wxID_CLEAR ID_CLEAR = wx.ID_CLEAR
ID_SELECTALL = wx.wxID_SELECTALL ID_SELECTALL = wx.ID_SELECTALL
ID_ABOUT = wx.wxID_ABOUT ID_ABOUT = wx.ID_ABOUT
ID_AUTOCOMP = wx.wxNewId() ID_AUTOCOMP = wx.NewId()
ID_AUTOCOMP_SHOW = wx.wxNewId() ID_AUTOCOMP_SHOW = wx.NewId()
ID_AUTOCOMP_MAGIC = wx.wxNewId() ID_AUTOCOMP_MAGIC = wx.NewId()
ID_AUTOCOMP_SINGLE = wx.wxNewId() ID_AUTOCOMP_SINGLE = wx.NewId()
ID_AUTOCOMP_DOUBLE = wx.wxNewId() ID_AUTOCOMP_DOUBLE = wx.NewId()
ID_CALLTIPS = wx.wxNewId() ID_CALLTIPS = wx.NewId()
ID_CALLTIPS_SHOW = wx.wxNewId() ID_CALLTIPS_SHOW = wx.NewId()
ID_COPY_PLUS = wx.wxNewId() ID_COPY_PLUS = wx.NewId()
ID_NAMESPACE = wx.wxNewId() ID_NAMESPACE = wx.NewId()
ID_PASTE_PLUS = wx.wxNewId() ID_PASTE_PLUS = wx.NewId()
ID_WRAP = wx.wxNewId() ID_WRAP = wx.NewId()
class Frame(wx.wxFrame): class Frame(wx.Frame):
"""Frame with standard menu items.""" """Frame with standard menu items."""
revision = __revision__ revision = __revision__
def __init__(self, parent=None, id=-1, title='Editor', def __init__(self, parent=None, id=-1, title='Editor',
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.wxDEFAULT_FRAME_STYLE): style=wx.DEFAULT_FRAME_STYLE):
"""Create a Frame instance.""" """Create a Frame instance."""
wx.wxFrame.__init__(self, parent, id, title, pos, size, style) wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.CreateStatusBar() self.CreateStatusBar()
self.SetStatusText('Frame') self.SetStatusText('Frame')
import images import images
self.SetIcon(images.getPyCrustIcon()) self.SetIcon(images.getPyIcon())
self.__createMenus() self.__createMenus()
wx.EVT_CLOSE(self, self.OnClose) wx.EVT_CLOSE(self, self.OnClose)
@@ -64,7 +64,7 @@ class Frame(wx.wxFrame):
self.Destroy() self.Destroy()
def __createMenus(self): def __createMenus(self):
m = self.fileMenu = wx.wxMenu() m = self.fileMenu = wx.Menu()
m.Append(ID_NEW, '&New \tCtrl+N', m.Append(ID_NEW, '&New \tCtrl+N',
'New file') 'New file')
m.Append(ID_OPEN, '&Open... \tCtrl+O', m.Append(ID_OPEN, '&Open... \tCtrl+O',
@@ -88,7 +88,7 @@ class Frame(wx.wxFrame):
m.AppendSeparator() m.AppendSeparator()
m.Append(ID_EXIT, 'E&xit', 'Exit Program') m.Append(ID_EXIT, 'E&xit', 'Exit Program')
m = self.editMenu = wx.wxMenu() m = self.editMenu = wx.Menu()
m.Append(ID_UNDO, '&Undo \tCtrl+Z', m.Append(ID_UNDO, '&Undo \tCtrl+Z',
'Undo the last action') 'Undo the last action')
m.Append(ID_REDO, '&Redo \tCtrl+Y', m.Append(ID_REDO, '&Redo \tCtrl+Y',
@@ -109,7 +109,7 @@ class Frame(wx.wxFrame):
m.Append(ID_SELECTALL, 'Select A&ll \tCtrl+A', m.Append(ID_SELECTALL, 'Select A&ll \tCtrl+A',
'Select all text') 'Select all text')
m = self.autocompMenu = wx.wxMenu() m = self.autocompMenu = wx.Menu()
m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion',
'Show auto completion list', 1) 'Show auto completion list', 1)
m.Append(ID_AUTOCOMP_MAGIC, 'Include Magic Attributes', m.Append(ID_AUTOCOMP_MAGIC, 'Include Magic Attributes',
@@ -120,11 +120,11 @@ class Frame(wx.wxFrame):
m.Append(ID_AUTOCOMP_DOUBLE, 'Include Double Underscores', m.Append(ID_AUTOCOMP_DOUBLE, 'Include Double Underscores',
'Include attibutes prefixed by a double underscore', 1) 'Include attibutes prefixed by a double underscore', 1)
m = self.calltipsMenu = wx.wxMenu() m = self.calltipsMenu = wx.Menu()
m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips',
'Show call tips with argument signature and docstring', 1) 'Show call tips with argument signature and docstring', 1)
m = self.optionsMenu = wx.wxMenu() m = self.optionsMenu = wx.Menu()
m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu,
'Auto Completion Options') 'Auto Completion Options')
m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu,
@@ -132,11 +132,11 @@ class Frame(wx.wxFrame):
m.Append(ID_WRAP, '&Wrap Lines', m.Append(ID_WRAP, '&Wrap Lines',
'Wrap lines at right edge', 1) 'Wrap lines at right edge', 1)
m = self.helpMenu = wx.wxMenu() m = self.helpMenu = wx.Menu()
m.AppendSeparator() m.AppendSeparator()
m.Append(ID_ABOUT, '&About...', 'About this program') m.Append(ID_ABOUT, '&About...', 'About this program')
b = self.menuBar = wx.wxMenuBar() b = self.menuBar = wx.MenuBar()
b.Append(self.fileMenu, '&File') b.Append(self.fileMenu, '&File')
b.Append(self.editMenu, '&Edit') b.Append(self.editMenu, '&Edit')
b.Append(self.optionsMenu, '&Options') b.Append(self.optionsMenu, '&Options')
@@ -221,77 +221,77 @@ class Frame(wx.wxFrame):
self.Close(False) self.Close(False)
def OnUndo(self, event): def OnUndo(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Undo() win.Undo()
def OnRedo(self, event): def OnRedo(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Redo() win.Redo()
def OnCut(self, event): def OnCut(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Cut() win.Cut()
def OnCopy(self, event): def OnCopy(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Copy() win.Copy()
def OnCopyPlus(self, event): def OnCopyPlus(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.CopyWithPrompts() win.CopyWithPrompts()
def OnPaste(self, event): def OnPaste(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Paste() win.Paste()
def OnPastePlus(self, event): def OnPastePlus(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.PasteAndRun() win.PasteAndRun()
def OnClear(self, event): def OnClear(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.Clear() win.Clear()
def OnSelectAll(self, event): def OnSelectAll(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.SelectAll() win.SelectAll()
def OnAbout(self, event): def OnAbout(self, event):
"""Display an About window.""" """Display an About window."""
title = 'About' title = 'About'
text = 'Your message here.' text = 'Your message here.'
dialog = wx.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
def OnAutoCompleteShow(self, event): def OnAutoCompleteShow(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.autoComplete = event.IsChecked() win.autoComplete = event.IsChecked()
def OnAutoCompleteMagic(self, event): def OnAutoCompleteMagic(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.autoCompleteIncludeMagic = event.IsChecked() win.autoCompleteIncludeMagic = event.IsChecked()
def OnAutoCompleteSingle(self, event): def OnAutoCompleteSingle(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.autoCompleteIncludeSingle = event.IsChecked() win.autoCompleteIncludeSingle = event.IsChecked()
def OnAutoCompleteDouble(self, event): def OnAutoCompleteDouble(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.autoCompleteIncludeDouble = event.IsChecked() win.autoCompleteIncludeDouble = event.IsChecked()
def OnCallTipsShow(self, event): def OnCallTipsShow(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.autoCallTip = event.IsChecked() win.autoCallTip = event.IsChecked()
def OnWrap(self, event): def OnWrap(self, event):
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
win.SetWrapMode(event.IsChecked()) win.SetWrapMode(event.IsChecked())
def OnUpdateMenu(self, event): def OnUpdateMenu(self, event):
"""Update menu items based on current status and context.""" """Update menu items based on current status and context."""
win = wx.wxWindow_FindFocus() win = wx.Window_FindFocus()
id = event.GetId() id = event.GetId()
event.Enable(True) event.Enable(True)
try: try:

View File

@@ -1,12 +1,26 @@
#---------------------------------------------------------------------- """Support for icons."""
# This file was generated by ../scripts/img2py
# __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
from wxPython.wx import wxImageFromStream, wxBitmapFromImage __cvsid__ = "$Id$"
from wxPython.wx import wxEmptyIcon __revision__ = "$Revision$"[11:-2]
import wx
import cStringIO import cStringIO
def getPyCrustData(): def getPyIcon():
icon = wx.EmptyIcon()
icon.CopyFromBitmap(getPyBitmap())
return icon
def getPyBitmap():
return wx.BitmapFromImage(getPyImage())
def getPyImage():
stream = cStringIO.StringIO(getPyData())
return wx.ImageFromStream(stream)
def getPyData():
return \ return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\
@@ -56,16 +70,3 @@ N\xba\xb3\xab\x87\xfb\x8f\x97\xd8\xd9\xd5\x03\xc0\xfd\xc7K\xec\xd8\xd6\xdd\
\x8f\xdb\xbel\x8e\xa1S\xc7\xda\xc6\xe6\xee\xccs\xe9\xdcYnV\x95\xd8\xf2?&q+\ \x8f\xdb\xbel\x8e\xa1S\xc7\xda\xc6\xe6\xee\xccs\xe9\xdcYnV\x95\xd8\xf2?&q+\
\x9c\x1b1\xf3\xbf\xcd3{\xfdJ\xdb\xf8\xde\xfd\x19.\\\xad\x08\x80\xbf\x01\xd1\ \x9c\x1b1\xf3\xbf\xcd3{\xfdJ\xdb\xf8\xde\xfd\x19.\\\xad\x08\x80\xbf\x01\xd1\
\x86\xfa\x8b\xc7\xc0\xc8\xb7\x00\x00\x00\x00IEND\xaeB`\x82' \x86\xfa\x8b\xc7\xc0\xc8\xb7\x00\x00\x00\x00IEND\xaeB`\x82'
def getPyCrustBitmap():
return wxBitmapFromImage(getPyCrustImage())
def getPyCrustImage():
stream = cStringIO.StringIO(getPyCrustData())
return wxImageFromStream(stream)
def getPyCrustIcon():
icon = wxEmptyIcon()
icon.CopyFromBitmap(getPyCrustBitmap())
return icon

View File

@@ -1,8 +1,6 @@
"""The PyCrust Shell is an interactive text control in which a user """Shell is an interactive text control in which a user types in
types in commands to be sent to the interpreter. This particular shell commands to be sent to the interpreter. This particular shell is
is based on wxPython's wxStyledTextCtrl. The latest files are always based on wxPython's wxStyledTextCtrl.
available at the SourceForge project page at
http://sourceforge.net/projects/pycrust/.
Sponsored by Orbtech - Your source for Python programming expertise.""" Sponsored by Orbtech - Your source for Python programming expertise."""
@@ -13,6 +11,8 @@ __revision__ = "$Revision$"[11:-2]
from wxd.d_wx import wx from wxd.d_wx import wx
from wxd.d_stc import stc from wxd.d_stc import stc
import wx
import keyword import keyword
import os import os
import sys import sys
@@ -40,18 +40,18 @@ NAVKEYS = (wx.WXK_END, wx.WXK_LEFT, wx.WXK_RIGHT,
class ShellFrame(frame.Frame): class ShellFrame(frame.Frame):
"""Frame containing the PyCrust shell component.""" """Frame containing the shell component."""
name = 'PyCrust Shell Frame' name = 'Shell Frame'
revision = __revision__ revision = __revision__
def __init__(self, parent=None, id=-1, title='PyShell', def __init__(self, parent=None, id=-1, title='PyShell',
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.wxDEFAULT_FRAME_STYLE, locals=None, style=wx.DEFAULT_FRAME_STYLE, locals=None,
InterpClass=None, *args, **kwds): InterpClass=None, *args, **kwds):
"""Create a PyCrust ShellFrame instance.""" """Create ShellFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style) frame.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro = 'PyShell %s - The Flakiest Python Shell' % VERSION
intro += '\nSponsored by Orbtech - ' + \ intro += '\nSponsored by Orbtech - ' + \
'Your source for Python programming expertise.' 'Your source for Python programming expertise.'
self.SetStatusText(intro.replace('\n', ', ')) self.SetStatusText(intro.replace('\n', ', '))
@@ -81,10 +81,10 @@ class ShellFrame(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.wxMessageDialog(self, text, title, dialog = wx.MessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION) wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -95,7 +95,7 @@ class ShellFacade:
This is a semi-transparent facade, in that all attributes of other This is a semi-transparent facade, in that all attributes of other
are accessible, even though only some are visible to the user.""" are accessible, even though only some are visible to the user."""
name = 'PyCrust Shell Interface' name = 'Shell Interface'
revision = __revision__ revision = __revision__
def __init__(self, other): def __init__(self, other):
@@ -174,15 +174,15 @@ Ctrl+= Default font size.
class Shell(editwindow.EditWindow): class Shell(editwindow.EditWindow):
"""PyCrust Shell based on StyledTextCtrl.""" """Shell based on StyledTextCtrl."""
name = 'PyCrust Shell' name = 'Shell'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN, size=wx.DefaultSize, style=wx.CLIP_CHILDREN,
introText='', locals=None, InterpClass=None, *args, **kwds): introText='', locals=None, InterpClass=None, *args, **kwds):
"""Create a PyCrust Shell instance.""" """Create Shell instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style) editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
self.wrap() self.wrap()
if locals is None: if locals is None:
@@ -240,7 +240,7 @@ class Shell(editwindow.EditWindow):
# Do this last so the user has complete control over their # Do this last so the user has complete control over their
# environment. They can override anything they want. # environment. They can override anything they want.
self.execStartupScript(self.interp.startupScript) self.execStartupScript(self.interp.startupScript)
wx.wxCallAfter(self.ScrollToLine, 0) wx.CallAfter(self.ScrollToLine, 0)
def destroy(self): def destroy(self):
del self.interp del self.interp
@@ -299,17 +299,17 @@ class Shell(editwindow.EditWindow):
self.push('') self.push('')
def about(self): def about(self):
"""Display information about PyCrust.""" """Display information about Py."""
text = """ text = """
Author: %r Author: %r
PyCrust Version: %s Py Version: %s
Shell Revision: %s Py Shell Revision: %s
Interpreter Revision: %s Py Interpreter Revision: %s
Python Version: %s Python Version: %s
wxPython Version: %s wxPython Version: %s
Platform: %s""" % \ Platform: %s""" % \
(__author__, VERSION, self.revision, self.interp.revision, (__author__, VERSION, self.revision, self.interp.revision,
sys.version.split()[0], wx.__version__, sys.platform) sys.version.split()[0], wx.VERSION_STRING, sys.platform)
self.write(text.strip()) self.write(text.strip())
def OnChar(self, event): def OnChar(self, event):
@@ -673,7 +673,7 @@ Platform: %s""" % \
def push(self, command): def push(self, command):
"""Send command to the interpreter for execution.""" """Send command to the interpreter for execution."""
self.write(os.linesep) self.write(os.linesep)
busy = wx.wxBusyCursor() busy = wx.BusyCursor()
self.waiting = True self.waiting = True
self.more = self.interp.push(command) self.more = self.interp.push(command)
self.waiting = False self.waiting = False
@@ -751,7 +751,7 @@ Platform: %s""" % \
self.prompt() self.prompt()
try: try:
while not reader.input: while not reader.input:
wx.wxYieldIfNeeded() wx.YieldIfNeeded()
input = reader.input input = reader.input
finally: finally:
reader.input = '' reader.input = ''
@@ -774,10 +774,10 @@ Platform: %s""" % \
def ask(self, prompt='Please enter your response:'): def ask(self, prompt='Please enter your response:'):
"""Get response from the user using a dialog box.""" """Get response from the user using a dialog box."""
dialog = wx.wxTextEntryDialog(None, prompt, dialog = wx.TextEntryDialog(None, prompt,
'Input Dialog (Raw)', '') 'Input Dialog (Raw)', '')
try: try:
if dialog.ShowModal() == wx.wxID_OK: if dialog.ShowModal() == wx.ID_OK:
text = dialog.GetValue() text = dialog.GetValue()
return text return text
finally: finally:
@@ -931,14 +931,14 @@ Platform: %s""" % \
command = command.replace(os.linesep + ps2, os.linesep) command = command.replace(os.linesep + ps2, os.linesep)
command = command.replace(os.linesep + ps1, os.linesep) command = command.replace(os.linesep + ps1, os.linesep)
command = self.lstripPrompt(text=command) command = self.lstripPrompt(text=command)
data = wx.wxTextDataObject(command) data = wx.TextDataObject(command)
self._clip(data) self._clip(data)
def CopyWithPrompts(self): def CopyWithPrompts(self):
"""Copy selection, including prompts, and place it on the clipboard.""" """Copy selection, including prompts, and place it on the clipboard."""
if self.CanCopy(): if self.CanCopy():
command = self.GetSelectedText() command = self.GetSelectedText()
data = wx.wxTextDataObject(command) data = wx.TextDataObject(command)
self._clip(data) self._clip(data)
def CopyWithPromptsPrefixed(self): def CopyWithPromptsPrefixed(self):
@@ -949,23 +949,23 @@ Platform: %s""" % \
spaces = ' ' * 4 spaces = ' ' * 4
command = spaces + command.replace(os.linesep, command = spaces + command.replace(os.linesep,
os.linesep + spaces) os.linesep + spaces)
data = wx.wxTextDataObject(command) data = wx.TextDataObject(command)
self._clip(data) self._clip(data)
def _clip(self, data): def _clip(self, data):
if wx.wxTheClipboard.Open(): if wx.TheClipboard.Open():
wx.wxTheClipboard.UsePrimarySelection(False) wx.TheClipboard.UsePrimarySelection(False)
wx.wxTheClipboard.SetData(data) wx.TheClipboard.SetData(data)
wx.wxTheClipboard.Flush() wx.TheClipboard.Flush()
wx.wxTheClipboard.Close() wx.TheClipboard.Close()
def Paste(self): def Paste(self):
"""Replace selection with clipboard contents.""" """Replace selection with clipboard contents."""
if self.CanPaste() and wx.wxTheClipboard.Open(): if self.CanPaste() and wx.TheClipboard.Open():
ps2 = str(sys.ps2) ps2 = str(sys.ps2)
if wx.wxTheClipboard.IsSupported(wx.wxDataFormat(wx.wxDF_TEXT)): if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)):
data = wx.wxTextDataObject() data = wx.TextDataObject()
if wx.wxTheClipboard.GetData(data): if wx.TheClipboard.GetData(data):
self.ReplaceSelection('') self.ReplaceSelection('')
command = data.GetText() command = data.GetText()
command = command.rstrip() command = command.rstrip()
@@ -975,16 +975,16 @@ Platform: %s""" % \
command = command.replace(os.linesep, '\n') command = command.replace(os.linesep, '\n')
command = command.replace('\n', os.linesep + ps2) command = command.replace('\n', os.linesep + ps2)
self.write(command) self.write(command)
wx.wxTheClipboard.Close() wx.TheClipboard.Close()
def PasteAndRun(self): def PasteAndRun(self):
"""Replace selection with clipboard contents, run commands.""" """Replace selection with clipboard contents, run commands."""
if wx.wxTheClipboard.Open(): if wx.TheClipboard.Open():
ps1 = str(sys.ps1) ps1 = str(sys.ps1)
ps2 = str(sys.ps2) ps2 = str(sys.ps2)
if wx.wxTheClipboard.IsSupported(wx.wxDataFormat(wx.wxDF_TEXT)): if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)):
data = wx.wxTextDataObject() data = wx.TextDataObject()
if wx.wxTheClipboard.GetData(data): if wx.TheClipboard.GetData(data):
endpos = self.GetTextLength() endpos = self.GetTextLength()
self.SetCurrentPos(endpos) self.SetCurrentPos(endpos)
startpos = self.promptPosEnd startpos = self.promptPosEnd
@@ -1022,14 +1022,14 @@ Platform: %s""" % \
command = command.replace('\n', os.linesep + ps2) command = command.replace('\n', os.linesep + ps2)
self.write(command) self.write(command)
self.processLine() self.processLine()
wx.wxTheClipboard.Close() wx.TheClipboard.Close()
def wrap(self, wrap=True): def wrap(self, wrap=True):
"""Sets whether text is word wrapped.""" """Sets whether text is word wrapped."""
try: try:
self.SetWrapMode(wrap) self.SetWrapMode(wrap)
except AttributeError: except AttributeError:
return 'Wrapping is not available in this version of PyCrust.' return 'Wrapping is not available in this version.'
def zoom(self, points=0): def zoom(self, points=0):
"""Set the zoom level. """Set the zoom level.