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)
-----------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,6 +4,8 @@ __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
from wxPython import wx
from interpreter import Interpreter
import imp
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>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
from wxPython import wx
import os
import pprint
import sys
import dispatcher
import editwindow
from filling import Filling
import frame
from shell import Shell
@@ -24,26 +22,26 @@ except NameError:
False = 1==0
class Crust(wx.SplitterWindow):
"""Crust based on SplitterWindow."""
class Crust(wx.wxSplitterWindow):
"""PyCrust Crust based on wxSplitterWindow."""
name = 'Crust'
name = 'PyCrust Crust'
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D,
def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition,
size=wx.wxDefaultSize, style=wx.wxSP_3D,
name='Crust Window', rootObject=None, rootLabel=None,
rootIsNamespace=True, intro='', locals=None,
InterpClass=None, *args, **kwds):
"""Create Crust instance."""
wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
"""Create a PyCrust Crust instance."""
wx.wxSplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.shell = Shell(parent=self, introText=intro,
locals=locals, InterpClass=InterpClass,
*args, **kwds)
self.editor = self.shell
if rootObject is None:
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.filling = Filling(parent=self.notebook,
rootObject=rootObject,
@@ -52,10 +50,6 @@ class Crust(wx.SplitterWindow):
# Add 'filling' to the interpreter's locals.
self.shell.interp.locals['filling'] = self.filling
self.notebook.AddPage(page=self.filling, text='Namespace', select=True)
self.display = Display(parent=self.notebook)
self.notebook.AddPage(page=self.display, text='Display')
# Add 'pp' (pretty print) to the interpreter's locals.
self.shell.interp.locals['pp'] = self.display.setItem
self.calltip = Calltip(parent=self.notebook)
self.notebook.AddPage(page=self.calltip, text='Calltip')
self.sessionlisting = SessionListing(parent=self.notebook)
@@ -80,46 +74,13 @@ class Crust(wx.SplitterWindow):
self.SetMinimumPaneSize(1)
class Display(editwindow.EditWindow):
"""STC used to display an object using Pretty Print."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER,
static=False):
"""Create Display instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
# Configure various defaults and user preferences.
self.SetReadOnly(True)
self.SetWrapMode(False)
if not static:
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
self.Refresh()
def Refresh(self):
if not hasattr(self, "item"):
return
self.SetReadOnly(False)
text = pprint.pformat(self.item)
self.SetText(text)
self.SetReadOnly(True)
def setItem(self, item):
"""Set item to pretty print in the notebook Display tab."""
self.item = item
self.Refresh()
class Calltip(wx.TextCtrl):
class Calltip(wx.wxTextCtrl):
"""Text control containing the most recent shell calltip."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.Colour(255, 255, 232))
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | wx.wxTE_RICH2
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.wxColour(255, 255, 232))
dispatcher.connect(receiver=self.display, signal='Shell.calltip')
def display(self, calltip):
@@ -127,13 +88,13 @@ class Calltip(wx.TextCtrl):
self.SetValue(calltip)
class SessionListing(wx.TextCtrl):
class SessionListing(wx.wxTextCtrl):
"""Text control containing all commands for session."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \
wx.wxTE_RICH2 | wx.wxTE_DONTWRAP
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
@@ -146,13 +107,13 @@ class SessionListing(wx.TextCtrl):
self.AppendText(command + '\n')
class DispatcherListing(wx.TextCtrl):
class DispatcherListing(wx.wxTextCtrl):
"""Text control containing all dispatches for session."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \
wx.wxTE_RICH2 | wx.wxTE_DONTWRAP
wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.spy)
def spy(self, signal, sender):
@@ -168,15 +129,15 @@ class DispatcherListing(wx.TextCtrl):
class CrustFrame(frame.Frame):
"""Frame containing all the PyCrust components."""
name = 'CrustFrame'
name = 'PyCrust Frame'
revision = __revision__
def __init__(self, parent=None, id=-1, title='PyCrust',
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE,
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize,
style=wx.wxDEFAULT_FRAME_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=True,
locals=None, InterpClass=None, *args, **kwds):
"""Create CrustFrame instance."""
"""Create a PyCrust CrustFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION
intro += '\nSponsored by Orbtech - '
@@ -213,9 +174,9 @@ class CrustFrame(frame.Frame):
'Shell Revision: %s\n' % self.shell.revision + \
'Interpreter Revision: %s\n\n' % self.shell.interp.revision + \
'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
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog = wx.wxMessageDialog(self, text, title,
wx.wxOK | wx.wxICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,11 @@
"""Provides an object representing the current 'version' or 'release'
of Py as a whole. Individual classes, such as the shell, filling and
interpreter, each have a revision property based on the CVS Revision."""
of PyCrust as a whole. Individual classes, such as the shell, filling
and interpreter, each have a revision property based on the CVS
Revision."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
VERSION = '0.9.3'
VERSION = '0.9.1'

View File

@@ -503,19 +503,6 @@ class GenericDirCtrl(Control):
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):
""""""

View File

@@ -788,14 +788,7 @@ def EVT_WINDOW_CREATE(win, func):
""""""
pass
def EVT_WINDOW_CREATE_ID(win, id, func):
""""""
pass
def EVT_WINDOW_DESTROY(win, func):
""""""
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()