Compare commits

..

1 Commits

Author SHA1 Message Date
Bryan Petty
04e089170a This commit was manufactured by cvs2svn to create tag 'Py_0_9_1'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/Py_0_9_1@20447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-05-03 13:12:21 +00:00
26 changed files with 333 additions and 588 deletions

View File

@@ -1,49 +1,4 @@
0.9.2 (5/3/2003 to //2003)
-----------------------------
Changed to the new prefix-less "wx" package::
import wx
instead of::
from wxPython import wx
Fixed typo in ``PyWrap.py``::
if __name__ == '__main__':
main(sys.argv)
should have been::
if __name__ == '__main__':
main()
Added pretty-print Display tab to Crust, based on suggestion from
Jason Whitlark.
Improved ``Can*`` checks in ``EditWindow``, since STC is too lenient,
particularly when it is set to read-only but returns True for
CanPaste() (seems like an STC bug to me)::
def CanCopy(self):
"""Return True if text is selected and can be copied."""
return self.GetSelectionStart() != self.GetSelectionEnd()
def CanCut(self):
"""Return True if text is selected and can be cut."""
return self.CanCopy() and self.CanEdit()
def CanEdit(self):
"""Return True if editing should succeed."""
return not self.GetReadOnly()
def CanPaste(self):
"""Return True if pasting should succeed."""
return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()
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]
import wx from wxPython 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.App): class App(wx.wxApp):
"""PyAlaCarte standalone application.""" """PyAlaCarte standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.App.__init__(self, redirect=False) wx.wxApp.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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]
import wx from wxPython 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.App): class App(wx.wxApp):
"""PyAlaMode standalone application.""" """PyAlaMode standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.App.__init__(self, redirect=False) wx.wxApp.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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]
import wx from wxPython 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.App): class App(wx.wxApp):
"""PyAlaModeTest standalone application.""" """PyAlaModeTest standalone application."""
def __init__(self, filename=None): def __init__(self, filename=None):
self.filename = filename self.filename = filename
wx.App.__init__(self, redirect=False) wx.wxApp.__init__(self, redirect=False)
def OnInit(self): def OnInit(self):
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

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]
import wx from wxPython import wx
try: try:
True True
@@ -20,12 +20,12 @@ except NameError:
False = 1==0 False = 1==0
class App(wx.App): class App(wx.wxApp):
"""PyCrust standalone application.""" """PyCrust standalone application."""
def OnInit(self): def OnInit(self):
import wx from wxPython import wx
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
locals = __main__.__dict__ locals = __main__.__dict__
from crust import CrustFrame from crust import CrustFrame
self.frame = CrustFrame(locals=locals) self.frame = CrustFrame(locals=locals)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -15,8 +15,9 @@ import interpreter
import introspect import introspect
import pseudo import pseudo
import shell import shell
import sys import sys
import wx from wxPython 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]
import wx from wxPython import wx
try: try:
True True
@@ -20,12 +20,12 @@ except NameError:
False = 1==0 False = 1==0
class App(wx.App): class App(wx.wxApp):
"""PyShell standalone application.""" """PyShell standalone application."""
def OnInit(self): def OnInit(self):
import wx from wxPython import wx
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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
import wx from wxPython 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.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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.App): if issubclass(d[item], wx.wxApp):
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() main(sys.argv)

View File

@@ -1,4 +1,4 @@
"""The py package, formerly the PyCrust package.""" """Python package."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"

View File

@@ -4,6 +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
from interpreter import Interpreter from interpreter import Interpreter
import imp import imp
import os import os

View File

@@ -1,17 +1,15 @@
"""Crust combines the shell and filling into one control.""" """PyCrust 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]
import wx from wxPython 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
@@ -24,26 +22,26 @@ except NameError:
False = 1==0 False = 1==0
class Crust(wx.SplitterWindow): class Crust(wx.wxSplitterWindow):
"""Crust based on SplitterWindow.""" """PyCrust Crust based on wxSplitterWindow."""
name = 'Crust' name = 'PyCrust Crust'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D, size=wx.wxDefaultSize, style=wx.wxSP_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 Crust instance.""" """Create a PyCrust Crust instance."""
wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) wx.wxSplitterWindow.__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.Notebook(parent=self, id=-1) self.notebook = wx.wxNotebook(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,
@@ -52,10 +50,6 @@ 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)
@@ -80,46 +74,13 @@ class Crust(wx.SplitterWindow):
self.SetMinimumPaneSize(1) self.SetMinimumPaneSize(1)
class Display(editwindow.EditWindow): class Calltip(wx.wxTextCtrl):
"""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):
"""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.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2 style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | wx.wxTE_RICH2
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style) wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.Colour(255, 255, 232)) self.SetBackgroundColour(wx.wxColour(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):
@@ -127,13 +88,13 @@ class Calltip(wx.TextCtrl):
self.SetValue(calltip) self.SetValue(calltip)
class SessionListing(wx.TextCtrl): class SessionListing(wx.wxTextCtrl):
"""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.TE_MULTILINE | wx.TE_READONLY | \ style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP wx.wxTE_RICH2 | wx.wxTE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style) wx.wxTextCtrl.__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):
@@ -146,13 +107,13 @@ class SessionListing(wx.TextCtrl):
self.AppendText(command + '\n') self.AppendText(command + '\n')
class DispatcherListing(wx.TextCtrl): class DispatcherListing(wx.wxTextCtrl):
"""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.TE_MULTILINE | wx.TE_READONLY | \ style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP wx.wxTE_RICH2 | wx.wxTE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style) wx.wxTextCtrl.__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):
@@ -168,15 +129,15 @@ class DispatcherListing(wx.TextCtrl):
class CrustFrame(frame.Frame): class CrustFrame(frame.Frame):
"""Frame containing all the PyCrust components.""" """Frame containing all the PyCrust components."""
name = 'CrustFrame' name = 'PyCrust Frame'
revision = __revision__ revision = __revision__
def __init__(self, parent=None, id=-1, title='PyCrust', def __init__(self, parent=None, id=-1, title='PyCrust',
pos=wx.DefaultPosition, size=wx.DefaultSize, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize,
style=wx.DEFAULT_FRAME_STYLE, style=wx.wxDEFAULT_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 CrustFrame instance.""" """Create a PyCrust 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 - '
@@ -213,9 +174,9 @@ 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_STRING + \ 'wxPython Version: %s\n' % wx.__version__ + \
'Platform: %s\n' % sys.platform 'Platform: %s\n' % sys.platform
dialog = wx.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_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]
import wx from wxPython import wx
from buffer import Buffer from buffer import Buffer
import crust import crust
@@ -25,9 +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.DefaultPosition, size=(800, 600), pos=wx.wxDefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE, style=wx.wxDEFAULT_FRAME_STYLE, filename=None):
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 = {}
@@ -56,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.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -142,12 +141,11 @@ class EditorFrame(frame.Frame):
"""Create new buffer.""" """Create new buffer."""
self.bufferDestroy() self.bufferDestroy()
buffer = Buffer() buffer = Buffer()
self.panel = panel = wx.Panel(parent=self, id=-1) self.panel = panel = wx.wxPanel(parent=self, id=-1)
wx.EVT_ERASE_BACKGROUND(panel, lambda x: x)
editor = Editor(parent=panel) editor = Editor(parent=panel)
panel.editor = editor panel.editor = editor
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.wxBoxSizer(wx.wxVERTICAL)
sizer.Add(editor.window, 1, wx.EXPAND) sizer.Add(editor.window, 1, wx.wxEXPAND)
panel.SetSizer(sizer) panel.SetSizer(sizer)
panel.SetAutoLayout(True) panel.SetAutoLayout(True)
sizer.Layout() sizer.Layout()
@@ -155,8 +153,6 @@ class EditorFrame(frame.Frame):
buffer.open(filename) buffer.open(filename)
self.setEditor(editor) self.setEditor(editor)
self.editor.setFocus() self.editor.setFocus()
self.SendSizeEvent()
def bufferDestroy(self): def bufferDestroy(self):
"""Destroy the current buffer.""" """Destroy the current buffer."""
@@ -168,7 +164,6 @@ class EditorFrame(frame.Frame):
self.buffer = None self.buffer = None
self.panel.Destroy() self.panel.Destroy()
def bufferHasChanged(self): def bufferHasChanged(self):
"""Return True if buffer has changed since last save.""" """Return True if buffer has changed since last save."""
if self.buffer: if self.buffer:
@@ -260,9 +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.DefaultPosition, size=(800, 600), pos=wx.wxDefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE, style=wx.wxDEFAULT_FRAME_STYLE, filename=None):
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,
@@ -276,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 = 'Py %s' % version.VERSION intro = 'PyCrust %s' % version.VERSION
import imp import imp
module = imp.new_module('__main__') module = imp.new_module('__main__')
import __builtin__ import __builtin__
@@ -290,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='*Shell*', select=True) self.notebook.AddPage(page=self.crust, text='PyCrust', select=True)
self.setEditor(self.crust.editor) self.setEditor(self.crust.editor)
self.crust.editor.SetFocus() self.crust.editor.SetFocus()
@@ -302,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.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -323,12 +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.Panel(parent=self.notebook, id=-1) panel = wx.wxPanel(parent=self.notebook, id=-1)
wx.EVT_ERASE_BACKGROUND(panel, lambda x: x)
editor = Editor(parent=panel) editor = Editor(parent=panel)
panel.editor = editor panel.editor = editor
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.wxBoxSizer(wx.wxVERTICAL)
sizer.Add(editor.window, 1, wx.EXPAND) sizer.Add(editor.window, 1, wx.wxEXPAND)
panel.SetSizer(sizer) panel.SetSizer(sizer)
panel.SetAutoLayout(True) panel.SetAutoLayout(True)
sizer.Layout() sizer.Layout()
@@ -366,12 +359,12 @@ class EditorNotebookFrame(EditorFrame):
return cancel return cancel
class EditorNotebook(wx.Notebook): class EditorNotebook(wx.wxNotebook):
"""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.Notebook.__init__(self, parent, id=-1, style=wx.NO_FULL_REPAINT_ON_RESIZE) wx.wxNotebook.__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(),
@@ -437,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.DefaultPosition, size=(600, 400), pos=wx.wxDefaultPosition, size=(600, 400),
style=wx.DEFAULT_FRAME_STYLE, style=wx.wxDEFAULT_FRAME_STYLE,
filename=None, singlefile=False): filename=None, singlefile=False):
"""Create EditorShellNotebookFrame instance.""" """Create EditorShellNotebookFrame instance."""
self._singlefile = singlefile self._singlefile = singlefile
@@ -456,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.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
@@ -522,16 +515,16 @@ class EditorShellNotebookFrame(EditorNotebookFrame):
return cancel return cancel
class EditorShellNotebook(wx.Notebook): class EditorShellNotebook(wx.wxNotebook):
"""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.Notebook.__init__(self, parent, id=-1) wx.wxNotebook.__init__(self, parent, id=-1)
usePanels = True usePanels = True
if usePanels: if usePanels:
editorparent = editorpanel = wx.Panel(self, -1) editorparent = editorpanel = wx.wxPanel(self, -1)
shellparent = shellpanel = wx.Panel(self, -1) shellparent = shellpanel = wx.wxPanel(self, -1)
else: else:
editorparent = self editorparent = self
shellparent = self shellparent = self
@@ -540,18 +533,18 @@ class EditorShellNotebook(wx.Notebook):
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.CLIP_CHILDREN | wx.SUNKEN_BORDER) style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_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.BoxSizer(wx.VERTICAL) editorsizer = wx.wxBoxSizer(wx.wxVERTICAL)
editorsizer.Add(self.editor.window, 1, wx.EXPAND) editorsizer.Add(self.editor.window, 1, wx.wxEXPAND)
editorpanel.SetSizer(editorsizer) editorpanel.SetSizer(editorsizer)
editorpanel.SetAutoLayout(True) editorpanel.SetAutoLayout(True)
shellsizer = wx.BoxSizer(wx.VERTICAL) shellsizer = wx.wxBoxSizer(wx.wxVERTICAL)
shellsizer.Add(self.shell, 1, wx.EXPAND) shellsizer.Add(self.shell, 1, wx.wxEXPAND)
shellpanel.SetSizer(shellsizer) shellpanel.SetSizer(shellsizer)
shellpanel.SetAutoLayout(True) shellpanel.SetAutoLayout(True)
else: else:
@@ -570,7 +563,7 @@ class EditorShellNotebook(wx.Notebook):
event.Skip() event.Skip()
def SetFocus(self): def SetFocus(self):
wx.Notebook.SetFocus(self) wx.wxNotebook.SetFocus(self)
selection = self.GetSelection() selection = self.GetSelection()
if selection == 0: if selection == 0:
self.editor.setFocus() self.editor.setFocus()
@@ -581,9 +574,9 @@ class EditorShellNotebook(wx.Notebook):
class Editor: class Editor:
"""Editor having an EditWindow.""" """Editor having an EditWindow."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, size=wx.wxDefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER): style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_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()
@@ -739,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.DefaultPosition, def __init__(self, editor, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, size=wx.wxDefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER): style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_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
@@ -753,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.ID_OK, wx.ID_YES) self.positive = returned in (wx.wxID_OK, wx.wxID_YES)
self.text = self._asString() self.text = self._asString()
@@ -762,22 +755,22 @@ class DialogResults:
def _asString(self): def _asString(self):
returned = self.returned returned = self.returned
if returned == wx.ID_OK: if returned == wx.wxID_OK:
return "Ok" return "Ok"
elif returned == wx.ID_CANCEL: elif returned == wx.wxID_CANCEL:
return "Cancel" return "Cancel"
elif returned == wx.ID_YES: elif returned == wx.wxID_YES:
return "Yes" return "Yes"
elif returned == wx.ID_NO: elif returned == wx.wxID_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.OPEN | wx.MULTIPLE): style=wx.wxOPEN | wx.wxMULTIPLE):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename, dialog = wx.wxFileDialog(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()
@@ -788,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.OPEN): wildcard='All Files (*.*)|*.*', style=wx.wxOPEN):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename, dialog = wx.wxFileDialog(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()
@@ -803,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.OPEN | wx.MULTIPLE): style=wx.wxOPEN | wx.wxMULTIPLE):
"""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.SAVE | wx.HIDE_READONLY | wx.OVERWRITE_PROMPT): style=wx.wxSAVE | wx.wxHIDE_READONLY | wx.wxOVERWRITE_PROMPT):
"""File dialog wrapper function.""" """File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename, dialog = wx.wxFileDialog(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()
@@ -824,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.DefaultPosition, size=wx.DefaultSize): pos=wx.wxDefaultPosition, size=wx.wxDefaultSize):
"""Dir dialog wrapper function.""" """Dir dialog wrapper function."""
dialog = wx.DirDialog(parent, message, path, style, pos, size) dialog = wx.wxDirDialog(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()
@@ -837,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.YES_NO | wx.CANCEL | wx.CENTRE | wx.ICON_QUESTION, style=wx.wxYES_NO | wx.wxCANCEL | wx.wxCENTRE | wx.wxICON_QUESTION,
pos=wx.DefaultPosition): pos=wx.wxDefaultPosition):
"""Message dialog wrapper function.""" """Message dialog wrapper function."""
dialog = wx.MessageDialog(parent, message, title, style, pos) dialog = wx.wxMessageDialog(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]
import wx from wxPython import wx
from wx import stc from wxPython 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.Platform == '__WXMSW__': if wx.wxPlatform == '__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.StyledTextCtrl): class EditWindow(stc.wxStyledTextCtrl):
"""EditWindow based on StyledTextCtrl.""" """EditWindow based on StyledTextCtrl."""
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER): size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN | wx.wxSUNKEN_BORDER):
"""Create EditWindow instance.""" """Create EditWindow instance."""
stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style) stc.wxStyledTextCtrl.__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.StyledTextCtrl):
def __config(self): def __config(self):
"""Configure shell based on user preferences.""" """Configure shell based on user preferences."""
self.SetMarginType(1, stc.STC_MARGIN_NUMBER) self.SetMarginType(1, stc.wxSTC_MARGIN_NUMBER)
self.SetMarginWidth(1, 40) self.SetMarginWidth(1, 40)
self.SetLexer(stc.STC_LEX_PYTHON) self.SetLexer(stc.wxSTC_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.StyledTextCtrl):
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.Colour(255, 255, 232)) self.CallTipSetBackground(wx.wxColour(255, 255, 232))
self.SetWrapMode(False) self.SetWrapMode(False)
try: try:
self.SetEndAtLastLine(False) self.SetEndAtLastLine(False)
@@ -102,50 +102,50 @@ class EditWindow(stc.StyledTextCtrl):
"""Configure font size, typeface and color for lexer.""" """Configure font size, typeface and color for lexer."""
# Default style # Default style
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, self.StyleSetSpec(stc.wxSTC_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.STC_STYLE_LINENUMBER, self.StyleSetSpec(stc.wxSTC_STYLE_LINENUMBER,
"back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces) "back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces)
self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, self.StyleSetSpec(stc.wxSTC_STYLE_CONTROLCHAR,
"face:%(mono)s" % faces) "face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, self.StyleSetSpec(stc.wxSTC_STYLE_BRACELIGHT,
"fore:#0000FF,back:#FFFF88") "fore:#0000FF,back:#FFFF88")
self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, self.StyleSetSpec(stc.wxSTC_STYLE_BRACEBAD,
"fore:#FF0000,back:#FFFF88") "fore:#FF0000,back:#FFFF88")
# Python styles # Python styles
self.StyleSetSpec(stc.STC_P_DEFAULT, self.StyleSetSpec(stc.wxSTC_P_DEFAULT,
"face:%(mono)s" % faces) "face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_COMMENTLINE, self.StyleSetSpec(stc.wxSTC_P_COMMENTLINE,
"fore:#007F00,face:%(mono)s" % faces) "fore:#007F00,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_NUMBER, self.StyleSetSpec(stc.wxSTC_P_NUMBER,
"") "")
self.StyleSetSpec(stc.STC_P_STRING, self.StyleSetSpec(stc.wxSTC_P_STRING,
"fore:#7F007F,face:%(mono)s" % faces) "fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_CHARACTER, self.StyleSetSpec(stc.wxSTC_P_CHARACTER,
"fore:#7F007F,face:%(mono)s" % faces) "fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_WORD, self.StyleSetSpec(stc.wxSTC_P_WORD,
"fore:#00007F,bold") "fore:#00007F,bold")
self.StyleSetSpec(stc.STC_P_TRIPLE, self.StyleSetSpec(stc.wxSTC_P_TRIPLE,
"fore:#7F0000") "fore:#7F0000")
self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, self.StyleSetSpec(stc.wxSTC_P_TRIPLEDOUBLE,
"fore:#000033,back:#FFFFE8") "fore:#000033,back:#FFFFE8")
self.StyleSetSpec(stc.STC_P_CLASSNAME, self.StyleSetSpec(stc.wxSTC_P_CLASSNAME,
"fore:#0000FF,bold") "fore:#0000FF,bold")
self.StyleSetSpec(stc.STC_P_DEFNAME, self.StyleSetSpec(stc.wxSTC_P_DEFNAME,
"fore:#007F7F,bold") "fore:#007F7F,bold")
self.StyleSetSpec(stc.STC_P_OPERATOR, self.StyleSetSpec(stc.wxSTC_P_OPERATOR,
"") "")
self.StyleSetSpec(stc.STC_P_IDENTIFIER, self.StyleSetSpec(stc.wxSTC_P_IDENTIFIER,
"") "")
self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, self.StyleSetSpec(stc.wxSTC_P_COMMENTBLOCK,
"fore:#7F7F7F") "fore:#7F7F7F")
self.StyleSetSpec(stc.STC_P_STRINGEOL, self.StyleSetSpec(stc.wxSTC_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.StyledTextCtrl):
# Check before. # Check before.
if charBefore and chr(charBefore) in '[]{}()' \ if charBefore and chr(charBefore) in '[]{}()' \
and styleBefore == stc.STC_P_OPERATOR: and styleBefore == stc.wxSTC_P_OPERATOR:
braceAtCaret = caretPos - 1 braceAtCaret = caretPos - 1
# Check after. # Check after.
@@ -171,7 +171,7 @@ class EditWindow(stc.StyledTextCtrl):
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.STC_P_OPERATOR: and styleAfter == stc.wxSTC_P_OPERATOR:
braceAtCaret = caretPos braceAtCaret = caretPos
if braceAtCaret >= 0: if braceAtCaret >= 0:
@@ -182,18 +182,14 @@ class EditWindow(stc.StyledTextCtrl):
else: else:
self.BraceHighlight(braceAtCaret, braceOpposite) self.BraceHighlight(braceAtCaret, braceOpposite)
def CanCut(self):
"""Return true if text is selected and can be cut."""
return self.CanCopy()
def CanCopy(self): def CanCopy(self):
"""Return True if text is selected and can be copied.""" """Return true if text is selected and can be copied."""
return self.GetSelectionStart() != self.GetSelectionEnd() return self.GetSelectionStart() != self.GetSelectionEnd()
def CanCut(self):
"""Return True if text is selected and can be cut."""
return self.CanCopy() and self.CanEdit()
def CanEdit(self): def CanEdit(self):
"""Return True if editing should succeed.""" """Return true if editing should succeed."""
return not self.GetReadOnly() return True
def CanPaste(self):
"""Return True if pasting should succeed."""
return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()

View File

@@ -1,11 +1,11 @@
"""Filling is the gui tree control through which a user can navigate """PyCrust Filling is the gui tree control through which a user can
the local namespace or any object.""" navigate 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]
import wx from wxPython import wx
import dispatcher import dispatcher
import editwindow import editwindow
@@ -34,26 +34,24 @@ DOCTYPES = ('BuiltinFunctionType', 'BuiltinMethodType', 'ClassType',
SIMPLETYPES = [getattr(types, t) for t in dir(types) \ SIMPLETYPES = [getattr(types, t) for t in dir(types) \
if not t.startswith('_') and t not in DOCTYPES] if not t.startswith('_') and t not in DOCTYPES]
del t
try: try:
COMMONTYPES.append(type(''.__repr__)) # Method-wrapper in version 2.2.x. COMMONTYPES.append(type(''.__repr__)) # Method-wrapper in version 2.2.x.
except AttributeError: except AttributeError:
pass pass
class FillingTree(wx.TreeCtrl): class FillingTree(wx.wxTreeCtrl):
"""FillingTree based on TreeCtrl.""" """PyCrust FillingTree based on wxTreeCtrl."""
name = 'Filling Tree' name = 'PyCrust Filling Tree'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE, size=wx.wxDefaultSize, style=wx.wxTR_DEFAULT_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=False, rootObject=None, rootLabel=None, rootIsNamespace=False,
static=False): static=False):
"""Create FillingTree instance.""" """Create a PyCrust FillingTree instance."""
wx.TreeCtrl.__init__(self, parent, id, pos, size, style) wx.wxTreeCtrl.__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:
@@ -63,7 +61,7 @@ class FillingTree(wx.TreeCtrl):
rootLabel = 'locals()' rootLabel = 'locals()'
if not rootLabel: if not rootLabel:
rootLabel = 'Ingredients' rootLabel = 'Ingredients'
rootData = wx.TreeItemData(rootObject) rootData = wx.wxTreeItemData(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)
@@ -79,7 +77,7 @@ class FillingTree(wx.TreeCtrl):
def OnItemExpanding(self, event): def OnItemExpanding(self, event):
"""Add children to the item.""" """Add children to the item."""
busy = wx.BusyCursor() busy = wx.wxBusyCursor()
item = event.GetItem() item = event.GetItem()
if self.IsExpanded(item): if self.IsExpanded(item):
return return
@@ -88,7 +86,7 @@ class FillingTree(wx.TreeCtrl):
def OnItemCollapsed(self, event): def OnItemCollapsed(self, event):
"""Remove all children from the item.""" """Remove all children from the item."""
busy = wx.BusyCursor() busy = wx.wxBusyCursor()
item = event.GetItem() item = event.GetItem()
# self.CollapseAndReset(item) # self.CollapseAndReset(item)
# self.DeleteChildren(item) # self.DeleteChildren(item)
@@ -96,7 +94,7 @@ class FillingTree(wx.TreeCtrl):
def OnSelChanged(self, event): def OnSelChanged(self, event):
"""Display information about the item.""" """Display information about the item."""
busy = wx.BusyCursor() busy = wx.wxBusyCursor()
self.item = event.GetItem() self.item = event.GetItem()
self.display() self.display()
@@ -118,7 +116,7 @@ class FillingTree(wx.TreeCtrl):
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.BusyCursor() busy = wx.wxBusyCursor()
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'):
@@ -146,7 +144,7 @@ class FillingTree(wx.TreeCtrl):
if not children: if not children:
return return
keys = children.keys() keys = children.keys()
keys.sort(lambda x, y: cmp(str(x).lower(), str(y).lower())) keys.sort(lambda x, y: cmp(x.lower(), y.lower()))
for key in keys: for key in keys:
itemtext = str(key) itemtext = str(key)
# Show string dictionary items with single quotes, except # Show string dictionary items with single quotes, except
@@ -158,7 +156,7 @@ class FillingTree(wx.TreeCtrl):
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.TreeItemData(child) data = wx.wxTreeItemData(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))
@@ -168,7 +166,7 @@ class FillingTree(wx.TreeCtrl):
self.addChildren(item) self.addChildren(item)
self.setText('') self.setText('')
obj = self.GetPyData(item) obj = self.GetPyData(item)
if wx.Platform == '__WXMSW__': if wx.wxPlatform == '__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))
@@ -250,13 +248,13 @@ class FillingTree(wx.TreeCtrl):
class FillingText(editwindow.EditWindow): class FillingText(editwindow.EditWindow):
"""FillingText based on StyledTextCtrl.""" """FillingText based on StyledTextCtrl."""
name = 'Filling Text' name = 'PyFilling Text'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.CLIP_CHILDREN, size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN,
static=False): static=False):
"""Create FillingText instance.""" """Create a 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)
@@ -275,18 +273,18 @@ class FillingText(editwindow.EditWindow):
self.SetReadOnly(True) self.SetReadOnly(True)
class Filling(wx.SplitterWindow): class Filling(wx.wxSplitterWindow):
"""Filling based on wxSplitterWindow.""" """Filling based on wxSplitterWindow."""
name = 'Filling' name = 'PyFilling'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D, size=wx.wxDefaultSize, style=wx.wxSP_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.SplitterWindow.__init__(self, parent, id, pos, size, style, name) wx.wxSplitterWindow.__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,
@@ -301,23 +299,23 @@ class Filling(wx.SplitterWindow):
self.tree.display() self.tree.display()
class FillingFrame(wx.Frame): class FillingFrame(wx.wxFrame):
"""Frame containing the namespace tree component.""" """Frame containing the namespace tree component."""
name = 'Filling Frame' name = 'PyFilling 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.DefaultPosition, size=(600, 400), pos=wx.wxDefaultPosition, size=(600, 400),
style=wx.DEFAULT_FRAME_STYLE, rootObject=None, style=wx.wxDEFAULT_FRAME_STYLE, rootObject=None,
rootLabel=None, rootIsNamespace=False, static=False): rootLabel=None, rootIsNamespace=False, static=False):
"""Create FillingFrame instance.""" """Create a FillingFrame instance."""
wx.Frame.__init__(self, parent, id, title, pos, size, style) wx.wxFrame.__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.getPyIcon()) self.SetIcon(images.getPyCrustIcon())
self.filling = Filling(parent=self, rootObject=rootObject, self.filling = Filling(parent=self, rootObject=rootObject,
rootLabel=rootLabel, rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace, rootIsNamespace=rootIsNamespace,
@@ -326,11 +324,11 @@ class FillingFrame(wx.Frame):
self.filling.tree.setStatusText = self.SetStatusText self.filling.tree.setStatusText = self.SetStatusText
class App(wx.App): class App(wx.wxApp):
"""PyFilling standalone application.""" """PyFilling standalone application."""
def OnInit(self): def OnInit(self):
wx.InitAllImageHandlers() wx.wxInitAllImageHandlers()
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]
import wx from wxPython 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.ID_NEW ID_NEW = wx.wxID_NEW
ID_OPEN = wx.ID_OPEN ID_OPEN = wx.wxID_OPEN
ID_REVERT = wx.ID_REVERT ID_REVERT = wx.wxID_REVERT
ID_CLOSE = wx.ID_CLOSE ID_CLOSE = wx.wxID_CLOSE
ID_SAVE = wx.ID_SAVE ID_SAVE = wx.wxID_SAVE
ID_SAVEAS = wx.ID_SAVEAS ID_SAVEAS = wx.wxID_SAVEAS
ID_PRINT = wx.ID_PRINT ID_PRINT = wx.wxID_PRINT
ID_EXIT = wx.ID_EXIT ID_EXIT = wx.wxID_EXIT
ID_UNDO = wx.ID_UNDO ID_UNDO = wx.wxID_UNDO
ID_REDO = wx.ID_REDO ID_REDO = wx.wxID_REDO
ID_CUT = wx.ID_CUT ID_CUT = wx.wxID_CUT
ID_COPY = wx.ID_COPY ID_COPY = wx.wxID_COPY
ID_PASTE = wx.ID_PASTE ID_PASTE = wx.wxID_PASTE
ID_CLEAR = wx.ID_CLEAR ID_CLEAR = wx.wxID_CLEAR
ID_SELECTALL = wx.ID_SELECTALL ID_SELECTALL = wx.wxID_SELECTALL
ID_ABOUT = wx.ID_ABOUT ID_ABOUT = wx.wxID_ABOUT
ID_AUTOCOMP = wx.NewId() ID_AUTOCOMP = wx.wxNewId()
ID_AUTOCOMP_SHOW = wx.NewId() ID_AUTOCOMP_SHOW = wx.wxNewId()
ID_AUTOCOMP_MAGIC = wx.NewId() ID_AUTOCOMP_MAGIC = wx.wxNewId()
ID_AUTOCOMP_SINGLE = wx.NewId() ID_AUTOCOMP_SINGLE = wx.wxNewId()
ID_AUTOCOMP_DOUBLE = wx.NewId() ID_AUTOCOMP_DOUBLE = wx.wxNewId()
ID_CALLTIPS = wx.NewId() ID_CALLTIPS = wx.wxNewId()
ID_CALLTIPS_SHOW = wx.NewId() ID_CALLTIPS_SHOW = wx.wxNewId()
ID_COPY_PLUS = wx.NewId() ID_COPY_PLUS = wx.wxNewId()
ID_NAMESPACE = wx.NewId() ID_NAMESPACE = wx.wxNewId()
ID_PASTE_PLUS = wx.NewId() ID_PASTE_PLUS = wx.wxNewId()
ID_WRAP = wx.NewId() ID_WRAP = wx.wxNewId()
class Frame(wx.Frame): class Frame(wx.wxFrame):
"""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.DefaultPosition, size=wx.DefaultSize, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize,
style=wx.DEFAULT_FRAME_STYLE): style=wx.wxDEFAULT_FRAME_STYLE):
"""Create a Frame instance.""" """Create a Frame instance."""
wx.Frame.__init__(self, parent, id, title, pos, size, style) wx.wxFrame.__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.getPyIcon()) self.SetIcon(images.getPyCrustIcon())
self.__createMenus() self.__createMenus()
wx.EVT_CLOSE(self, self.OnClose) wx.EVT_CLOSE(self, self.OnClose)
@@ -64,7 +64,7 @@ class Frame(wx.Frame):
self.Destroy() self.Destroy()
def __createMenus(self): def __createMenus(self):
m = self.fileMenu = wx.Menu() m = self.fileMenu = wx.wxMenu()
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.Frame):
m.AppendSeparator() m.AppendSeparator()
m.Append(ID_EXIT, 'E&xit', 'Exit Program') m.Append(ID_EXIT, 'E&xit', 'Exit Program')
m = self.editMenu = wx.Menu() m = self.editMenu = wx.wxMenu()
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.Frame):
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.Menu() m = self.autocompMenu = wx.wxMenu()
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.Frame):
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.Menu() m = self.calltipsMenu = wx.wxMenu()
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.Menu() m = self.optionsMenu = wx.wxMenu()
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.Frame):
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.Menu() m = self.helpMenu = wx.wxMenu()
m.AppendSeparator() m.AppendSeparator()
m.Append(ID_ABOUT, '&About...', 'About this program') m.Append(ID_ABOUT, '&About...', 'About this program')
b = self.menuBar = wx.MenuBar() b = self.menuBar = wx.wxMenuBar()
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.Frame):
self.Close(False) self.Close(False)
def OnUndo(self, event): def OnUndo(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Undo() win.Undo()
def OnRedo(self, event): def OnRedo(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Redo() win.Redo()
def OnCut(self, event): def OnCut(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Cut() win.Cut()
def OnCopy(self, event): def OnCopy(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Copy() win.Copy()
def OnCopyPlus(self, event): def OnCopyPlus(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.CopyWithPrompts() win.CopyWithPrompts()
def OnPaste(self, event): def OnPaste(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Paste() win.Paste()
def OnPastePlus(self, event): def OnPastePlus(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.PasteAndRun() win.PasteAndRun()
def OnClear(self, event): def OnClear(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.Clear() win.Clear()
def OnSelectAll(self, event): def OnSelectAll(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_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.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_INFORMATION)
dialog.ShowModal() dialog.ShowModal()
dialog.Destroy() dialog.Destroy()
def OnAutoCompleteShow(self, event): def OnAutoCompleteShow(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.autoComplete = event.IsChecked() win.autoComplete = event.IsChecked()
def OnAutoCompleteMagic(self, event): def OnAutoCompleteMagic(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.autoCompleteIncludeMagic = event.IsChecked() win.autoCompleteIncludeMagic = event.IsChecked()
def OnAutoCompleteSingle(self, event): def OnAutoCompleteSingle(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.autoCompleteIncludeSingle = event.IsChecked() win.autoCompleteIncludeSingle = event.IsChecked()
def OnAutoCompleteDouble(self, event): def OnAutoCompleteDouble(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.autoCompleteIncludeDouble = event.IsChecked() win.autoCompleteIncludeDouble = event.IsChecked()
def OnCallTipsShow(self, event): def OnCallTipsShow(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_FindFocus()
win.autoCallTip = event.IsChecked() win.autoCallTip = event.IsChecked()
def OnWrap(self, event): def OnWrap(self, event):
win = wx.Window_FindFocus() win = wx.wxWindow_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.Window_FindFocus() win = wx.wxWindow_FindFocus()
id = event.GetId() id = event.GetId()
event.Enable(True) event.Enable(True)
try: try:
@@ -300,23 +300,17 @@ class Frame(wx.Frame):
elif id == ID_OPEN: elif id == ID_OPEN:
event.Enable(hasattr(self, 'bufferOpen')) event.Enable(hasattr(self, 'bufferOpen'))
elif id == ID_REVERT: elif id == ID_REVERT:
event.Enable(hasattr(self, 'bufferRevert') event.Enable(hasattr(self, 'bufferRevert') and self.hasBuffer())
and self.hasBuffer())
elif id == ID_CLOSE: elif id == ID_CLOSE:
event.Enable(hasattr(self, 'bufferClose') event.Enable(hasattr(self, 'bufferClose') and self.hasBuffer())
and self.hasBuffer())
elif id == ID_SAVE: elif id == ID_SAVE:
event.Enable(hasattr(self, 'bufferSave') event.Enable(hasattr(self, 'bufferSave') and self.bufferHasChanged())
and self.bufferHasChanged())
elif id == ID_SAVEAS: elif id == ID_SAVEAS:
event.Enable(hasattr(self, 'bufferSaveAs') event.Enable(hasattr(self, 'bufferSaveAs') and self.hasBuffer())
and self.hasBuffer())
elif id == ID_NAMESPACE: elif id == ID_NAMESPACE:
event.Enable(hasattr(self, 'updateNamespace') event.Enable(hasattr(self, 'updateNamespace') and self.hasBuffer())
and self.hasBuffer())
elif id == ID_PRINT: elif id == ID_PRINT:
event.Enable(hasattr(self, 'bufferPrint') event.Enable(hasattr(self, 'bufferPrint') and self.hasBuffer())
and self.hasBuffer())
elif id == ID_UNDO: elif id == ID_UNDO:
event.Enable(win.CanUndo()) event.Enable(win.CanUndo())
elif id == ID_REDO: elif id == ID_REDO:

View File

@@ -1,26 +1,12 @@
"""Support for icons.""" #----------------------------------------------------------------------
# This file was generated by ../scripts/img2py
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" #
__cvsid__ = "$Id$" from wxPython.wx import wxImageFromStream, wxBitmapFromImage
__revision__ = "$Revision$"[11:-2] from wxPython.wx import wxEmptyIcon
import wx
import cStringIO import cStringIO
def getPyIcon(): def getPyCrustData():
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\
@@ -70,3 +56,16 @@ 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,4 +1,4 @@
"""Interpreter executes Python commands.""" """PyCrust Interpreter executes Python commands."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>" __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$" __cvsid__ = "$Id$"
@@ -18,7 +18,7 @@ except NameError:
class Interpreter(InteractiveInterpreter): class Interpreter(InteractiveInterpreter):
"""Interpreter based on code.InteractiveInterpreter.""" """PyCrust Interpreter based on code.InteractiveInterpreter."""
revision = __revision__ revision = __revision__
@@ -112,7 +112,7 @@ class Interpreter(InteractiveInterpreter):
class InterpreterAlaCarte(Interpreter): class InterpreterAlaCarte(Interpreter):
"""Demo Interpreter.""" """PyCrustAlaCarte Demo Interpreter."""
def __init__(self, locals, rawin, stdin, stdout, stderr, def __init__(self, locals, rawin, stdin, stdout, stderr,
ps1='main prompt', ps2='continuation prompt'): ps1='main prompt', ps2='continuation prompt'):

View File

@@ -174,10 +174,7 @@ def getCallTip(command='', locals=None):
tip1 = name + argspec tip1 = name + argspec
doc = '' doc = ''
if callable(object): if callable(object):
try: doc = inspect.getdoc(object)
doc = inspect.getdoc(object)
except:
pass
if doc: if doc:
# tip2 is the first separated line of the docstring, like: # tip2 is the first separated line of the docstring, like:
# "Return call tip text for a command." # "Return call tip text for a command."

View File

@@ -1,6 +1,8 @@
"""Shell is an interactive text control in which a user types in """The PyCrust Shell is an interactive text control in which a user
commands to be sent to the interpreter. This particular shell is types in commands to be sent to the interpreter. This particular shell
based on wxPython's wxStyledTextCtrl. is based on wxPython's wxStyledTextCtrl. The latest files are always
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."""
@@ -11,8 +13,6 @@ __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 shell component.""" """Frame containing the PyCrust shell component."""
name = 'Shell Frame' name = 'PyCrust 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.DefaultPosition, size=wx.DefaultSize, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize,
style=wx.DEFAULT_FRAME_STYLE, locals=None, style=wx.wxDEFAULT_FRAME_STYLE, locals=None,
InterpClass=None, *args, **kwds): InterpClass=None, *args, **kwds):
"""Create ShellFrame instance.""" """Create a PyCrust ShellFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style) frame.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyShell %s - The Flakiest Python Shell' % VERSION intro = 'PyCrust %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_STRING + \ 'wxPython Version: %s\n' % wx.__version__ + \
'Platform: %s\n' % sys.platform 'Platform: %s\n' % sys.platform
dialog = wx.MessageDialog(self, text, title, dialog = wx.wxMessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION) wx.wxOK | wx.wxICON_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 = 'Shell Interface' name = 'PyCrust 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):
"""Shell based on StyledTextCtrl.""" """PyCrust Shell based on StyledTextCtrl."""
name = 'Shell' name = 'PyCrust Shell'
revision = __revision__ revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.DefaultSize, style=wx.CLIP_CHILDREN, size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN,
introText='', locals=None, InterpClass=None, *args, **kwds): introText='', locals=None, InterpClass=None, *args, **kwds):
"""Create Shell instance.""" """Create a PyCrust 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.CallAfter(self.ScrollToLine, 0) wx.wxCallAfter(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 Py.""" """Display information about PyCrust."""
text = """ text = """
Author: %r Author: %r
Py Version: %s PyCrust Version: %s
Py Shell Revision: %s Shell Revision: %s
Py Interpreter Revision: %s 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_STRING, sys.platform) sys.version.split()[0], wx.__version__, 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.BusyCursor() busy = wx.wxBusyCursor()
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.YieldIfNeeded() wx.wxYieldIfNeeded()
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.TextEntryDialog(None, prompt, dialog = wx.wxTextEntryDialog(None, prompt,
'Input Dialog (Raw)', '') 'Input Dialog (Raw)', '')
try: try:
if dialog.ShowModal() == wx.ID_OK: if dialog.ShowModal() == wx.wxID_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.TextDataObject(command) data = wx.wxTextDataObject(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.TextDataObject(command) data = wx.wxTextDataObject(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.TextDataObject(command) data = wx.wxTextDataObject(command)
self._clip(data) self._clip(data)
def _clip(self, data): def _clip(self, data):
if wx.TheClipboard.Open(): if wx.wxTheClipboard.Open():
wx.TheClipboard.UsePrimarySelection(False) wx.wxTheClipboard.UsePrimarySelection(False)
wx.TheClipboard.SetData(data) wx.wxTheClipboard.SetData(data)
wx.TheClipboard.Flush() wx.wxTheClipboard.Flush()
wx.TheClipboard.Close() wx.wxTheClipboard.Close()
def Paste(self): def Paste(self):
"""Replace selection with clipboard contents.""" """Replace selection with clipboard contents."""
if self.CanPaste() and wx.TheClipboard.Open(): if self.CanPaste() and wx.wxTheClipboard.Open():
ps2 = str(sys.ps2) ps2 = str(sys.ps2)
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)): if wx.wxTheClipboard.IsSupported(wx.wxDataFormat(wx.wxDF_TEXT)):
data = wx.TextDataObject() data = wx.wxTextDataObject()
if wx.TheClipboard.GetData(data): if wx.wxTheClipboard.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.TheClipboard.Close() wx.wxTheClipboard.Close()
def PasteAndRun(self): def PasteAndRun(self):
"""Replace selection with clipboard contents, run commands.""" """Replace selection with clipboard contents, run commands."""
if wx.TheClipboard.Open(): if wx.wxTheClipboard.Open():
ps1 = str(sys.ps1) ps1 = str(sys.ps1)
ps2 = str(sys.ps2) ps2 = str(sys.ps2)
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)): if wx.wxTheClipboard.IsSupported(wx.wxDataFormat(wx.wxDF_TEXT)):
data = wx.TextDataObject() data = wx.wxTextDataObject()
if wx.TheClipboard.GetData(data): if wx.wxTheClipboard.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.TheClipboard.Close() wx.wxTheClipboard.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.' return 'Wrapping is not available in this version of PyCrust.'
def zoom(self, points=0): def zoom(self, points=0):
"""Set the zoom level. """Set the zoom level.

View File

@@ -1,9 +1,11 @@
"""Provides an object representing the current 'version' or 'release' """Provides an object representing the current 'version' or 'release'
of Py as a whole. Individual classes, such as the shell, filling and of PyCrust as a whole. Individual classes, such as the shell, filling
interpreter, each have a revision property based on the CVS Revision.""" and interpreter, each have a revision property based on the CVS
Revision."""
__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]
VERSION = '0.9.3' VERSION = '0.9.1'

View File

@@ -503,19 +503,6 @@ class GenericDirCtrl(Control):
pass pass
class DirFilterListCtrl(Choice):
""""""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
""""""
pass
def FillFilterList(filter, defaultFilter):
""""""
pass
class ListBox(ControlWithItems): class ListBox(ControlWithItems):
"""""" """"""

View File

@@ -788,14 +788,7 @@ def EVT_WINDOW_CREATE(win, func):
"""""" """"""
pass pass
def EVT_WINDOW_CREATE_ID(win, id, func):
""""""
pass
def EVT_WINDOW_DESTROY(win, func): def EVT_WINDOW_DESTROY(win, func):
"""""" """"""
pass pass
def EVT_WINDOW_DESTROY_ID(win, id, func):
""""""
pass

View File

@@ -1,133 +0,0 @@
"""API generator for decorator classes.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import inspect
import os
import sys
import types
header = '''\
"""wxPython decorator classes.
This file is automatically generated, and these are not the real
wxPython classes. These are Python versions for API documentation
purposes only.
Please send corrections, questions, and suggestions to:
Patrick K. O'Brien <pobrien@orbtech.com>
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
from wxd import Parameters as wx
try:
True
except NameError:
True = 1==1
False = 1==0
'''
modlist = [
'Base',
'Window',
'Frames',
'Accelerators',
'App',
'ClipDragDrop',
'Config',
'Controls',
'DataStructures',
'DateTime',
'Dialogs',
'Drawing',
'Errors',
'EventFunctions',
'Events',
'FileSystem',
'Functions',
'Help',
'ImageHandlers',
'Joystick',
'LayoutConstraints',
'Logging',
'Menus',
'MimeTypes',
'Misc',
'Panel',
'Printing',
'Process',
'SashSplitter',
'Sizers',
'Streams',
'Threading',
'ToolBar',
'Tree',
'Validators',
]
dir = os.path.realpath('api/wx/')
filename = os.path.join(dir, '__init__.py')
def main():
modules = {}
f = file(filename, 'w')
f.write(header)
for modname in modlist:
modules[modname] = __import__(modname, globals())
for modname in modlist:
module = modules[modname]
try:
source = inspect.getsource(module)
except IOError:
print 'No source for', module
else:
# Remove everything up to the first class or function definition.
splitter = '\n\nclass '
parts = source.split(splitter, 1)
if len(parts) == 2:
source = splitter + parts[1]
else:
splitter = '\n\ndef '
parts = source.split(splitter, 1)
if len(parts) == 2:
source = splitter + parts[1]
source = '\n\n\n' + source.strip()
f.write(source)
print 'Writing', modname
f.write('\n')
f.close()
# Add constants and any other missing stuff.
f = file(filename, 'a')
f.write('\n\n## Other Stuff:\n\n')
import wx as old
old = old.__dict__
sys.path.insert(0, dir) # Munge the sys.path so that we can
import __init__ # import the file we just created.
new = __init__.__dict__
l = [(k, v) for (k, v) in old.items() if (not k.startswith('_')
and not k.endswith('Ptr')
and not (k == 'cvar'))]
l.sort()
from wxPython import wx
for key, value in l:
if key not in new:
if (inspect.isclass(value)
or inspect.isroutine(value)
or type(value) is types.InstanceType):
value = repr(value)
text = '%s = %r' % (key, value)
f.write(text + '\n')
print 'Writing', text
f.close()
if __name__ == '__main__':
main()