wxPython 2.0b9, first phase (win32)
Added gobs of stuff, see wxPython/README.txt for details git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@ -1,4 +1,3 @@
|
||||
docs
|
||||
*.zip
|
||||
.cvsignore
|
||||
.emacs.desktop
|
||||
@ -26,6 +25,7 @@ controls2.pyc
|
||||
controls2.pyc
|
||||
controls2.pyo
|
||||
controls2.pyo
|
||||
docs
|
||||
events.py
|
||||
events.py
|
||||
events.pyc
|
||||
@ -44,6 +44,10 @@ gdi.pyc
|
||||
gdi.pyc
|
||||
gdi.pyo
|
||||
gdi.pyo
|
||||
glcanvas.py
|
||||
glcanvas.pyc
|
||||
image.py
|
||||
image.pyc
|
||||
mdi.py
|
||||
mdi.py
|
||||
mdi.pyc
|
||||
@ -67,6 +71,8 @@ utils.py
|
||||
utils.pyc
|
||||
utils.pyc
|
||||
utils.pyo
|
||||
utilsc.ilk
|
||||
utilsc.pyd
|
||||
windows.py
|
||||
windows.py
|
||||
windows.pyc
|
||||
|
@ -59,6 +59,59 @@ Or you can send mail directly to the list using this address:
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b9
|
||||
-------------------
|
||||
Bug fix for ListCtrl in test4.py (Was a missing file... DSM!)
|
||||
|
||||
Bug fix for occassional GPF on Win32 systems upon termination of a
|
||||
wxPython application.
|
||||
|
||||
Added wxListBox.GetSelections returning selections as a Tuple.
|
||||
|
||||
Added a wxTreeItemData that is able to hold any Python object and be
|
||||
associated with items in a wxTreeCtrl. Added test pytree.py to show
|
||||
this feature off.
|
||||
|
||||
Added wxSafeYield function.
|
||||
|
||||
OpenGL Canvas can be optionally compiled in to wxPython.
|
||||
|
||||
Awesome new Demo Framework for showing off wxPython and for learning
|
||||
how it all works.
|
||||
|
||||
The pre-built Win32 version is no longer distributing the wxWindows
|
||||
DLL. It is statically linked with the wxWindows library instead.
|
||||
|
||||
Added a couple missing items from the docs.
|
||||
|
||||
Added wxImage, wxImageHandler, wxPNGHandler, wxJPEGHandler,
|
||||
wxGIFHandler and wxBMPHandler.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b8
|
||||
-------------------
|
||||
Support for using Python threads in wxPython apps.
|
||||
|
||||
Several missing methods from various classes.
|
||||
|
||||
Various bug fixes.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b7
|
||||
-------------------
|
||||
Added DLG_PNT and DLG_SZE convienience methods to wxWindow class.
|
||||
|
||||
Added missing constructor and other methods for wxMenuItem.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b6
|
||||
-------------------
|
||||
Just a quickie update to fix the self-installer to be compatible with
|
||||
Python 1.5.2b2's Registry settings.
|
||||
|
||||
|
||||
What's new in 2.0b5
|
||||
-------------------
|
||||
|
@ -370,6 +370,17 @@
|
||||
+ *
|
||||
+ * -- Revision History
|
||||
+ * $Log$
|
||||
+ * Revision 1.2 1999/04/30 03:28:35 RD
|
||||
+ * wxPython 2.0b9, first phase (win32)
|
||||
+ * Added gobs of stuff, see wxPython/README.txt for details
|
||||
+ *
|
||||
+ * Revision 1.1.4.1 1999/03/27 23:28:59 RD
|
||||
+ *
|
||||
+ * wxPython 2.0b8
|
||||
+ * Python thread support
|
||||
+ * various minor additions
|
||||
+ * various minor fixes
|
||||
+ *
|
||||
+ * Revision 1.1 1998/10/03 05:56:03 RD
|
||||
+ * *** empty log message ***
|
||||
+ *
|
||||
|
5
utils/wxPython/demo/.cvsignore
Normal file
@ -0,0 +1,5 @@
|
||||
*.pyc
|
||||
.emacs.desktop
|
||||
hangman_dict.txt
|
||||
setup.bat
|
||||
tmphtml.txt
|
25
utils/wxPython/demo/ColorPanel.py
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: ColorPanel.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ColoredPanel(wxWindow):
|
||||
def __init__(self, parent, color):
|
||||
wxWindow.__init__(self, parent, -1,
|
||||
wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
|
||||
self.SetBackgroundColour(color)
|
||||
|
||||
#---------------------------------------------------------------------------
|
123
utils/wxPython/demo/DialogUnits.py
Normal file
@ -0,0 +1,123 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: DialogUnits.py
|
||||
# Purpose: A minimal wxPython program that is a bit smarter than test1.
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: A long time ago, in a galaxy far, far away...
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
## import all of the wxPython GUI package
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
## Create a new frame class, derived from the wxPython Frame.
|
||||
class MyFrame(wxFrame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
# First, call the base class' __init__ method to create the frame
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 100))
|
||||
|
||||
# Associate some events with methods of this class
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
|
||||
# Add a panel and some controls to display the size and position
|
||||
panel = wxPanel(self, -1)
|
||||
wxStaticText(panel, -1, "Size:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
|
||||
wxStaticText(panel, -1, "Pos:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 14)), wxDefaultSize)
|
||||
self.sizeCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 4)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
self.posCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 14)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
|
||||
# This method is called automatically when the CLOSE event is
|
||||
# sent to this window
|
||||
def OnCloseWindow(self, event):
|
||||
# tell the window to kill itself
|
||||
self.Destroy()
|
||||
|
||||
|
||||
# This method is called by the System when the window is resized,
|
||||
# because of the association above.
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
|
||||
|
||||
# tell the event system to continue looking for an event handler,
|
||||
# so the default handler will get called.
|
||||
event.Skip()
|
||||
|
||||
# This method is called by the System when the window is moved,
|
||||
# because of the association above.
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Every wxWindows application must have a class derived from wxApp
|
||||
class MyApp(wxApp):
|
||||
|
||||
# wxWindows calls this method to initialize the application
|
||||
def OnInit(self):
|
||||
|
||||
# Create an instance of our customized Frame class
|
||||
frame = MyFrame(NULL, -1, "This is a test")
|
||||
frame.Show(true)
|
||||
|
||||
# Tell wxWindows that this is our main window
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
# Return a success flag
|
||||
return true
|
||||
|
||||
|
||||
app = MyApp(0) # Create an instance of the application class
|
||||
app.MainLoop() # Tell it to start processing events
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyFrame(frame, -1, "This is a test")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
overview = """\
|
||||
A simple example that shows how to use Dialog Units.
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
62
utils/wxPython/demo/Layoutf.py
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.layoutf import Layoutf
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestLayoutf(wxPanel):
|
||||
def __init__(self, parent):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.SetAutoLayout(true)
|
||||
EVT_BUTTON(self, 100, self.OnButton)
|
||||
|
||||
self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelA.SetBackgroundColour(wxBLUE)
|
||||
self.panelA.SetConstraints(Layoutf('t=t10#1;l=l10#1;b=b10#1;r%r50#1',(self,)))
|
||||
|
||||
self.panelB = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelB.SetBackgroundColour(wxRED)
|
||||
self.panelB.SetConstraints(Layoutf('t=t10#1;r=r10#1;b%b30#1;l>10#2', (self,self.panelA)))
|
||||
|
||||
self.panelC = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelC.SetBackgroundColour(wxWHITE)
|
||||
self.panelC.SetConstraints(Layoutf('t_10#3;r=r10#1;b=b10#1;l>10#2', (self,self.panelA,self.panelB)))
|
||||
|
||||
b = wxButton(self.panelA, 100, ' Panel A ')
|
||||
b.SetConstraints(Layoutf('X=X#1;Y=Y#1;h*;w%w50#1', (self.panelA,)))
|
||||
|
||||
b = wxButton(self.panelB, 100, ' Panel B ')
|
||||
b.SetConstraints(Layoutf('t=t2#1;r=r4#1;h*;w*', (self.panelB,)))
|
||||
|
||||
self.panelD = wxWindow(self.panelC, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelD.SetBackgroundColour(wxGREEN)
|
||||
self.panelD.SetConstraints(Layoutf('b%h50#1;r%w50#1;h=h#2;w=w#2', (self.panelC, b)))
|
||||
|
||||
b = wxButton(self.panelC, 100, ' Panel C ')
|
||||
b.SetConstraints(Layoutf('t_#1;l>#1;h*;w*', (self.panelD,)))
|
||||
|
||||
wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
|
||||
|
||||
def OnButton(self, event):
|
||||
wxBell()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestLayoutf(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = Layoutf.__doc__
|
319
utils/wxPython/demo/Main.py
Normal file
@ -0,0 +1,319 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: Main.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1999 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
import sys, os
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
_treeList = [
|
||||
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),
|
||||
|
||||
('Miscellaneous Windows', ['wxGrid', 'wxSashWindow',
|
||||
'wxScrolledWindow', 'wxSplitterWindow',
|
||||
'wxStatusBar', 'wxToolBar', 'wxNotebook']),
|
||||
|
||||
('Common Dialogs', ['wxColourDialog', 'wxDirDialog', 'wxFileDialog',
|
||||
'wxSingleChoiceDialog', 'wxTextEntryDialog',
|
||||
'wxFontDialog', 'wxPageSetupDialog', 'wxPrintDialog',
|
||||
'wxMessageDialog']),
|
||||
|
||||
('Controls', ['wxButton', 'wxCheckBox', 'wxCheckListBox', 'wxChoice',
|
||||
'wxComboBox', 'wxGauge', 'wxListBox', 'wxListCtrl', 'wxTextCtrl',
|
||||
'wxTreeCtrl', 'wxSpinButton', 'wxStaticText', 'wxStaticBitmap',
|
||||
'wxRadioBox', 'wxSlider']),
|
||||
|
||||
('Window Layout', ['wxLayoutConstraints']),
|
||||
|
||||
('Micellaneous', ['wxTimer', 'wxGLCanvas', 'DialogUnits', 'wxImage']),
|
||||
|
||||
('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',
|
||||
'wxMultipleChoiceDialog', 'wxPlotCanvas']),
|
||||
|
||||
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot']),
|
||||
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class wxPythonDemo(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, -1, title,
|
||||
wxDefaultPosition, wxSize(700, 550))
|
||||
if wxPlatform == '__WXMSW__':
|
||||
self.icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
|
||||
self.SetIcon(self.icon)
|
||||
|
||||
self.otherWin = None
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.Centre(wxBOTH)
|
||||
self.CreateStatusBar(1, wxST_SIZEGRIP)
|
||||
splitter = wxSplitterWindow(self, -1)
|
||||
splitter2 = wxSplitterWindow(splitter, -1)
|
||||
|
||||
# Prevent TreeCtrl from displaying all items after destruction
|
||||
self.dying = false
|
||||
|
||||
# Make a File menu
|
||||
self.mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'E&xit', 'Get the heck outta here!')
|
||||
EVT_MENU(self, mID, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Help menu
|
||||
mID = NewId()
|
||||
menu = wxMenu()
|
||||
menu.Append(mID, '&About', 'wxPython RULES!!!')
|
||||
EVT_MENU(self, mID, self.OnHelpAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
# Create a TreeCtrl
|
||||
tID = NewId()
|
||||
self.tree = wxTreeCtrl(splitter, tID)
|
||||
root = self.tree.AddRoot("Overview")
|
||||
for item in _treeList:
|
||||
child = self.tree.AppendItem(root, item[0])
|
||||
for childItem in item[1]:
|
||||
self.tree.AppendItem(child, childItem)
|
||||
self.tree.Expand(root)
|
||||
EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
||||
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wxNotebook(splitter2, -1)
|
||||
|
||||
# Set up a TextCtrl on the Overview Notebook page
|
||||
self.ovr = wxTextCtrl(self.nb, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY)
|
||||
self.nb.AddPage(self.ovr, "Overview")
|
||||
|
||||
|
||||
# Set up a TextCtrl on the Demo Code Notebook page
|
||||
self.txt = wxTextCtrl(self.nb, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
self.nb.AddPage(self.txt, "Demo Code")
|
||||
|
||||
|
||||
# select initial items
|
||||
self.nb.SetSelection(0)
|
||||
self.tree.SelectItem(root)
|
||||
|
||||
# Set up a log on the View Log Notebook page
|
||||
self.log = wxTextCtrl(splitter2, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
(w, self.charHeight) = self.log.GetTextExtent('X')
|
||||
self.WriteText('wxPython Demo Log:\n')
|
||||
|
||||
|
||||
# add the windows to the splitter and split it.
|
||||
splitter.SplitVertically(self.tree, splitter2)
|
||||
splitter.SetSashPosition(180, true)
|
||||
splitter.SetMinimumPaneSize(20)
|
||||
|
||||
splitter2.SplitHorizontally(self.nb, self.log)
|
||||
splitter2.SetSashPosition(360, true)
|
||||
splitter2.SetMinimumPaneSize(20)
|
||||
|
||||
# make our log window be stdout
|
||||
sys.stdout = self
|
||||
|
||||
#---------------------------------------------
|
||||
def WriteText(self, text):
|
||||
self.log.WriteText(text)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
w, h = self.log.GetClientSizeTuple()
|
||||
numLines = h/self.charHeight
|
||||
x, y = self.log.PositionToXY(self.log.GetLastPosition())
|
||||
self.log.ShowPosition(self.log.XYToPosition(x, y-numLines+1))
|
||||
|
||||
def write(self, txt):
|
||||
self.WriteText(txt)
|
||||
|
||||
#---------------------------------------------
|
||||
def OnItemExpanded(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------
|
||||
def OnItemCollapsed(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------
|
||||
def OnSelChanged(self, event):
|
||||
if self.dying:
|
||||
return
|
||||
|
||||
if self.nb.GetPageCount() == 3:
|
||||
if self.nb.GetSelection() == 2:
|
||||
self.nb.SetSelection(0)
|
||||
self.nb.DeletePage(2)
|
||||
|
||||
item = event.GetItem()
|
||||
itemText = self.tree.GetItemText(item)
|
||||
|
||||
if itemText == 'Overview':
|
||||
self.GetDemoFile('Main.py')
|
||||
self.SetOverview('Overview', overview)
|
||||
#self.nb.ResizeChildren();
|
||||
self.nb.Refresh();
|
||||
#wxYield()
|
||||
|
||||
else:
|
||||
if os.path.exists(itemText + '.py'):
|
||||
self.GetDemoFile(itemText + '.py')
|
||||
module = __import__(itemText, globals())
|
||||
self.SetOverview(itemText, module.overview)
|
||||
|
||||
# in case runTest is modal, make sure things look right...
|
||||
self.nb.Refresh();
|
||||
wxYield()
|
||||
|
||||
window = module.runTest(self, self.nb, self)
|
||||
if window:
|
||||
self.nb.AddPage(window, 'Demo')
|
||||
self.nb.SetSelection(2)
|
||||
self.nb.ResizeChildren();
|
||||
|
||||
else:
|
||||
self.ovr.Clear()
|
||||
self.txt.Clear()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
# Get the Demo files
|
||||
def GetDemoFile(self, filename):
|
||||
self.txt.Clear()
|
||||
if not self.txt.LoadFile(filename):
|
||||
self.txt.WriteText("Cannot open %s file." % filename)
|
||||
|
||||
self.txt.SetInsertionPoint(0)
|
||||
self.txt.ShowPosition(0)
|
||||
|
||||
#---------------------------------------------
|
||||
def SetOverview(self, name, text):
|
||||
self.ovr.Clear()
|
||||
self.ovr.WriteText(text)
|
||||
self.nb.SetPageText(0, name)
|
||||
self.ovr.SetInsertionPoint(0)
|
||||
self.ovr.ShowPosition(0)
|
||||
|
||||
#---------------------------------------------
|
||||
# Menu methods
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = wxMessageDialog(self,
|
||||
"wxPython is a Python extension module that\n"
|
||||
"encapsulates the wxWindows GUI classes.\n\n"
|
||||
"This demo shows off some of the capabilities\n"
|
||||
"of wxPython.\n\n"
|
||||
" Developed by Robin Dunn",
|
||||
"About wxPython", wxOK)
|
||||
about.ShowModal()
|
||||
about.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnCloseWindow(self, event):
|
||||
self.dying = true
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnIdle(self, event):
|
||||
if self.otherWin:
|
||||
self.otherWin.Raise()
|
||||
self.otherWin = None
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
frame = wxPythonDemo(NULL, -1, "wxPython: (A Demonstration)")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def main():
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
Python
|
||||
------------
|
||||
|
||||
Python is an interpreted, interactive, object-oriented programming language often compared to Tcl, Perl, Scheme, or Java.
|
||||
|
||||
Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, and new built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface.
|
||||
|
||||
wxWindows
|
||||
--------------------
|
||||
|
||||
wxWindows is a free C++ framework designed to make cross-platform programming child's play. Well, almost. wxWindows 2 supports Windows 3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version underway. Other ports are under consideration.
|
||||
|
||||
wxWindows is a set of libraries that allows C++ applications to compile and run on several different types of computers, with minimal source code changes. There is one library per supported GUI (such as Motif, or Windows). As well as providing a common API (Application Programming Interface) for GUI functionality, it provides functionality for accessing some commonly-used operating system facilities, such as copying or deleting files. wxWindows is a 'framework' in the sense that it provides a lot of built-in functionality, which the application can use or replace as required, thus saving a great deal of coding effort. Basic data structures such as strings, linked lists and hash tables are also supported.
|
||||
|
||||
wxPython
|
||||
----------------
|
||||
|
||||
wxPython is a Python extension module that encapsulates the wxWindows GUI classes. Currently it is only available for the Win32 and GTK ports of wxWindows, but as soon as the other ports are brought up to the same level as Win32 and GTK, it should be fairly trivial to enable wxPython to be used with the new GUI.
|
||||
|
||||
The wxPython extension module attempts to mirror the class heiarchy of wxWindows as closely as possible. This means that there is a wxFrame class in wxPython that looks, smells, tastes and acts almost the same as the wxFrame class in the C++ version. Unfortunately, because of differences in the languages, wxPython doesn't match wxWindows exactly, but the differences should be easy to absorb because they are natural to Python. For example, some methods that return multiple values via argument pointers in C++ will return a tuple of values in Python.
|
||||
|
||||
There is still much to be done for wxPython, many classes still need to be mirrored. Also, wxWindows is still somewhat of a moving target so it is a bit of an effort just keeping wxPython up to date. On the other hand, there are enough of the core classes completed that useful applications can be written.
|
||||
|
||||
wxPython is close enough to the C++ version that the majority of the wxPython documentation is actually just notes attached to the C++ documents that describe the places where wxPython is different. There is also a series of sample programs included, and a series of documentation pages that assist the programmer in getting started with wxPython.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
7
utils/wxPython/demo/README.txt
Normal file
@ -0,0 +1,7 @@
|
||||
To run the main demo in this directory, execute demo.py. In other
|
||||
words, one of the following commands should do it:
|
||||
|
||||
demo.py
|
||||
python demo.py
|
||||
pythonw demo.py
|
||||
|
378
utils/wxPython/demo/SlashDot.py
Normal file
@ -0,0 +1,378 @@
|
||||
#!/usr/bin/python
|
||||
"""This is SlashDot 1.2
|
||||
|
||||
It's the obligatory Slashdot.org headlines reader that
|
||||
any modern widget set/library must have in order to be taken
|
||||
seriously :-)
|
||||
|
||||
Usage is quite simple; wxSlash attempts to download the
|
||||
'ultramode.txt' file from http://slashdot.org, which
|
||||
contains the headlines in a computer friendly format. It
|
||||
then displays said headlines in a wxWindows list control.
|
||||
|
||||
You can read articles using either Python's html library
|
||||
or an external browser. Uncheck the 'browser->internal' menu
|
||||
item to use the latter option. Use the settings dialog box
|
||||
to set which external browser is started.
|
||||
|
||||
This code is available under the wxWindows license, see
|
||||
elsewhere. If you modify this code, be aware of the fact
|
||||
that slashdot.org's maintainer, CmdrTaco, explicitly asks
|
||||
'ultramode.txt' downloaders not to do this automatically
|
||||
more than twice per hour. If this feature is abused,
|
||||
CmdrTaco may remove the ultramode file completely and that
|
||||
will make a *lot* of people unhappy.
|
||||
|
||||
I want to thank Alex Shnitman whose slashes.pl
|
||||
(Perl/GTK) script gave me the idea for this applet.
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
from httplib import HTTP
|
||||
from htmllib import HTMLParser
|
||||
import os
|
||||
import re
|
||||
import formatter
|
||||
|
||||
class HTMLTextView(wxFrame):
|
||||
def __init__(self, parent, id, title='HTMLTextView', url=None):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(600,400))
|
||||
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(201, '&Open URL...', 'Open URL')
|
||||
EVT_MENU(self, 201, self.OnFileOpen)
|
||||
menu.Append(209, 'E&xit', 'Exit viewer')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.CreateStatusBar(1)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "", wxPyDefaultPosition,
|
||||
wxPyDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
if (url):
|
||||
self.OpenURL(url)
|
||||
|
||||
def logprint(self, x):
|
||||
self.SetStatusText(x)
|
||||
|
||||
def OpenURL(self, url):
|
||||
self.url = url
|
||||
m = re.match('file:(\S+)\s*', url)
|
||||
if m:
|
||||
f = open(m.groups()[0],'r')
|
||||
else:
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = RetrieveAsFile(host,path,self.logprint)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('tmphtml.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
tmp = open('tmphtml.txt', 'r')
|
||||
self.text.SetValue(tmp.read())
|
||||
self.SetTitle(url)
|
||||
self.logprint(url)
|
||||
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter URL to open:", "")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
url = dlg.GetValue()
|
||||
else:
|
||||
url = None
|
||||
if url:
|
||||
self.OpenURL(url)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
def ParseSlashdot(f):
|
||||
art_sep = re.compile('%%\r?\n')
|
||||
line_sep = re.compile('\r?\n')
|
||||
data = f.read()
|
||||
list = art_sep.split(data)
|
||||
art_list = []
|
||||
for i in range(1,len(list)-1):
|
||||
art_list.append(line_sep.split(list[i]))
|
||||
return art_list
|
||||
|
||||
def myprint(x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(host, path='', logprint = myprint):
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
# f = open('/home/harm/ultramode.txt','r')
|
||||
return f
|
||||
|
||||
|
||||
class AppStatusBar(wxStatusBar):
|
||||
def __init__(self, parent):
|
||||
wxStatusBar.__init__(self,parent, -1)
|
||||
self.SetFieldsCount(2)
|
||||
self.SetStatusWidths([-1, 100])
|
||||
self.but = wxButton(self, 1001, "Refresh")
|
||||
EVT_BUTTON(self, 1001, parent.OnViewRefresh)
|
||||
self.OnSize(None)
|
||||
|
||||
def logprint(self,x):
|
||||
self.SetStatusText(x,0)
|
||||
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.but.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.but.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
# This is a simple timer class to start a function after a short delay;
|
||||
class QuickTimer(wxTimer):
|
||||
def __init__(self, func, wait=100):
|
||||
wxTimer.__init__(self)
|
||||
self.callback = func
|
||||
self.Start(wait); # wait .1 second (.001 second doesn't work. why?)
|
||||
def Notify(self):
|
||||
self.Stop();
|
||||
apply(self.callback, ());
|
||||
|
||||
class AppFrame(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(650, 250))
|
||||
|
||||
# if the window manager closes the window:
|
||||
EVT_CLOSE(self, self.OnCloseWindow);
|
||||
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(209, 'E&xit', 'Enough of this already!')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
menu = wxMenu()
|
||||
menu.Append(210, '&Refresh', 'Refresh headlines')
|
||||
EVT_MENU(self, 210, self.OnViewRefresh)
|
||||
menu.Append(211, '&Slashdot Index', 'View Slashdot index')
|
||||
EVT_MENU(self, 211, self.OnViewIndex)
|
||||
menu.Append(212, 'Selected &Article', 'View selected article')
|
||||
EVT_MENU(self, 212, self.OnViewArticle)
|
||||
self.mainmenu.Append(menu, '&View')
|
||||
menu = wxMenu()
|
||||
menu.Append(220, '&Internal', 'Use internal text browser',TRUE)
|
||||
menu.Check(220, true)
|
||||
self.UseInternal = 1;
|
||||
EVT_MENU(self, 220, self.OnBrowserInternal)
|
||||
menu.Append(222, '&Settings...', 'External browser Settings')
|
||||
EVT_MENU(self, 222, self.OnBrowserSettings)
|
||||
self.mainmenu.Append(menu, '&Browser')
|
||||
menu = wxMenu()
|
||||
menu.Append(230, '&About', 'Some documentation');
|
||||
EVT_MENU(self, 230, self.OnAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
if wxPlatform == '__WXGTK__':
|
||||
# I like lynx. Also Netscape 4.5 doesn't react to my cmdline opts
|
||||
self.BrowserSettings = "xterm -e lynx %s &"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
# netscape 4.x likes to hang out here...
|
||||
self.BrowserSettings = '\\progra~1\\Netscape\\Communicator\\Program\\netscape.exe %s'
|
||||
else:
|
||||
# a wild guess...
|
||||
self.BrowserSettings = 'netscape %s'
|
||||
|
||||
# A status bar to tell people what's happening
|
||||
self.sb = AppStatusBar(self)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
self.list = wxListCtrl(self, 1100)
|
||||
self.list.SetSingleStyle(wxLC_REPORT)
|
||||
self.list.InsertColumn(0, 'Subject')
|
||||
self.list.InsertColumn(1, 'Date')
|
||||
self.list.InsertColumn(2, 'Posted by')
|
||||
self.list.InsertColumn(3, 'Comments')
|
||||
self.list.SetColumnWidth(0, 300)
|
||||
self.list.SetColumnWidth(1, 150)
|
||||
self.list.SetColumnWidth(2, 100)
|
||||
self.list.SetColumnWidth(3, 100)
|
||||
|
||||
EVT_LIST_ITEM_SELECTED(self, 1100, self.OnItemSelected)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnLeftDClick)
|
||||
|
||||
self.logprint("Connecting to slashdot... Please wait.")
|
||||
# wxYield doesn't yet work here. That's why we use a timer
|
||||
# to make sure that we see some GUI stuff before the slashdot
|
||||
# file is transfered.
|
||||
self.timer = QuickTimer(self.DoRefresh, 1000)
|
||||
|
||||
def logprint(self, x):
|
||||
self.sb.logprint(x)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def DoRefresh(self):
|
||||
f = RetrieveAsFile('slashdot.org','/ultramode.txt',self.sb.logprint)
|
||||
art_list = ParseSlashdot(f)
|
||||
self.list.DeleteAllItems()
|
||||
self.url = []
|
||||
self.current = -1
|
||||
i = 0;
|
||||
for article in art_list:
|
||||
self.list.InsertStringItem(i, article[0])
|
||||
self.list.SetStringItem(i, 1, article[2])
|
||||
self.list.SetStringItem(i, 2, article[3])
|
||||
self.list.SetStringItem(i, 3, article[6])
|
||||
self.url.append(article[1])
|
||||
i = i + 1
|
||||
self.logprint("File retrieved OK.")
|
||||
|
||||
def OnViewRefresh(self, event):
|
||||
self.logprint("Connecting to slashdot... Please wait.");
|
||||
wxYield()
|
||||
self.DoRefresh()
|
||||
|
||||
def DoViewIndex(self):
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, 'slashdot.org',
|
||||
'http://slashdot.org')
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % ('http://slashdot.org'))
|
||||
#os.system(self.BrowserSettings % ('http://slashdot.org'))
|
||||
wxExecute(self.BrowserSettings % ('http://slashdot.org'))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewIndex(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewIndex()
|
||||
|
||||
def DoViewArticle(self):
|
||||
if self.current<0: return
|
||||
url = self.url[self.current]
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, url, url)
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % (url))
|
||||
os.system(self.BrowserSettings % (url))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewArticle(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
|
||||
def OnBrowserInternal(self, event):
|
||||
if self.mainmenu.Checked(220):
|
||||
self.UseInternal = 1
|
||||
else:
|
||||
self.UseInternal = 0
|
||||
|
||||
def OnBrowserSettings(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter command to view URL.\nUse %s as a placeholder for the URL.", "", self.BrowserSettings);
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.BrowserSettings = dlg.GetValue()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.current = event.m_itemIndex
|
||||
self.logprint("URL: %s" % (self.url[self.current]))
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
# Actually, we should convert x,y to logical coords using
|
||||
# a dc, but only for a wxScrolledWindow widget.
|
||||
# Now wxGTK derives wxListCtrl from wxScrolledWindow,
|
||||
# and wxMSW from wxControl... So that doesn't work.
|
||||
#dc = wxClientDC(self.list)
|
||||
##self.list.PrepareDC(dc)
|
||||
#x = dc.DeviceToLogicalX( event.GetX() )
|
||||
#y = dc.DeviceToLogicalY( event.GetY() )
|
||||
id = self.list.HitTest(wxPoint(x,y))
|
||||
#print "Double click at %d %d" % (x,y), id
|
||||
# Okay, we got a double click. Let's assume it's the current selection
|
||||
wxYield()
|
||||
self.OnViewArticle(event)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == '__main__':
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(NULL, -1, "Slashdot Breaking News")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = AppFrame(NULL, -1, "Slashdot Breaking News")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
BIN
utils/wxPython/demo/bitmaps/copy.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
utils/wxPython/demo/bitmaps/image.bmp
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
utils/wxPython/demo/bitmaps/image.gif
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
utils/wxPython/demo/bitmaps/image.jpg
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
utils/wxPython/demo/bitmaps/image.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
utils/wxPython/demo/bitmaps/mondrian.ico
Normal file
After Width: | Height: | Size: 766 B |
BIN
utils/wxPython/demo/bitmaps/new.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
utils/wxPython/demo/bitmaps/open.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
utils/wxPython/demo/bitmaps/paste.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
utils/wxPython/demo/bitmaps/smiles.bmp
Normal file
After Width: | Height: | Size: 246 B |
BIN
utils/wxPython/demo/bitmaps/smiles.ico
Normal file
After Width: | Height: | Size: 766 B |
BIN
utils/wxPython/demo/bitmaps/test2.bmp
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
utils/wxPython/demo/bitmaps/tog1.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
utils/wxPython/demo/bitmaps/tog2.bmp
Normal file
After Width: | Height: | Size: 238 B |
4
utils/wxPython/demo/demo.py
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/env python
|
||||
|
||||
import Main
|
||||
Main.main()
|
463
utils/wxPython/demo/hangman.py
Normal file
@ -0,0 +1,463 @@
|
||||
"""Hangman.py, a simple wxPython game, inspired by the
|
||||
old bsd game by Ken Arnold.
|
||||
From the original man page:
|
||||
|
||||
In hangman, the computer picks a word from the on-line
|
||||
word list and you must try to guess it. The computer
|
||||
keeps track of which letters have been guessed and how
|
||||
many wrong guesses you have made on the screen in a
|
||||
graphic fashion.
|
||||
|
||||
That says it all, doesn't it?
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
|
||||
|
||||
import random,re,string
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
|
||||
class WordFetcher:
|
||||
builtin_words = ' albatros banana electrometer eggshell'
|
||||
|
||||
def __init__(self, filename, min_length = 5):
|
||||
self.min_length = min_length
|
||||
print "Trying to open file %s" % (filename,)
|
||||
try:
|
||||
f = open(filename, "r")
|
||||
except:
|
||||
print "Couldn't open dictionary file %s, using builtins" % (filename,)
|
||||
self.words = self.builtin_words
|
||||
self.filename = None
|
||||
return
|
||||
self.words = f.read()
|
||||
self.filename = filename
|
||||
print "Got %d bytes." % (len(self.words),)
|
||||
|
||||
def SetMinLength(min_length):
|
||||
self.min_length = min_length
|
||||
|
||||
def Get(self):
|
||||
reg = re.compile('\s+([a-zA-Z]+)\s+')
|
||||
n = 50 # safety valve; maximum number of tries to find a suitable word
|
||||
while n:
|
||||
index = int(random.random()*len(self.words))
|
||||
m = reg.search(self.words[index:])
|
||||
if m and len(m.groups()[0]) >= self.min_length: break
|
||||
n = n - 1
|
||||
if n: return string.lower(m.groups()[0])
|
||||
return "error"
|
||||
|
||||
|
||||
|
||||
def stdprint(x):
|
||||
print x
|
||||
|
||||
|
||||
|
||||
class URLWordFetcher(WordFetcher):
|
||||
def __init__(self, url):
|
||||
self.OpenURL(url)
|
||||
WordFetcher.__init__(self, "hangman_dict.txt")
|
||||
|
||||
def logprint(self,x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(self, host, path=''):
|
||||
from httplib import HTTP
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
self.logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
self.logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
return f
|
||||
|
||||
def OpenURL(self,url):
|
||||
from htmllib import HTMLParser
|
||||
import formatter
|
||||
self.url = url
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = self.RetrieveAsFile(host,path)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('hangman_dict.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
|
||||
|
||||
|
||||
class HangmanWnd(wxWindow):
|
||||
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
||||
wxWindow.__init__(self, parent, id, pos, size)
|
||||
self.SetBackgroundColour(wxNamedColour('white'))
|
||||
if wxPlatform == '__WXGTK__':
|
||||
self.font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
else:
|
||||
self.font = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
self.SetFocus()
|
||||
|
||||
def StartGame(self, word):
|
||||
self.word = word
|
||||
self.guess = []
|
||||
self.tries = 0
|
||||
self.misses = 0
|
||||
self.Draw()
|
||||
|
||||
def EndGame(self):
|
||||
self.misses = 7;
|
||||
self.guess = map(chr, range(ord('a'),ord('z')+1))
|
||||
self.Draw()
|
||||
|
||||
def HandleKey(self, key):
|
||||
self.message = ""
|
||||
if self.guess.count(key):
|
||||
self.message = 'Already guessed %s' % (key,)
|
||||
return 0
|
||||
self.guess.append(key)
|
||||
self.guess.sort()
|
||||
self.tries = self.tries+1
|
||||
if not key in self.word:
|
||||
self.misses = self.misses+1
|
||||
if self.misses == 7:
|
||||
self.EndGame()
|
||||
return 1
|
||||
has_won = 1
|
||||
for letter in self.word:
|
||||
if not self.guess.count(letter):
|
||||
has_won = 0
|
||||
break
|
||||
if has_won:
|
||||
self.Draw()
|
||||
return 2
|
||||
self.Draw()
|
||||
return 0
|
||||
|
||||
def Draw(self, dc = None):
|
||||
if not dc:
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.font)
|
||||
dc.Clear()
|
||||
(x,y) = self.GetSizeTuple()
|
||||
x1 = x-200; y1 = 20
|
||||
for letter in self.word:
|
||||
if self.guess.count(letter):
|
||||
dc.DrawText(letter, x1, y1)
|
||||
else:
|
||||
dc.DrawText('.', x1, y1)
|
||||
x1 = x1 + 10
|
||||
x1 = x-200
|
||||
dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
|
||||
guesses = ""
|
||||
for letter in self.guess:
|
||||
guesses = guesses + letter
|
||||
dc.DrawText("guessed:", x1, 70)
|
||||
dc.DrawText(guesses[:13], x1+80, 70)
|
||||
dc.DrawText(guesses[13:], x1+80, 90)
|
||||
dc.SetUserScale(x/1000.0, y/1000.0)
|
||||
self.DrawVictim(dc)
|
||||
|
||||
def DrawVictim(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('black'), 20))
|
||||
dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
|
||||
(720,980), (900,980)])
|
||||
dc.DrawLines([(100,900), (100, 100), (300,100)])
|
||||
dc.DrawLine(100,200,200,100)
|
||||
if ( self.misses == 0 ): return
|
||||
dc.SetPen(wxPen(wxNamedColour('blue'), 10))
|
||||
dc.DrawLine(300,100,300,200)
|
||||
if ( self.misses == 1 ): return
|
||||
dc.DrawEllipse(250,200,100,100)
|
||||
if ( self.misses == 2 ): return
|
||||
dc.DrawLine(300,300,300,600)
|
||||
if ( self.misses == 3) : return
|
||||
dc.DrawLine(300,300,250,550)
|
||||
if ( self.misses == 4) : return
|
||||
dc.DrawLine(300,300,350,550)
|
||||
if ( self.misses == 5) : return
|
||||
dc.DrawLine(300,600,350,850)
|
||||
if ( self.misses == 6) : return
|
||||
dc.DrawLine(300,600,250,850)
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.Draw(dc)
|
||||
|
||||
|
||||
|
||||
class HangmanDemo(HangmanWnd):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
HangmanWnd.__init__(self, parent, id, pos, size)
|
||||
self.StartGame("dummy")
|
||||
self.start_new = 1
|
||||
self.wf = wf
|
||||
self.delay = 500
|
||||
self.timer = self.PlayTimer(self.MakeMove)
|
||||
|
||||
def MakeMove(self):
|
||||
self.timer.Stop()
|
||||
if self.start_new:
|
||||
self.StartGame(self.wf.Get())
|
||||
self.start_new = 0
|
||||
self.left = list('aaaabcdeeeeefghiiiiijklmnnnoooopqrssssttttuuuuvwxyz')
|
||||
else:
|
||||
key = self.left[int(random.random()*len(self.left))]
|
||||
while self.left.count(key): self.left.remove(key)
|
||||
self.start_new = self.HandleKey(key)
|
||||
self.timer.Start(self.delay)
|
||||
|
||||
def Stop(self):
|
||||
self.timer.Stop()
|
||||
|
||||
class PlayTimer(wxTimer):
|
||||
def __init__(self,func):
|
||||
wxTimer.__init__(self)
|
||||
self.func = func
|
||||
self.Start(1000)
|
||||
|
||||
def Notify(self):
|
||||
apply(self.func, ())
|
||||
|
||||
|
||||
|
||||
class HangmanDemoFrame(wxFrame):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
wxFrame.__init__(self, parent, id, "Hangman demo", pos, size)
|
||||
self.demo = HangmanDemo(wf, self, -1, wxDefaultPosition, wxDefaultSize)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.demo.timer.Stop()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class AboutBox(wxDialog):
|
||||
def __init__(self, parent,wf):
|
||||
wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
|
||||
self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
|
||||
self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
|
||||
self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
|
||||
EVT_BUTTON(self, 2001, self.OnOK)
|
||||
|
||||
def OnOK(self, event):
|
||||
self.wnd.Stop()
|
||||
self.EndModal(wxID_OK)
|
||||
|
||||
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, wf):
|
||||
self.wf = wf
|
||||
wxFrame.__init__(self, parent, -1, "hangman", wxDefaultPosition, wxSize(400,300))
|
||||
self.wnd = HangmanWnd(self, -1)
|
||||
menu = wxMenu()
|
||||
menu.Append(1001, "New")
|
||||
menu.Append(1002, "End")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1003, "Reset")
|
||||
menu.Append(1004, "Demo...")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1005, "Exit")
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Game")
|
||||
menu = wxMenu()
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
|
||||
menu.Append(1011, "ASCII File...")
|
||||
urls = [ 'wxPython home', 'http://alldunn.com/wxPython/main.html',
|
||||
'slashdot.org', 'http://slashdot.org/',
|
||||
'cnn.com', 'http://cnn.com',
|
||||
'The New York Times', 'http://www.nytimes.com',
|
||||
'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
|
||||
'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
|
||||
'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
|
||||
urlmenu = wxMenu()
|
||||
for item in range(0,len(urls),2):
|
||||
urlmenu.Append(1020+item/2, urls[item], urls[item+1])
|
||||
urlmenu.Append(1080, 'Other...', 'Enter an URL')
|
||||
menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
|
||||
menu.Append(1013, 'Dump', 'Write contents to stdout')
|
||||
menubar.Append(menu, "Dictionary")
|
||||
self.urls = urls
|
||||
self.urloffset = 1020
|
||||
menu = wxMenu()
|
||||
menu.Append(1090, "About...")
|
||||
menubar.Append(menu, "Help")
|
||||
self.SetMenuBar(menubar)
|
||||
self.CreateStatusBar(2)
|
||||
EVT_MENU(self, 1001, self.OnGameNew)
|
||||
EVT_MENU(self, 1002, self.OnGameEnd)
|
||||
EVT_MENU(self, 1003, self.OnGameReset)
|
||||
EVT_MENU(self, 1004, self.OnGameDemo)
|
||||
EVT_MENU(self, 1005, self.OnWindowClose)
|
||||
EVT_MENU(self, 1011, self.OnDictFile)
|
||||
EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
|
||||
EVT_MENU(self, 1080, self.OnDictURLSel)
|
||||
EVT_MENU(self, 1013, self.OnDictDump)
|
||||
EVT_MENU(self, 1090, self.OnHelpAbout)
|
||||
EVT_CHAR(self.wnd, self.OnChar)
|
||||
self.OnGameReset()
|
||||
|
||||
def OnGameNew(self, event):
|
||||
word = self.wf.Get()
|
||||
self.in_progress = 1
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.StartGame(word)
|
||||
|
||||
def OnGameEnd(self, event):
|
||||
self.UpdateAverages(0)
|
||||
self.in_progress = 0
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.EndGame()
|
||||
|
||||
def OnGameReset(self, event=None):
|
||||
self.played = 0
|
||||
self.won = 0
|
||||
self.history = []
|
||||
self.average = 0.0
|
||||
self.OnGameNew(None)
|
||||
|
||||
def OnGameDemo(self, event):
|
||||
frame = HangmanDemoFrame(self.wf, self, -1, wxDefaultPosition, self.GetSize())
|
||||
frame.Show(TRUE)
|
||||
|
||||
def OnDictFile(self, event):
|
||||
fd = wxFileDialog(self)
|
||||
if (self.wf.filename):
|
||||
fd.SetFilename(self.wf.filename)
|
||||
if fd.ShowModal() == wxID_OK:
|
||||
file = fd.GetPath()
|
||||
self.wf = WordFetcher(file)
|
||||
|
||||
def OnDictURL(self, event):
|
||||
item = (event.GetId() - self.urloffset)*2
|
||||
print "Trying to open %s at %s" % (self.urls[item], self.urls[item+1])
|
||||
self.wf = URLWordFetcher(self.urls[item+1])
|
||||
|
||||
def OnDictURLSel(self, event):
|
||||
msg = wxTextEntryDialog(self, "Enter the URL of the dictionary document", "Enter URL")
|
||||
if msg.ShowModal() == wxID_OK:
|
||||
url = msg.GetValue()
|
||||
self.wf = URLWordFetcher(url)
|
||||
def OnDictDump(self, event):
|
||||
print self.wf.words
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = AboutBox(self, self.wf)
|
||||
about.ShowModal()
|
||||
about.wnd.Stop() # that damn timer won't stop!
|
||||
|
||||
def UpdateAverages(self, has_won):
|
||||
if has_won:
|
||||
self.won = self.won + 1
|
||||
self.played = self.played+1
|
||||
self.history.append(self.wnd.misses) # ugly
|
||||
total = 0.0
|
||||
for m in self.history:
|
||||
total = total + m
|
||||
self.average = float(total/len(self.history))
|
||||
|
||||
def OnChar(self, event):
|
||||
if not self.in_progress:
|
||||
self.OnGameNew(None)
|
||||
return
|
||||
key = event.KeyCode();
|
||||
if key >= ord('A') and key <= ord('Z'):
|
||||
key = key + ord('a') - ord('A')
|
||||
key = chr(key)
|
||||
if key < 'a' or key > 'z':
|
||||
event.Skip()
|
||||
return
|
||||
res = self.wnd.HandleKey(key)
|
||||
if res == 0:
|
||||
self.SetStatusText(self.wnd.message)
|
||||
elif res == 1:
|
||||
self.UpdateAverages(0)
|
||||
self.SetStatusText("Too bad, you're dead!",0)
|
||||
self.in_progress = 0
|
||||
elif res == 2:
|
||||
self.in_progress = 0
|
||||
self.UpdateAverages(1)
|
||||
self.SetStatusText("Congratulations!",0)
|
||||
if self.played:
|
||||
percent = (100.*self.won)/self.played
|
||||
else:
|
||||
percent = 0.0
|
||||
self.SetStatusText("p %d, w %d (%g %%), av %g" % (self.played,self.won, percent, self.average),1)
|
||||
|
||||
def OnWindowClose(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
if wxPlatform == '__WXGTK__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
frame = MyFrame(NULL, wf)
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXGTK__' or wxPlatform == '__WXMOTIF__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
win = MyFrame(frame, wf)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
211
utils/wxPython/demo/pyTree.py
Normal file
@ -0,0 +1,211 @@
|
||||
"""
|
||||
Hello, and welcome to this test of the wxTreeItemData
|
||||
class.
|
||||
|
||||
The wxTreeItemData class can be used to associate a python
|
||||
object with a wxTreeCtrl item. In this sample, its use is
|
||||
demonstrated via a tree control that shows the contents of a
|
||||
python namespace according to the standard dir()
|
||||
command. Every item in the tree has its label taken from the
|
||||
dir() output, and 'behind it' a reference to the python
|
||||
object is stored in a wxTreeItemData object.
|
||||
|
||||
As you may have guessed by now, this sample automatically
|
||||
displays '__doc__' strings if the selected python object
|
||||
happens to have one. Please expand the pyTree object to
|
||||
learn more about the implementation.
|
||||
|
||||
Version 1.0, April 4 1999.
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
|
||||
P.S. Check out the string module. It's imported in this
|
||||
sample not because it's used, but because it's so
|
||||
beautifully documented...
|
||||
"""
|
||||
|
||||
from wxPython import wx
|
||||
import string # Don't use it, but it's fun expanding :-)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def _getindent(line):
|
||||
"""Returns the indentation level of the given line."""
|
||||
indent = 0
|
||||
for c in line:
|
||||
if c == ' ': indent = indent + 1
|
||||
elif c == '\t': indent = indent + 8
|
||||
else: break
|
||||
return indent
|
||||
|
||||
def _sourcefinder(func):
|
||||
"""Given a func_code object, this function tries to find and return
|
||||
the python source code of the function."""
|
||||
try:
|
||||
f = open(func.co_filename,"r")
|
||||
except:
|
||||
return "(could not open file %s)" % (func.co_filename,)
|
||||
|
||||
for i in range(func.co_firstlineno):
|
||||
line = f.readline()
|
||||
ind = _getindent(line)
|
||||
msg = ""
|
||||
while line:
|
||||
msg = msg + line
|
||||
line = f.readline()
|
||||
# the following should be <= ind, but then we get
|
||||
# confused by multiline docstrings. Using == works most of
|
||||
# the time... but not always!
|
||||
if _getindent(line) == ind: break
|
||||
return msg
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class pyTree(wx.wxTreeCtrl):
|
||||
"""
|
||||
This wxTreeCtrl derivative displays a tree view of a Python namespace.
|
||||
Anything from which the dir() command returns a non-empty list is a branch
|
||||
in this tree.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, id, root):
|
||||
"""
|
||||
Initialize function; because we insert branches into the tree
|
||||
as needed, we use the ITEM_EXPANDING event handler. The
|
||||
ITEM_COLLAPSED handler removes the stuff afterwards. The
|
||||
SEL_CHANGED handler attempts to display interesting
|
||||
information about the selected object.
|
||||
"""
|
||||
wx.wxTreeCtrl.__init__(self, parent, id)
|
||||
self.root = self.AddRoot(str(root), -1, -1, wx.wxTreeItemData(root))
|
||||
if dir(root):
|
||||
self.SetItemHasChildren(self.root, wx.TRUE)
|
||||
wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
|
||||
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
|
||||
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
|
||||
self.output = None
|
||||
|
||||
|
||||
def SetOutput(self, output):
|
||||
"""
|
||||
Set output function (accepts single string). Used to display string
|
||||
representation of the selected object by OnSelChanged.
|
||||
"""
|
||||
self.output = output
|
||||
|
||||
|
||||
def OnItemExpanding(self,event):
|
||||
"""
|
||||
The real workhorse of this class. First we retrieve the object
|
||||
(parent) belonging to the branch that is to be expanded. This
|
||||
is done by calling GetPyData(parent), which is a short-cut for
|
||||
GetPyItemData(parent).Get().
|
||||
|
||||
Then we get the dir() list of that object. For each item in
|
||||
this list, a tree item is created with associated
|
||||
wxTreeItemData referencing the child object. We get this
|
||||
object using child = getattr(parent, item).
|
||||
|
||||
Finally, we check wether the child returns a non-empty dir()
|
||||
list. If so, it is labeled as 'having children', so that it
|
||||
may be expanded. When it actually is expanded, this function
|
||||
will again figure out what the offspring is.
|
||||
"""
|
||||
item = event.GetItem()
|
||||
obj = self.GetPyData( item )
|
||||
lst = dir(obj)
|
||||
for key in lst:
|
||||
new_obj = getattr(obj,key)
|
||||
new_item = self.AppendItem( item, key, -1, -1,
|
||||
wx.wxTreeItemData(new_obj) )
|
||||
if dir(new_obj):
|
||||
self.SetItemHasChildren(new_item, wx.TRUE)
|
||||
|
||||
def OnItemCollapsed(self, event):
|
||||
"""
|
||||
We need to remove all children here, otherwise we'll see all
|
||||
that old rubbish again after the next expansion.
|
||||
"""
|
||||
item = event.GetItem()
|
||||
self.DeleteChildren(item)
|
||||
|
||||
def OnSelChanged(self, event):
|
||||
"""
|
||||
If an output function is defined, we try to print some
|
||||
informative, interesting and thought-provoking stuff to it.
|
||||
If it has a __doc__ string, we print it. If it's a function or
|
||||
unbound class method, we attempt to find the python source.
|
||||
"""
|
||||
if not self.output:
|
||||
return
|
||||
obj = self.GetPyData( event.GetItem() )
|
||||
msg = str(obj)
|
||||
if hasattr(obj, '__doc__'):
|
||||
msg = msg+"\n\nDocumentation string:\n\n%s" % ( getattr(obj, '__doc__'),)
|
||||
# Is it a function?
|
||||
func = None
|
||||
if hasattr(obj, "func_code"): # normal function
|
||||
func = getattr(obj, "func_code")
|
||||
elif hasattr(obj, "im_func"): # unbound class method
|
||||
func = getattr(getattr(obj, "im_func"), "func_code")
|
||||
if func: # if we found one, let's try to print the source
|
||||
msg = msg+"\n\nFunction source:\n\n" + _sourcefinder(func)
|
||||
|
||||
apply(self.output, (msg,))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
"""
|
||||
This method is used by the wxPython Demo Framework for integrating
|
||||
this demo with the rest.
|
||||
"""
|
||||
thisModule = __import__(__name__, globals())
|
||||
win = wx.wxFrame(frame, -1, "PyTreeItemData Test")
|
||||
split = wx.wxSplitterWindow(win, -1)
|
||||
tree = pyTree(split, -1, thisModule)
|
||||
text = wx.wxTextCtrl(split, -1, "", wx.wxDefaultPosition,
|
||||
wx.wxDefaultSize, wx.wxTE_MULTILINE)
|
||||
split.SplitVertically(tree, text, 200)
|
||||
tree.SetOutput(text.SetValue)
|
||||
tree.SelectItem(tree.root)
|
||||
win.SetSize(wx.wxSize(800,500))
|
||||
frame.otherWin = win
|
||||
win.Show(1)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
|
||||
class MyFrame(wx.wxFrame):
|
||||
"""Very standard Frame class. Nothing special here!"""
|
||||
|
||||
def __init__(self):
|
||||
"""Make a splitter window; left a tree, right a textctrl. Wow."""
|
||||
import __main__
|
||||
wx.wxFrame.__init__(self, wx.NULL, -1, "PyTreeItemData Test",
|
||||
wx.wxDefaultPosition, wx.wxSize(800,500))
|
||||
split = wx.wxSplitterWindow(self, -1)
|
||||
tree = pyTree(split, -1, __main__)
|
||||
text = wx.wxTextCtrl(split, -1, "", wx.wxDefaultPosition,
|
||||
wx.wxDefaultSize, wx.wxTE_MULTILINE)
|
||||
split.SplitVertically(tree, text, 200)
|
||||
tree.SetOutput(text.SetValue)
|
||||
tree.SelectItem(tree.root)
|
||||
|
||||
class MyApp(wx.wxApp):
|
||||
"""This class is even less interesting than MyFrame."""
|
||||
|
||||
def OnInit(self):
|
||||
"""OnInit. Boring, boring, boring!"""
|
||||
frame = MyFrame()
|
||||
frame.Show(wx.TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return wx.TRUE
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
47
utils/wxPython/demo/wxButton.py
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
wxButton(self, 10, "Hello", wxPoint(20, 20)).SetDefault()
|
||||
EVT_BUTTON(self, 10, self.OnClick)
|
||||
|
||||
wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(90, 45))
|
||||
EVT_BUTTON(self, 20, self.OnClick)
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
|
||||
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
||||
EVT_BUTTON(self, 30, self.OnClick)
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.WriteText("Click! (%d)\n" % event.GetId())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
80
utils/wxPython/demo/wxCheckBox.py
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestCheckBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckBox control.",
|
||||
wxPoint(10, 10))
|
||||
|
||||
cID = NewId()
|
||||
cb1 = wxCheckBox(self, cID, " Apples", wxPoint(65, 40), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2 = wxCheckBox(self, cID+1, " Oranges", wxPoint(65, 60), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2.SetValue(true)
|
||||
cb3 = wxCheckBox(self, cID+2, " Pears", wxPoint(65, 80), wxSize(150, 20), wxNO_BORDER)
|
||||
|
||||
EVT_CHECKBOX(self, cID, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+1, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+2, self.EvtCheckBox)
|
||||
|
||||
|
||||
def EvtCheckBox(self, event):
|
||||
self.log.WriteText('EvtCheckBox: %d\n' % event.Checked())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestCheckBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).
|
||||
|
||||
wxCheckBox()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")
|
||||
|
||||
Constructor, creating and showing a checkbox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Checkbox identifier. A value of -1 indicates a default value.
|
||||
|
||||
label = Text to be displayed next to the checkbox.
|
||||
|
||||
pos = Checkbox position. If the position (-1, -1) is specified then a default position is chosen.
|
||||
|
||||
size = Checkbox size. If the default size (-1, -1) is specified then a default size is chosen.
|
||||
|
||||
style = Window style. See wxCheckBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
53
utils/wxPython/demo/wxCheckListBox.py
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
||||
'twelve', 'thirteen', 'fourteen']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckListBox control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
lb = wxCheckListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
|
||||
sampleList)
|
||||
EVT_LISTBOX(self, 60, self.EvtListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
|
||||
lb.SetSelection(0)
|
||||
|
||||
|
||||
def EvtListBox(self, event):
|
||||
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
||||
|
||||
def EvtListBoxDClick(self, event):
|
||||
self.log.WriteText('EvtListBoxDClick:\n')
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
76
utils/wxPython/demo/wxChoice.py
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestChoice(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxChoice control.",
|
||||
wxPoint(15, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
|
||||
wxChoice(self, 40, wxPoint(80, 50), wxSize(95, 20), #wxDefaultSize,
|
||||
sampleList)
|
||||
EVT_CHOICE(self, 40, self.EvtChoice)
|
||||
|
||||
def EvtChoice(self, event):
|
||||
self.log.WriteText('EvtChoice: %s\n' % event.GetString())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestChoice(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices.
|
||||
|
||||
wxChoice()
|
||||
-------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxChoice(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "choice")
|
||||
|
||||
Constructor, creating and showing a choice.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the choice is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the choice control.
|
||||
|
||||
choices = An array of strings with which to initialise the choice control.
|
||||
|
||||
style = Window style. See wxChoice.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
38
utils/wxPython/demo/wxColourDialog.py
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxColourData()
|
||||
data.SetChooseFull(true)
|
||||
dlg = wxColourDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetColourData()
|
||||
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the colour chooser dialog.
|
||||
|
||||
wxColourDialog()
|
||||
------------------------------
|
||||
|
||||
wxColourDialog(wxWindow* parent, wxColourData* data = NULL)
|
||||
|
||||
Constructor. Pass a parent window, and optionally a pointer to a block of colour data, which will be copied to the colour dialog's colour data.
|
||||
|
||||
"""
|
79
utils/wxPython/demo/wxComboBox.py
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestComboBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxComboBox control.",
|
||||
wxPoint(8, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
|
||||
wxComboBox(self, 50, "default value", wxPoint(80, 50), wxSize(95, 20),
|
||||
sampleList, wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, 50, self.EvtComboBox)
|
||||
|
||||
|
||||
def EvtComboBox(self, event):
|
||||
self.log.WriteText('EvtComboBox: %s\n' % event.GetString())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestComboBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
|
||||
|
||||
A combobox permits a single selection only. Combobox items are numbered from zero.
|
||||
|
||||
wxComboBox()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxComboBox(wxWindow* parent, wxWindowID id, const wxString& value = "", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "comboBox")
|
||||
|
||||
Constructor, creating and showing a combobox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the control.
|
||||
|
||||
choices = An array of strings with which to initialise the control.
|
||||
|
||||
style = Window style. See wxComboBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
33
utils/wxPython/demo/wxDialog.py
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", wxDefaultPosition, wxSize(350, 200))
|
||||
|
||||
wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20))
|
||||
wxButton(win, wxID_OK, " OK ", wxPoint(75, 120), wxDefaultSize).SetDefault()
|
||||
wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(150, 120), wxDefaultSize)
|
||||
|
||||
val = win.ShowModal()
|
||||
if val == wxID_OK:
|
||||
log.WriteText("You pressed OK\n")
|
||||
else:
|
||||
log.WriteText("You pressed Cancel\n")
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
53
utils/wxPython/demo/wxDirDialog.py
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxDirDialog(frame)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the directory chooser dialog.
|
||||
|
||||
wxDirDialog()
|
||||
------------------------
|
||||
|
||||
wxDirDialog(wxWindow* parent, const wxString& message = "Choose a directory", const wxString& defaultPath = "", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxDirDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultPath = The default path, or the empty string.
|
||||
|
||||
style = A dialog style, currently unused.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
62
utils/wxPython/demo/wxFileDialog.py
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the file chooser dialog.
|
||||
|
||||
wxFileDialog()
|
||||
----------------------------
|
||||
|
||||
wxFileDialog(wxWindow* parent, const wxString& message = "Choose a file", const wxString& defaultDir = ""
|
||||
, const wxString& defaultFile = "", const wxString& wildcard = "*.*", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxFileDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultDir = The default directory, or the empty string.
|
||||
|
||||
defaultFile = The default filename, or the empty string.
|
||||
|
||||
wildcard = A wildcard, such as "*.*".
|
||||
|
||||
style = A dialog style. A bitlist of:
|
||||
|
||||
wxOPEN This is an open dialog (Windows only).
|
||||
|
||||
wxSAVE This is a save dialog (Windows only).
|
||||
|
||||
wxHIDE_READONLY Hide read-only files (Windows only).
|
||||
|
||||
wxOVERWRITE_PROMPT Prompt for a conformation if a file will be overridden (Windows only).
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
39
utils/wxPython/demo/wxFontDialog.py
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFontDialog(frame)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetFontData()
|
||||
font = data.GetChosenFont()
|
||||
log.WriteText('You selected: "%s", %d points, color %s\n' %
|
||||
(font.GetFaceName(), font.GetPointSize(),
|
||||
data.GetColour().Get()))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the font chooser dialog.
|
||||
|
||||
wxFontDialog()
|
||||
----------------------------
|
||||
|
||||
wxFontDialog(wxWindow* parent, wxFontData* data = NULL)
|
||||
|
||||
Constructor. Pass a parent window, and optionally a pointer to a block of font data, which will be copied to the font dialog's font data.
|
||||
"""
|
41
utils/wxPython/demo/wxFrame.py
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, ID, title, pos, size):
|
||||
wxFrame.__init__(self, parent, ID, title, pos, size)
|
||||
panel = wxPanel(self, -1)
|
||||
|
||||
button = wxButton(panel, 1003, "Close Me")
|
||||
button.SetPosition(wxPoint(15, 15))
|
||||
EVT_BUTTON(self, 1003, self.OnCloseMe)
|
||||
|
||||
def OnCloseMe(self, event):
|
||||
self.Close(true)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyFrame(frame, -1, "This is a wxFrame", wxDefaultPosition, wxSize(350, 200))
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
153
utils/wxPython/demo/wxGLCanvas.py
Normal file
@ -0,0 +1,153 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
try:
|
||||
from wxPython.glcanvas import *
|
||||
haveGLCanvas = true
|
||||
except ImportError:
|
||||
haveGLCanvas = false
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveGLCanvas:
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame, 'The wxGLCanvas has not been included with this build of wxPython!',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
else:
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestGLCanvas(nb)
|
||||
return win
|
||||
|
||||
|
||||
|
||||
class TestGLCanvas(wxGLCanvas):
|
||||
def __init__(self, parent):
|
||||
wxGLCanvas.__init__(self, parent, -1)
|
||||
EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
|
||||
self.init = false
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
pass # Do nothing, to avoid flashing.
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
if self.GetContext() != 'NULL':
|
||||
self.SetCurrent()
|
||||
glViewport(0, 0, size.width, size.height)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
|
||||
ctx = self.GetContext()
|
||||
if ctx == "NULL": return
|
||||
|
||||
self.SetCurrent()
|
||||
|
||||
|
||||
if not self.init:
|
||||
self.InitGL()
|
||||
self.init = true
|
||||
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
# draw six faces of a cube
|
||||
glBegin(GL_QUADS)
|
||||
glNormal3f( 0.0, 0.0, 1.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0, 0.0,-1.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
|
||||
glNormal3f( 0.0, 1.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0,-1.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 1.0, 0.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
|
||||
glNormal3f(-1.0, 0.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glEnd()
|
||||
|
||||
self.SwapBuffers()
|
||||
|
||||
|
||||
def InitGL(self):
|
||||
# set viewing projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glTranslatef(0.0, 0.0, -2.0);
|
||||
|
||||
# position object
|
||||
glRotatef(30.0, 1.0, 0.0, 0.0);
|
||||
glRotatef(30.0, 0.0, 1.0, 0.0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def _test():
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = wxFrame(NULL, -1, "HELP ME!!")
|
||||
win = TestGLCanvas(frame)
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
55
utils/wxPython/demo/wxGauge.py
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxGauge control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
#self.g1 = wxGauge(self, -1, 50, wxPoint(40, 50), wxSize(40, 160),
|
||||
# wxGA_VERTICAL)
|
||||
#self.g1.SetBezelFace(3)
|
||||
#self.g1.SetShadowWidth(3)
|
||||
|
||||
self.g2 = wxGauge(self, -1, 50, wxPoint(110, 50), wxSize(250, 25),
|
||||
wxGA_HORIZONTAL)
|
||||
self.g2.SetBezelFace(5)
|
||||
self.g2.SetShadowWidth(5)
|
||||
|
||||
EVT_IDLE(self, self.IdleHandler)
|
||||
|
||||
|
||||
def IdleHandler(self, event):
|
||||
self.count = self.count + 1
|
||||
if self.count >= 50:
|
||||
self.count = 0
|
||||
#self.g1.SetValue(self.count)
|
||||
self.g2.SetValue(self.count)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
77
utils/wxPython/demo/wxGrid.py
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestGrid(wxGrid):
|
||||
def __init__(self, parent, log):
|
||||
wxGrid.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
self.CreateGrid(16, 16)
|
||||
self.SetColumnWidth(3, 200)
|
||||
self.SetRowHeight(4, 45)
|
||||
self.SetCellValue("First cell", 0, 0)
|
||||
self.SetCellValue("Another cell", 1, 1)
|
||||
self.SetCellValue("Yet another cell", 2, 2)
|
||||
self.SetCellTextFont(wxFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0)
|
||||
self.SetCellTextColour(wxRED, 1, 1)
|
||||
self.SetCellBackgroundColour(wxCYAN, 2, 2)
|
||||
self.UpdateDimensions()
|
||||
self.AdjustScrollbars()
|
||||
|
||||
EVT_GRID_SELECT_CELL(self, self.OnSelectCell)
|
||||
EVT_GRID_CELL_CHANGE(self, self.OnCellChange)
|
||||
EVT_GRID_CELL_LCLICK(self, self.OnCellClick)
|
||||
EVT_GRID_LABEL_LCLICK(self, self.OnLabelClick)
|
||||
|
||||
|
||||
|
||||
def OnSelectCell(self, event):
|
||||
self.log.WriteText("OnSelectCell: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnCellChange(self, event):
|
||||
self.log.WriteText("OnCellChange: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnCellClick(self, event):
|
||||
self.log.WriteText("OnCellClick: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnLabelClick(self, event):
|
||||
self.log.WriteText("OnLabelClick: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestGrid(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxGrid is a class for displaying and editing tabular information.
|
||||
|
||||
wxGrid()
|
||||
-----------------
|
||||
|
||||
wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
|
||||
|
||||
Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.
|
||||
"""
|
40
utils/wxPython/demo/wxImage.py
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
bmp = wxImage('bitmaps/image.bmp', wxBITMAP_TYPE_BMP).ConvertToBitmap()
|
||||
gif = wxImage('bitmaps/image.gif', wxBITMAP_TYPE_GIF).ConvertToBitmap()
|
||||
png = wxImage('bitmaps/image.png', wxBITMAP_TYPE_PNG).ConvertToBitmap()
|
||||
jpg = wxImage('bitmaps/image.jpg', wxBITMAP_TYPE_JPEG).ConvertToBitmap()
|
||||
|
||||
panel = wxPanel(nb, -1)
|
||||
pos = 10
|
||||
wxStaticBitmap(panel, -1, bmp, wxPoint(10, pos),
|
||||
wxSize(bmp.GetWidth(), bmp.GetHeight()))
|
||||
|
||||
pos = pos + bmp.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, gif, wxPoint(10, pos),
|
||||
wxSize(gif.GetWidth(), gif.GetHeight()))
|
||||
|
||||
pos = pos + gif.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, png, wxPoint(10, pos),
|
||||
wxSize(png.GetWidth(), png.GetHeight()))
|
||||
|
||||
pos = pos + png.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, jpg, wxPoint(10, pos),
|
||||
wxSize(jpg.GetWidth(), jpg.GetHeight()))
|
||||
|
||||
return panel
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
142
utils/wxPython/demo/wxLayoutConstraints.py
Normal file
@ -0,0 +1,142 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestLayoutConstraints(wxWindow):
|
||||
def __init__(self, parent):
|
||||
wxWindow.__init__(self, parent, -1)
|
||||
self.SetBackgroundColour(wxNamedColour("MEDIUM ORCHID"))
|
||||
|
||||
self.SetAutoLayout(true)
|
||||
EVT_BUTTON(self, 100, self.OnButton)
|
||||
|
||||
self.panelA = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelA.SetBackgroundColour(wxBLUE)
|
||||
txt = wxStaticText(self.panelA, -1,
|
||||
"Resize the window and see\n"
|
||||
"what happens... Notice that\n"
|
||||
"there is no OnSize handler.",
|
||||
wxPoint(5,5), wxSize(-1, 50))
|
||||
txt.SetBackgroundColour(wxBLUE)
|
||||
txt.SetForegroundColour(wxWHITE)
|
||||
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs(self, wxTop, 10)
|
||||
lc.left.SameAs(self, wxLeft, 10)
|
||||
lc.bottom.SameAs(self, wxBottom, 10)
|
||||
lc.right.PercentOf(self, wxRight, 50)
|
||||
self.panelA.SetConstraints(lc)
|
||||
|
||||
self.panelB = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelB.SetBackgroundColour(wxRED)
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs(self, wxTop, 10)
|
||||
lc.right.SameAs(self, wxRight, 10)
|
||||
lc.bottom.PercentOf(self, wxBottom, 30)
|
||||
lc.left.RightOf(self.panelA, 10)
|
||||
self.panelB.SetConstraints(lc)
|
||||
|
||||
self.panelC = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelC.SetBackgroundColour(wxWHITE)
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.Below(self.panelB, 10)
|
||||
lc.right.SameAs(self, wxRight, 10)
|
||||
lc.bottom.SameAs(self, wxBottom, 10)
|
||||
lc.left.RightOf(self.panelA, 10)
|
||||
self.panelC.SetConstraints(lc)
|
||||
|
||||
b = wxButton(self.panelA, 100, ' Panel A ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.centreX.SameAs (self.panelA, wxCentreX)
|
||||
lc.centreY.SameAs (self.panelA, wxCentreY)
|
||||
lc.height.AsIs ()
|
||||
lc.width.PercentOf (self.panelA, wxWidth, 50)
|
||||
b.SetConstraints(lc);
|
||||
|
||||
b = wxButton(self.panelB, 100, ' Panel B ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs (self.panelB, wxTop, 2)
|
||||
lc.right.SameAs (self.panelB, wxRight, 4)
|
||||
lc.height.AsIs ()
|
||||
lc.width.AsIs ()
|
||||
b.SetConstraints(lc);
|
||||
|
||||
self.panelD = wxWindow(self.panelC, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelD.SetBackgroundColour(wxGREEN)
|
||||
wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
|
||||
|
||||
b = wxButton(self.panelC, 100, ' Panel C ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.Below (self.panelD)
|
||||
lc.left.RightOf (self.panelD)
|
||||
lc.height.AsIs ()
|
||||
lc.width.AsIs ()
|
||||
b.SetConstraints(lc);
|
||||
|
||||
lc = wxLayoutConstraints()
|
||||
lc.bottom.PercentOf (self.panelC, wxHeight, 50)
|
||||
lc.right.PercentOf (self.panelC, wxWidth, 50)
|
||||
lc.height.SameAs (b, wxHeight)
|
||||
lc.width.SameAs (b, wxWidth)
|
||||
self.panelD.SetConstraints(lc);
|
||||
|
||||
|
||||
def OnButton(self, event):
|
||||
wxBell()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestLayoutConstraints(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
Objects of this class can be associated with a window to define its layout constraints, with respect to siblings or its parent.
|
||||
|
||||
The class consists of the following eight constraints of class wxIndividualLayoutConstraint, some or all of which should be accessed directly to set the appropriate constraints.
|
||||
|
||||
left: represents the left hand edge of the window
|
||||
|
||||
right: represents the right hand edge of the window
|
||||
|
||||
top: represents the top edge of the window
|
||||
|
||||
bottom: represents the bottom edge of the window
|
||||
|
||||
width: represents the width of the window
|
||||
|
||||
height: represents the height of the window
|
||||
|
||||
centreX: represents the horizontal centre point of the window
|
||||
|
||||
centreY: represents the vertical centre point of the window
|
||||
|
||||
Most constraints are initially set to have the relationship wxUnconstrained, which means that their values should be calculated by looking at known constraints. The exceptions are width and height, which are set to wxAsIs to ensure that if the user does not specify a constraint, the existing width and height will be used, to be compatible with panel items which often have take a default size. If the constraint is wxAsIs, the dimension will not be changed.
|
||||
|
||||
wxLayoutConstraints()
|
||||
-------------------------------------------
|
||||
|
||||
Constructor.
|
||||
"""
|
99
utils/wxPython/demo/wxListBox.py
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestListBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
||||
'twelve', 'thirteen', 'fourteen']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxListBox control.",
|
||||
wxPoint(45, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(65, 18))
|
||||
lb = wxListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
|
||||
sampleList, wxLB_SINGLE)
|
||||
EVT_LISTBOX(self, 60, self.EvtListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
|
||||
lb.SetSelection(0)
|
||||
|
||||
|
||||
wxStaticText(self, -1, "Select many:", wxPoint(200, 50), wxSize(65, 18))
|
||||
self.lb = wxListBox(self, 70, wxPoint(280, 50), wxSize(80, 120),
|
||||
sampleList, wxLB_EXTENDED)
|
||||
EVT_LISTBOX(self, 70, self.EvtMultiListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 70, self.EvtListBoxDClick)
|
||||
self.lb.SetSelection(0)
|
||||
|
||||
|
||||
def EvtListBox(self, event):
|
||||
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
||||
|
||||
def EvtListBoxDClick(self, event):
|
||||
self.log.WriteText('EvtListBoxDClick:\n')
|
||||
|
||||
def EvtMultiListBox(self, event):
|
||||
self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb.GetSelections()))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestListBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections).
|
||||
|
||||
List box elements are numbered from zero.
|
||||
|
||||
wxListBox()
|
||||
---------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listBox")
|
||||
|
||||
Constructor, creating and showing a list box.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the control.
|
||||
|
||||
choices = An array of strings with which to initialise the control.
|
||||
|
||||
style = Window style. See wxListBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
106
utils/wxPython/demo/wxListCtrl.py
Normal file
@ -0,0 +1,106 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: ListCtrl.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestListCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.il = wxImageList(16, 16)
|
||||
idx1 = self.il.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
|
||||
|
||||
self.list = wxListCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT|wxSUNKEN_BORDER)
|
||||
self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
|
||||
|
||||
self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
|
||||
wxToolTip_Enable(true)
|
||||
|
||||
self.list.InsertColumn(0, "Column 0")
|
||||
self.list.InsertColumn(1, "Column 1")
|
||||
self.list.InsertColumn(2, "One More Column (2)")
|
||||
for x in range(50):
|
||||
self.list.InsertImageStringItem(x, "This is item %d" % x, idx1)
|
||||
self.list.SetStringItem(x, 1, "Col 1, item %d" % x)
|
||||
self.list.SetStringItem(x, 2, "item %d in column 2" % x)
|
||||
|
||||
self.list.SetColumnWidth(0, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(1, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(2, wxLIST_AUTOSIZE)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.list.SetDimensions(0, 0, w, h)
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestListCtrlPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
|
||||
|
||||
wxListCtrl()
|
||||
------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
|
||||
|
||||
Constructor, creating and showing a list control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
style = Window style. See wxListCtrl.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
62
utils/wxPython/demo/wxMessageDialog.py
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame, 'Hello from Python and wxPython!',
|
||||
'A Message Box', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxMessageDialog()
|
||||
----------------------------------
|
||||
|
||||
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxMessageDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
caption = The dialog caption.
|
||||
|
||||
style = A dialog style (bitlist) containing flags chosen from the following:
|
||||
|
||||
wxOK Show an OK button.
|
||||
|
||||
wxCANCEL Show a Cancel button.
|
||||
|
||||
wxYES_NO Show Yes and No buttons.
|
||||
|
||||
wxCENTRE Centre the message. Not Windows.
|
||||
|
||||
wxICON_EXCLAMATION Shows an exclamation mark icon. Windows only.
|
||||
|
||||
wxICON_HAND Shows a hand icon. Windows only.
|
||||
|
||||
wxICON_QUESTION Shows a question mark icon. Windows only.
|
||||
|
||||
wxICON_INFORMATION Shows an information (i) icon. Windows only.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
42
utils/wxPython/demo/wxMiniFrame.py
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
class MyMiniFrame(wxMiniFrame):
|
||||
def __init__(self, parent, ID, title, pos, size, style):
|
||||
wxMiniFrame.__init__(self, parent, ID, title, pos, size, style)
|
||||
panel = wxPanel(self, -1)
|
||||
|
||||
button = wxButton(panel, 1003, "Close Me")
|
||||
button.SetPosition(wxPoint(15, 15))
|
||||
EVT_BUTTON(self, 1003, self.OnCloseMe)
|
||||
|
||||
def OnCloseMe(self, event):
|
||||
self.Close(true)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyMiniFrame(frame, -1, "This is a wxMiniFrame",
|
||||
wxDefaultPosition, wxSize(200, 200),
|
||||
wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
27
utils/wxPython/demo/wxMultipleChoiceDialog.py
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.dialogs import wxMultipleChoiceDialog
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
|
||||
'etc', 'etc..', 'etc...' ]
|
||||
dlg = wxMultipleChoiceDialog(frame,
|
||||
"Pick some from\n this list\nblah blah...",
|
||||
"m.s.d.", lst)
|
||||
if (dlg.ShowModal() == wxID_OK):
|
||||
print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
84
utils/wxPython/demo/wxNotebook.py
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import ColorPanel
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
|
||||
testWin = wxNotebook(nb, -1)
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxBLUE)
|
||||
testWin.AddPage(win, "Blue")
|
||||
st = wxStaticText(win, -1,
|
||||
"You can put nearly any type of window here!",
|
||||
wxPoint(10, 10))
|
||||
st.SetForegroundColour(wxWHITE)
|
||||
st.SetBackgroundColour(wxBLUE)
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxRED)
|
||||
testWin.AddPage(win, "Red")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxGREEN)
|
||||
testWin.AddPage(win, "Green")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxCYAN)
|
||||
testWin.AddPage(win, "Cyan")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxWHITE)
|
||||
testWin.AddPage(win, "White")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxBLACK)
|
||||
testWin.AddPage(win, "Black")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxNamedColour('MIDNIGHT BLUE'))
|
||||
testWin.AddPage(win, "MIDNIGHT BLUE")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxNamedColour('INDIAN RED'))
|
||||
testWin.AddPage(win, "INDIAN RED")
|
||||
|
||||
return testWin
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a notebook control, which manages multiple windows with associated tabs.
|
||||
|
||||
To use the class, create a wxNotebook object and call AddPage or InsertPage, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed by wxNotebook.
|
||||
|
||||
wxNotebook()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size, long style = 0, const wxString& name = "notebook")
|
||||
|
||||
Constructs a notebook control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The parent window. Must be non-NULL.
|
||||
|
||||
id = The window identifier.
|
||||
|
||||
pos = The window position.
|
||||
|
||||
size = The window size.
|
||||
|
||||
style = The window style. Its value is a bit list of zero or more of wxTC_MULTILINE, wxTC_RIGHTJUSTIFY, wxTC_FIXEDWIDTH and wxTC_OWNERDRAW.
|
||||
"""
|
33
utils/wxPython/demo/wxPageSetupDialog.py
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxPageSetupDialogData()
|
||||
data.SetMarginTopLeft(wxPoint(50,50))
|
||||
data.SetMarginBottomRight(wxPoint(50,50))
|
||||
dlg = wxPageSetupDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetPageSetupData()
|
||||
tl = data.GetMarginTopLeft()
|
||||
br = data.GetMarginBottomRight()
|
||||
log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
39
utils/wxPython/demo/wxPlotCanvas.py
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
from wxPython.lib.wxPlotCanvas import *
|
||||
from wxPython.lib import wxPlotCanvas
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def _InitObjects():
|
||||
# 100 points sin function, plotted as green circles
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
|
||||
data1.shape = (100, 2)
|
||||
data1[:,1] = Numeric.sin(data1[:,0])
|
||||
markers1 = PolyMarker(data1, color='green', marker='circle',size=1)
|
||||
|
||||
# 50 points cos function, plotted as red line
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
|
||||
data1.shape = (50,2)
|
||||
data1[:,1] = Numeric.cos(data1[:,0])
|
||||
lines = PolyLine(data1, color='red')
|
||||
|
||||
# A few more points...
|
||||
pi = Numeric.pi
|
||||
markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
|
||||
(3.*pi/4., -1)], color='blue',
|
||||
fillcolor='green', marker='cross')
|
||||
|
||||
return PlotGraphics([markers1, lines, markers2])
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = PlotCanvas(nb)
|
||||
win.draw(_InitObjects(),'automatic','automatic');
|
||||
return win
|
||||
|
||||
overview = wxPlotCanvas.__doc__
|
||||
|
||||
#---------------------------------------------------------------------------
|
31
utils/wxPython/demo/wxPrintDialog.py
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxPrintDialogData()
|
||||
data.EnablePrintToFile(true)
|
||||
data.EnablePageNumbers(true)
|
||||
data.EnableSelection(true)
|
||||
dlg = wxPrintDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('\n')
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
76
utils/wxPython/demo/wxRadioBox.py
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestRadioButtons(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(35, 30), wxDefaultSize,
|
||||
sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER)
|
||||
EVT_RADIOBOX(self, 30, self.EvtRadioBox)
|
||||
|
||||
|
||||
def EvtRadioBox(self, event):
|
||||
self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestRadioButtons(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A radio box item is used to select one of number of mutually exclusive choices. It is displayed as a vertical column or horizontal row of labelled buttons.
|
||||
|
||||
wxRadioBox()
|
||||
----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxRadioBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDimension = 0, long style = wxRA_SPECIFY_COLS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "radioBox")
|
||||
|
||||
Constructor, creating and showing a radiobox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
label = Label for the static box surrounding the radio buttons.
|
||||
|
||||
pos = Window position. If the position (-1, -1) is specified then a default position is chosen.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then a default size is chosen.
|
||||
|
||||
n = Number of choices with which to initialize the radiobox.
|
||||
|
||||
choices = An array of choices with which to initialize the radiobox.
|
||||
|
||||
majorDimension = Specifies the maximum number of rows (if style contains wxRA_SPECIFY_ROWS) or columns (if style contains wxRA_SPECIFY_COLS) for a two-dimensional radiobox.
|
||||
|
||||
style = Window style. See wxRadioBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
152
utils/wxPython/demo/wxSashWindow.py
Normal file
@ -0,0 +1,152 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestSashWindow(wxPanel):
|
||||
ID_WINDOW_TOP = 5100
|
||||
ID_WINDOW_LEFT1 = 5101
|
||||
ID_WINDOW_LEFT2 = 5102
|
||||
ID_WINDOW_BOTTOM = 5103
|
||||
|
||||
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
|
||||
EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP,
|
||||
self.ID_WINDOW_BOTTOM, self.OnSashDrag)
|
||||
|
||||
|
||||
# Create some layout windows
|
||||
# A window like a toolbar
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, wxDefaultPosition,
|
||||
wxSize(200, 30), wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(1000, 30))
|
||||
win.SetOrientation(wxLAYOUT_HORIZONTAL)
|
||||
win.SetAlignment(wxLAYOUT_TOP)
|
||||
win.SetBackgroundColour(wxColour(255, 0, 0))
|
||||
win.SetSashVisible(wxSASH_BOTTOM, true)
|
||||
|
||||
self.topWindow = win
|
||||
|
||||
|
||||
# A window like a statusbar
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(1000, 30))
|
||||
win.SetOrientation(wxLAYOUT_HORIZONTAL)
|
||||
win.SetAlignment(wxLAYOUT_BOTTOM)
|
||||
win.SetBackgroundColour(wxColour(0, 0, 255))
|
||||
win.SetSashVisible(wxSASH_TOP, true)
|
||||
|
||||
self.bottomWindow = win
|
||||
|
||||
|
||||
# A window to the left of the client window
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(120, 1000))
|
||||
win.SetOrientation(wxLAYOUT_VERTICAL)
|
||||
win.SetAlignment(wxLAYOUT_LEFT)
|
||||
win.SetBackgroundColour(wxColour(0, 255, 0))
|
||||
win.SetSashVisible(wxSASH_RIGHT, TRUE)
|
||||
win.SetExtraBorderSize(10)
|
||||
|
||||
textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxSUNKEN_BORDER)
|
||||
textWindow.SetValue("A help window")
|
||||
|
||||
self.leftWindow1 = win
|
||||
|
||||
|
||||
# Another window to the left of the client window
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(120, 1000))
|
||||
win.SetOrientation(wxLAYOUT_VERTICAL)
|
||||
win.SetAlignment(wxLAYOUT_LEFT)
|
||||
win.SetBackgroundColour(wxColour(0, 255, 255))
|
||||
win.SetSashVisible(wxSASH_RIGHT, TRUE)
|
||||
|
||||
self.leftWindow2 = win
|
||||
|
||||
|
||||
def OnSashDrag(self, event):
|
||||
if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
|
||||
return
|
||||
|
||||
eID = event.GetId()
|
||||
if eID == self.ID_WINDOW_TOP:
|
||||
self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
|
||||
|
||||
elif eID == self.ID_WINDOW_LEFT1:
|
||||
self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
|
||||
|
||||
|
||||
elif eID == self.ID_WINDOW_LEFT2:
|
||||
self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
|
||||
|
||||
elif eID == self.ID_WINDOW_BOTTOM:
|
||||
self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
|
||||
|
||||
wxLayoutAlgorithm().LayoutWindow(self)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
wxLayoutAlgorithm().LayoutWindow(self)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestSashWindow(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxSashLayoutWindow responds to OnCalculateLayout events generated by wxLayoutAlgorithm. It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wxSashWindow allows sashes to be used if required, to allow the windows to be user-resizable.
|
||||
|
||||
wxSashLayoutWindow()
|
||||
-------------------------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
|
||||
|
||||
Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Pointer to a parent window.
|
||||
|
||||
id = Window identifier. If -1, will automatically create an identifier.
|
||||
|
||||
pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxSashLayoutWindows should generate a default position for the window. If using the wxSashLayoutWindow class directly, supply an actual position.
|
||||
|
||||
size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
|
||||
|
||||
style = Window style. For window styles, please see wxSashLayoutWindow.
|
||||
|
||||
name = Window name.
|
||||
"""
|
24
utils/wxPython/demo/wxScrolledMessageDialog.py
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.dialogs import wxScrolledMessageDialog
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
f = open("Main.py", "r")
|
||||
msg = f.read()
|
||||
dlg = wxScrolledMessageDialog(frame, msg, "message test")
|
||||
dlg.ShowModal()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
122
utils/wxPython/demo/wxScrolledWindow.py
Normal file
@ -0,0 +1,122 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyCanvas(wxScrolledWindow):
|
||||
def __init__(self, parent):
|
||||
wxScrolledWindow.__init__(self, parent, -1, wxPoint(0, 0), wxPyDefaultSize, wxSUNKEN_BORDER)
|
||||
|
||||
self.lines = []
|
||||
|
||||
self.SetBackgroundColour(wxNamedColor("WHITE"))
|
||||
self.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnLeftButtonEvent)
|
||||
self.Connect(-1, -1, wxEVT_LEFT_UP, self.OnLeftButtonEvent)
|
||||
self.Connect(-1, -1, wxEVT_MOTION, self.OnLeftButtonEvent)
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_PENCIL))
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.bmp = bmp
|
||||
|
||||
self.SetScrollbars(20, 20, 50, 50)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.PrepareDC(dc)
|
||||
self.DoDrawing(dc)
|
||||
|
||||
|
||||
def DoDrawing(self, dc):
|
||||
dc.BeginDrawing()
|
||||
#dc.Clear()
|
||||
pen1 = wxPen(wxNamedColour('RED'))
|
||||
dc.SetPen(pen1)
|
||||
dc.DrawRectangle(5, 5, 50, 50)
|
||||
|
||||
dc.SetBrush(wxLIGHT_GREY_BRUSH)
|
||||
dc.SetPen(wxPen(wxNamedColour('BLUE'), 4))
|
||||
dc.DrawRectangle(15, 15, 50, 50)
|
||||
|
||||
font = wxFont(14, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
dc.SetFont(font)
|
||||
dc.SetTextForeground(wxColour(0xFF, 0x20, 0xFF))
|
||||
te = dc.GetTextExtent("Hello World")
|
||||
dc.DrawText("Hello World", 60, 65)
|
||||
|
||||
dc.SetPen(wxPen(wxNamedColour('VIOLET'), 4))
|
||||
dc.DrawLine(5, 65+te[1], 60+te[0], 65+te[1])
|
||||
|
||||
lst = [(100,110), (150,110), (150,160), (100,160)]
|
||||
dc.DrawLines(lst, -60)
|
||||
dc.SetPen(wxGREY_PEN)
|
||||
dc.DrawPolygon(lst, 75)
|
||||
dc.SetPen(wxGREEN_PEN)
|
||||
dc.DrawSpline(lst+[(100,100)])
|
||||
|
||||
dc.DrawBitmap(self.bmp, 200, 20)
|
||||
dc.SetTextForeground(wxColour(0, 0xFF, 0x80))
|
||||
dc.DrawText("a bitmap", 200, 80)
|
||||
|
||||
self.DrawSavedLines(dc)
|
||||
dc.EndDrawing()
|
||||
|
||||
|
||||
def DrawSavedLines(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4))
|
||||
for line in self.lines:
|
||||
for coords in line:
|
||||
apply(dc.DrawLine, coords)
|
||||
|
||||
|
||||
def SetXY(self, event):
|
||||
self.x, self.y = self.ConvertEventCoords(event)
|
||||
|
||||
def ConvertEventCoords(self, event):
|
||||
xView, yView = self.ViewStart()
|
||||
xDelta, yDelta = self.GetScrollPixelsPerUnit()
|
||||
return (event.GetX() + (xView * xDelta),
|
||||
event.GetY() + (yView * yDelta))
|
||||
|
||||
def OnLeftButtonEvent(self, event):
|
||||
if event.LeftDown():
|
||||
self.SetXY(event)
|
||||
self.curLine = []
|
||||
|
||||
elif event.Dragging():
|
||||
dc = wxClientDC(self)
|
||||
self.PrepareDC(dc)
|
||||
dc.BeginDrawing()
|
||||
dc.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4))
|
||||
coords = (self.x, self.y) + self.ConvertEventCoords(event)
|
||||
self.curLine.append(coords)
|
||||
apply(dc.DrawLine, coords)
|
||||
self.SetXY(event)
|
||||
dc.EndDrawing()
|
||||
|
||||
elif event.LeftUp():
|
||||
self.lines.append(self.curLine)
|
||||
self.curLine = []
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyCanvas(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
59
utils/wxPython/demo/wxSingleChoiceDialog.py
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxSingleChoiceDialog(frame, 'Test Single Choice', 'The Caption',
|
||||
['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight'])
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a dialog that shows a list of strings, and allows the user to select one. Double-clicking on a list item is equivalent to single-clicking and then pressing OK.
|
||||
|
||||
wxSingleChoiceDialog()
|
||||
---------------------------------------------
|
||||
|
||||
wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, int n, const wxString* choices, char** clientData = NULL, long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor, taking an array of wxString choices and optional client data.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
caption = The dialog caption.
|
||||
n = The number of choices.
|
||||
|
||||
choices = An array of strings, or a string list, containing the choices.
|
||||
|
||||
style = A dialog style (bitlist) containing flags chosen from the following:
|
||||
|
||||
wxOK Show an OK button.
|
||||
|
||||
wxCANCEL Show a Cancel button.
|
||||
|
||||
wxCENTRE Centre the message. Not Windows.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
41
utils/wxPython/demo/wxSlider.py
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This is a wxSlider.", wxPoint(45, 15))
|
||||
|
||||
slider = wxSlider(self, 100, 25, 1, 100, wxPoint(30, 60),
|
||||
wxSize(250, -1),
|
||||
wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS )
|
||||
slider.SetTickFreq(5, 1)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
49
utils/wxPython/demo/wxSpinButton.py
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxSpinButton control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "1", wxPoint(30, 50), wxSize(60, -1))
|
||||
h = self.text.GetSize().height
|
||||
self.spin = wxSpinButton(self, 20, wxPoint(92, 50), wxSize(h*2, h))
|
||||
self.spin.SetRange(1, 100)
|
||||
self.spin.SetValue(1)
|
||||
|
||||
EVT_SPIN(self, 20, self.OnSpin)
|
||||
|
||||
|
||||
def OnSpin(self, event):
|
||||
self.text.SetValue(str(event.GetPosition()))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
67
utils/wxPython/demo/wxSplitterWindow.py
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
splitter = wxSplitterWindow(nb, -1)
|
||||
|
||||
p1 = wxWindow(splitter, -1)
|
||||
p1.SetBackgroundColour(wxRED)
|
||||
wxStaticText(p1, -1, "Panel One", wxPoint(5,5)).SetBackgroundColour(wxRED)
|
||||
|
||||
p2 = wxWindow(splitter, -1)
|
||||
p2.SetBackgroundColour(wxBLUE)
|
||||
wxStaticText(p2, -1, "Panel Two", wxPoint(5,5)).SetBackgroundColour(wxBLUE)
|
||||
|
||||
splitter.SplitVertically(p1, p2)
|
||||
splitter.SetSashPosition(100)
|
||||
splitter.SetMinimumPaneSize(20)
|
||||
|
||||
return splitter
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class manages up to two subwindows. The current view can be split into two programmatically (perhaps from a menu command), and unsplit either programmatically or via the wxSplitterWindow user interface.
|
||||
|
||||
wxSplitterWindow()
|
||||
-----------------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxSplitterWindow(wxWindow* parent, wxWindowID id, int x, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style=wxSP_3D, const wxString& name = "splitterWindow")
|
||||
|
||||
Constructor for creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The parent of the splitter window.
|
||||
|
||||
id = The window identifier.
|
||||
|
||||
pos = The window position.
|
||||
|
||||
size = The window size.
|
||||
|
||||
style = The window style. See wxSplitterWindow.
|
||||
|
||||
name = The window name.
|
||||
"""
|
41
utils/wxPython/demo/wxStaticBitmap.py
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This is a wxStaticBitmap.", wxPoint(45, 15))
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
wxStaticBitmap(self, -1, bmp, wxPoint(80, 50),
|
||||
wxSize(bmp.GetWidth(), bmp.GetHeight()))
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
73
utils/wxPython/demo/wxStaticText.py
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This is an example of static text",
|
||||
wxPoint(20, 10))
|
||||
|
||||
wxStaticText(self, -1, "using the wxStaticText Control.",
|
||||
wxPoint(20, 30))
|
||||
|
||||
wxStaticText(self, -1, "Is this yellow?",
|
||||
wxPoint(20, 70)).SetBackgroundColour(wxNamedColour('Yellow'))
|
||||
|
||||
str = "This is a different font."
|
||||
text = wxStaticText(self, -1, str, wxPoint(20, 100))
|
||||
font = wxFont(20, wxSWISS, wxNORMAL, wxNORMAL, false, "Arial")
|
||||
w, h, d, e = self.GetFullTextExtent(str, font)
|
||||
text.SetFont(font)
|
||||
text.SetSize(wxSize(w, h))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
panel = TestPanel(nb)
|
||||
return panel
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = '''\
|
||||
A static text control displays one or more lines of read-only text.
|
||||
|
||||
wxStaticText()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label = "", const wxPoint& pos, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "staticText")
|
||||
|
||||
Constructor, creating and showing a text control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Should not be NULL.
|
||||
|
||||
id = Control identifier. A value of -1 denotes a default value.
|
||||
|
||||
label = Text label.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size.
|
||||
|
||||
style = Window style. See wxStaticText.
|
||||
|
||||
name = Window name.
|
||||
'''
|
||||
|
||||
#---------------------------------------------------------------------------
|
114
utils/wxPython/demo/wxStatusBar.py
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import time
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class CustomStatusBar(wxStatusBar):
|
||||
def __init__(self, parent, log):
|
||||
wxStatusBar.__init__(self, parent, -1)
|
||||
self.SetFieldsCount(3)
|
||||
self.log = log
|
||||
|
||||
self.SetStatusText("A Custom StatusBar...", 0)
|
||||
|
||||
self.cb = wxCheckBox(self, 1001, "toggle clock")
|
||||
EVT_CHECKBOX(self, 1001, self.OnToggleClock)
|
||||
self.cb.SetValue(true)
|
||||
|
||||
# figure out how tall to make it.
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.GetFont())
|
||||
(w,h) = dc.GetTextExtent('X')
|
||||
h = int(h * 1.8)
|
||||
self.SetSize(wxSize(100, h))
|
||||
|
||||
# start our timer
|
||||
self.timer = wxPyTimer(self.Notify)
|
||||
self.timer.Start(1000)
|
||||
self.Notify()
|
||||
|
||||
|
||||
# Time-out handler
|
||||
def Notify(self):
|
||||
t = time.localtime(time.time())
|
||||
st = time.strftime("%d-%b-%Y %I:%M:%S", t)
|
||||
self.SetStatusText(st, 2)
|
||||
self.log.WriteText("tick...\n")
|
||||
|
||||
# the checkbox was clicked
|
||||
def OnToggleClock(self, event):
|
||||
if self.cb.GetValue():
|
||||
self.timer.Start(1000)
|
||||
self.Notify()
|
||||
else:
|
||||
self.timer.Stop()
|
||||
|
||||
|
||||
# reposition the checkbox
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
|
||||
|
||||
class TestCustomStatusBar(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
|
||||
wxPoint(0,0), wxSize(500, 300))
|
||||
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
|
||||
|
||||
self.sb = CustomStatusBar(self, log)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.sb.timer.Stop()
|
||||
del self.sb.timer
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestCustomStatusBar(frame, log)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window.
|
||||
|
||||
wxStatusBar()
|
||||
----------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
|
||||
|
||||
Constructor, creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The window parent, usually a frame.
|
||||
|
||||
id = The window identifier. It may take a value of -1 to indicate a default value.
|
||||
|
||||
pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
style = The window style. See wxStatusBar.
|
||||
|
||||
name = The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
|
||||
"""
|
40
utils/wxPython/demo/wxTextCtrl.py
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
wxStaticText(self, -1, "wxTextCtrl", wxPoint(5, 25), wxSize(75, 20))
|
||||
wxTextCtrl(self, 10, "", wxPoint(80, 25), wxSize(150, 20))
|
||||
EVT_TEXT(self, 10, self.EvtText)
|
||||
|
||||
wxStaticText(self, -1, "Passsword", wxPoint(5, 50), wxSize(75, 20))
|
||||
wxTextCtrl(self, 20, "", wxPoint(80, 50), wxSize(150, 20), wxTE_PASSWORD)
|
||||
EVT_TEXT(self, 20, self.EvtText)
|
||||
|
||||
wxStaticText(self, -1, "Multi-line", wxPoint(5, 75), wxSize(75, 20))
|
||||
wxTextCtrl(self, 30, "", wxPoint(80, 75), wxSize(200, 150), wxTE_MULTILINE)
|
||||
EVT_TEXT(self, 30, self.EvtText)
|
||||
|
||||
def EvtText(self, event):
|
||||
self.log.WriteText('EvtText: %s\n' % event.GetString())
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
50
utils/wxPython/demo/wxTextEntryDialog.py
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxTextEntryDialog(frame, 'What is your favorite programming language?',
|
||||
'Duh??', 'Python')
|
||||
dlg.SetValue("Python is the best!") #### this doesn't work?
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You entered: %s\n' % dlg.GetValue())
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a dialog that requests a one-line text string from the user. It is implemented as a generic wxWindows dialog.
|
||||
|
||||
wxTextEntryDialog()
|
||||
----------------------------------
|
||||
|
||||
wxTextEntryDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Please enter text", const wxString& defaultValue = "", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxTextEntryDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultValue = The default value, which may be the empty string.
|
||||
|
||||
style = A dialog style, specifying the buttons (wxOK, wxCANCEL) and an optional wxCENTRE style.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
67
utils/wxPython/demo/wxTimer.py
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import time
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTimer(wxTimer):
|
||||
def __init__(self, log = None):
|
||||
wxTimer.__init__(self)
|
||||
self.log = log
|
||||
|
||||
def Notify(self):
|
||||
wxBell()
|
||||
if self.log:
|
||||
self.log.WriteText('beep!\n')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
_timer = TestTimer()
|
||||
|
||||
|
||||
class TestTimerWin(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
_timer.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This is a timer example",
|
||||
wxPoint(15, 30))
|
||||
|
||||
wxButton(self, 11101, ' Start ', wxPoint(15, 75), wxDefaultSize)
|
||||
wxButton(self, 11102, ' Stop ', wxPoint(77, 75), wxDefaultSize)
|
||||
EVT_BUTTON(self, 11101, self.OnStart)
|
||||
EVT_BUTTON(self, 11102, self.OnStop)
|
||||
|
||||
def OnStart(self, event):
|
||||
_timer.Start(1000)
|
||||
|
||||
def OnStop(self, event):
|
||||
_timer.Stop()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestTimerWin(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
The wxTimer class allows you to execute code at specified intervals. To use it, derive a new class and override the Notify member to perform the required action. Start with Start, stop with Stop, it's as simple as that.
|
||||
|
||||
wxTimer()
|
||||
------------------
|
||||
|
||||
Constructor.
|
||||
"""
|
125
utils/wxPython/demo/wxToolBar.py
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestToolBar(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test ToolBar',
|
||||
wxPoint(0,0), wxSize(500, 300))
|
||||
self.log = log
|
||||
|
||||
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
|
||||
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||
#tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
# wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
|
||||
#self.SetToolBar(tb)
|
||||
|
||||
self.CreateStatusBar()
|
||||
|
||||
tb.AddTool(10, wxNoRefBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "New", "Long help for 'New'")
|
||||
EVT_TOOL(self, 10, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(20, wxNoRefBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Open")
|
||||
EVT_TOOL(self, 20, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
tb.AddTool(30, wxNoRefBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Copy")
|
||||
EVT_TOOL(self, 30, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(40, wxNoRefBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Paste")
|
||||
EVT_TOOL(self, 40, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
|
||||
tb.AddTool(50, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, true, -1, -1, "Toggle this")
|
||||
EVT_TOOL(self, 50, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(60, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNoRefBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
|
||||
true, -1, -1, "Toggle with 2 bitmaps")
|
||||
EVT_TOOL(self, 60, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
|
||||
|
||||
tb.Realize()
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def OnToolClick(self, event):
|
||||
self.log.WriteText("tool %s clicked\n" % event.GetId())
|
||||
|
||||
def OnToolRClick(self, event):
|
||||
self.log.WriteText("tool %s right-clicked\n" % event.GetId())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestToolBar(frame, log)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
The name wxToolBar is defined to be a synonym for one of the following classes:
|
||||
|
||||
wxToolBar95 The native Windows 95 toolbar. Used on Windows 95, NT 4 and above.
|
||||
|
||||
wxToolBarMSW A Windows implementation. Used on 16-bit Windows.
|
||||
|
||||
wxToolBarGTK The GTK toolbar.
|
||||
|
||||
wxToolBarSimple A simple implementation, with scrolling. Used on platforms with no native toolbar control, or where scrolling is required.
|
||||
|
||||
wxToolBar()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr)
|
||||
|
||||
Constructs a toolbar.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Pointer to a parent window.
|
||||
|
||||
id = Window identifier. If -1, will automatically create an identifier.
|
||||
|
||||
pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxWindows should generate a default position for the window. If using the wxWindow class directly, supply an actual position.
|
||||
|
||||
size = Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows should generate a default size for the window.
|
||||
|
||||
style = Window style. See wxToolBar for details.
|
||||
|
||||
name = Window name.
|
||||
"""
|
98
utils/wxPython/demo/wxTreeCtrl.py
Normal file
@ -0,0 +1,98 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTreeCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.tree = wxTreeCtrl(self, tID)
|
||||
root = self.tree.AddRoot("The Root Item")
|
||||
for x in range(15):
|
||||
child = self.tree.AppendItem(root, "Item %d" % x)
|
||||
for y in range(5):
|
||||
last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
|
||||
for z in range(5):
|
||||
self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))
|
||||
|
||||
self.tree.Expand(root)
|
||||
EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self, tID, self.OnSelChanged)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.tree.SetDimensions(0, 0, w, h)
|
||||
|
||||
|
||||
def OnItemExpanded(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
def OnItemCollapsed(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
def OnSelChanged(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestTreeCtrlPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
|
||||
|
||||
wxTreeCtrl()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
|
||||
|
||||
Constructor, creating and showing a tree control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
style = Window style. See wxTreeCtrl.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@ -35,6 +35,58 @@ Or you can send mail directly to the list using this address:
|
||||
wxpython-users@starship.python.net
|
||||
|
||||
|
||||
What's new in 2.0b9
|
||||
-------------------
|
||||
Bug fix for ListCtrl in test4.py (Was a missing file... DSM!)
|
||||
|
||||
Bug fix for occassional GPF on Win32 systems upon termination of a
|
||||
wxPython application.
|
||||
|
||||
Added wxListBox.GetSelections returning selections as a Tuple.
|
||||
|
||||
Added a wxTreeItemData that is able to hold any Python object and be
|
||||
associated with items in a wxTreeCtrl. Added test pytree.py to show
|
||||
this feature off.
|
||||
|
||||
Added wxSafeYield function.
|
||||
|
||||
OpenGL Canvas can be optionally compiled in to wxPython.
|
||||
|
||||
Awesome new Demo Framework for showing off wxPython and for learning
|
||||
how it all works.
|
||||
|
||||
The pre-built Win32 version is no longer distributing the wxWindows
|
||||
DLL. It is statically linked with the wxWindows library instead.
|
||||
|
||||
Added a couple missing items from the docs.
|
||||
|
||||
Added wxImage, wxImageHandler, wxPNGHandler, wxJPEGHandler,
|
||||
wxGIFHandler and wxBMPHandler.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b8
|
||||
-------------------
|
||||
Support for using Python threads in wxPython apps.
|
||||
|
||||
Several missing methods from various classes.
|
||||
|
||||
Various bug fixes.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b7
|
||||
-------------------
|
||||
Added DLG_PNT and DLG_SZE convienience methods to wxWindow class.
|
||||
|
||||
Added missing constructor and other methods for wxMenuItem.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b6
|
||||
-------------------
|
||||
Just a quickie update to fix the self-installer to be compatible with
|
||||
Python 1.5.2b2's Registry settings.
|
||||
|
||||
|
||||
What's new in 2.0b5
|
||||
|
@ -1,8 +1,8 @@
|
||||
wxPython\*.txt
|
||||
|
||||
wxPython\tests\*.py
|
||||
wxPython\tests\bitmaps\*.bmp
|
||||
wxPython\tests\bitmaps\*.ico
|
||||
wxPython\demo\*.py
|
||||
wxPython\demo\bitmaps\*.bmp
|
||||
wxPython\demo\bitmaps\*.ico
|
||||
|
||||
|
||||
|
||||
@ -33,4 +33,6 @@ wxPython\src\qt\*.cpp
|
||||
wxPython\src\qt\*.h
|
||||
wxPython\src\qt\*.py
|
||||
|
||||
wxPython\SWIG.patches\*.patch
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ item: Global
|
||||
Patch Flags=0000000000001001
|
||||
Patch Threshold=85
|
||||
Patch Memory=4000
|
||||
EXE Filename=wxPython-2.0b6.exe
|
||||
EXE Filename=wxPython-2.0b9.exe
|
||||
FTP Cluster Size=20
|
||||
Per-User Version ID=1
|
||||
Dialogs Version=6
|
||||
@ -191,7 +191,7 @@ end
|
||||
item: End Block
|
||||
end
|
||||
item: Display Graphic
|
||||
Pathname=e:\Projects\wxPython\distrib\wxPython.BMP
|
||||
Pathname=e:\Projects\wx\utils\wxPython\distrib\wxPython.BMP
|
||||
X Position=32784
|
||||
Y Position=16
|
||||
Flags=0000001010000000
|
||||
@ -971,11 +971,6 @@ item: If/While Statement
|
||||
Value=A
|
||||
Flags=00001010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wx\lib\wx200.dll
|
||||
Destination=%SYS%\wx200.dll
|
||||
Flags=0000001010010010
|
||||
end
|
||||
item: Install File
|
||||
Source=c:\WINNT\System32\Msvcirt.dll
|
||||
Destination=%SYS%\Msvcirt.dll
|
||||
@ -987,178 +982,63 @@ item: Install File
|
||||
Flags=0000001010000011
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\__init__.py
|
||||
Destination=%MAINDIR%\wxPython\__init__.py
|
||||
Source=e:\Projects\wx\utils\wxPython\*.py
|
||||
Destination=%MAINDIR%\wxPython
|
||||
Description=wxPython shadow class modules
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\cmndlgs.py
|
||||
Destination=%MAINDIR%\wxPython\cmndlgs.py
|
||||
Source=e:\Projects\wx\utils\wxPython\*.pyd
|
||||
Destination=%MAINDIR%\wxPython\
|
||||
Description=wxPython extension modules
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\controls2.py
|
||||
Destination=%MAINDIR%\wxPython\controls2.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\events.py
|
||||
Destination=%MAINDIR%\wxPython\events.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\frames.py
|
||||
Destination=%MAINDIR%\wxPython\frames.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\gdi.py
|
||||
Destination=%MAINDIR%\wxPython\gdi.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\mdi.py
|
||||
Destination=%MAINDIR%\wxPython\mdi.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\misc.py
|
||||
Destination=%MAINDIR%\wxPython\misc.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\stattool.py
|
||||
Destination=%MAINDIR%\wxPython\stattool.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\utils.py
|
||||
Destination=%MAINDIR%\wxPython\utils.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\windows.py
|
||||
Destination=%MAINDIR%\wxPython\windows.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\windows2.py
|
||||
Destination=%MAINDIR%\wxPython\windows2.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\windows3.py
|
||||
Destination=%MAINDIR%\wxPython\windows3.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\controls.py
|
||||
Destination=%MAINDIR%\wxPython\controls.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\wx.py
|
||||
Destination=%MAINDIR%\wxPython\wx.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\wxc.pyd
|
||||
Destination=%MAINDIR%\wxPython\wxc.pyd
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\distrib\SelfInst-README.txt
|
||||
Source=e:\Projects\wx\utils\wxPython\distrib\SelfInst-README.txt
|
||||
Destination=%MAINDIR%\wxPython\README.txt
|
||||
Description=README file
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test1.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test1.py
|
||||
Source=e:\Projects\wx\utils\wxPython\lib\*.py
|
||||
Destination=%MAINDIR%\wxPython\lib
|
||||
Description=wxPython Standard Library
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test2.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test2.py
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\*.py
|
||||
Destination=%MAINDIR%\wxPython\demo
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test3.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test3.py
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\bitmaps\*.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test4.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test4.py
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\bitmaps\*.gif
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test5.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test5.py
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\bitmaps\*.jpg
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test6.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test6.py
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\bitmaps\*.png
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\test7.py
|
||||
Destination=%MAINDIR%\wxPython\demo\test7.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\wxSlash.py
|
||||
Destination=%MAINDIR%\wxPython\demo\wxSlash.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=E:\PROJECTS\wxPython\tests\wxPlotCanvas.py
|
||||
Destination=%MAINDIR%\wxPython\demo\wxPlotCanvas.py
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\copy.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\copy.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\mondrian.ico
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\mondrian.ico
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\new.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\new.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\open.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\open.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\paste.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\paste.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\smiles.ico
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\smiles.ico
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\tog1.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\tog1.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\test2.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\test2.bmp
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\Projects\wxPython\tests\bitmaps\tog2.bmp
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps\tog2.bmp
|
||||
Source=e:\Projects\wx\utils\wxPython\demo\bitmaps\*.ico
|
||||
Destination=%MAINDIR%\wxPython\demo\bitmaps
|
||||
Description=Demos
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: End Block
|
||||
@ -1173,11 +1053,13 @@ end
|
||||
item: Install File
|
||||
Source=e:\projects\wx\docs\html\wx\*.*
|
||||
Destination=%MAINDIR%\wxPython\docs
|
||||
Description=wxPython documentation
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: Install File
|
||||
Source=e:\projects\wx\docs\html\wx\wx.htm
|
||||
Destination=%MAINDIR%\wxPython\docs\index.htm
|
||||
Description=wxPython documentation
|
||||
Flags=0000000010000010
|
||||
end
|
||||
item: End Block
|
||||
|
@ -11,5 +11,6 @@ copy wxPython\docs\wx.htm wxPython\docs\index.htm
|
||||
zip -r wxPython\wxPython-docs-%1.zip wxPython\docs
|
||||
|
||||
del /y wxPython\docs\*.*
|
||||
rmdir wxPython\docs
|
||||
|
||||
move /R wxPython\*.zip wxPython\distrib
|
||||
move /R wxPython\*.zip wxPython\distrib
|
||||
|
1
utils/wxPython/lib/.cvsignore
Normal file
@ -0,0 +1 @@
|
||||
*.pyc
|
3
utils/wxPython/lib/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
106
utils/wxPython/lib/dialogs.py
Normal file
@ -0,0 +1,106 @@
|
||||
from wxPython.wx import *
|
||||
from layoutf import Layoutf
|
||||
import string
|
||||
|
||||
|
||||
|
||||
class wxScrolledMessageDialog(wxDialog):
|
||||
|
||||
def __init__(self, parent, msg, caption, pos = None, size = None):
|
||||
if not pos:
|
||||
pos = wxDefaultPosition
|
||||
if not size:
|
||||
size = wxSize(500,300)
|
||||
wxDialog.__init__(self, parent, -1, caption, pos, size)
|
||||
text = wxTextCtrl(self, -1, msg, wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxTE_MULTILINE | wxTE_READONLY)
|
||||
ok = wxButton(self, wxID_OK, "OK")
|
||||
text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
|
||||
ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!25', (self,)))
|
||||
self.SetAutoLayout(TRUE)
|
||||
|
||||
|
||||
|
||||
class wxMultipleChoiceDialog(wxDialog):
|
||||
|
||||
def __init__(self, parent, msg, title, lst, pos = None, size = None):
|
||||
if not pos:
|
||||
pos = wxDefaultPosition
|
||||
if not size:
|
||||
size = wxSize(200,200)
|
||||
wxDialog.__init__(self, parent, -1, title, pos, size)
|
||||
dc = wxClientDC(self)
|
||||
height = 0
|
||||
for line in string.split(msg,'\n'):
|
||||
height = height + dc.GetTextExtent(msg)[1] + 4
|
||||
stat = wxStaticText(self, -1, msg)
|
||||
self.lbox = wxListBox(self, 100, wxDefaultPosition,
|
||||
wxDefaultSize, lst, wxLB_MULTIPLE)
|
||||
ok = wxButton(self, wxID_OK, "OK")
|
||||
cancel = wxButton(self, wxID_CANCEL, "Cancel")
|
||||
stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
|
||||
(self,)))
|
||||
self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
|
||||
(self, stat, ok)))
|
||||
ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
|
||||
cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
|
||||
self.SetAutoLayout(TRUE)
|
||||
self.lst = lst
|
||||
|
||||
def OnSize(self, event):
|
||||
self.Layout()
|
||||
|
||||
def GetValue(self):
|
||||
return self.lbox.GetSelections()
|
||||
|
||||
def GetValueString(self):
|
||||
sel = self.lbox.GetSelections()
|
||||
val = []
|
||||
for i in sel:
|
||||
val.append(self.lst[i])
|
||||
return tuple(val)
|
||||
|
||||
if __name__ == '__main__':
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, NULL, -1, "hello",
|
||||
wxDefaultPosition, wxSize(200,200))
|
||||
wxButton(self, 100, "Multiple Test",wxPoint(0,0))
|
||||
wxButton(self, 101, "Message Test", wxPoint(0,100))
|
||||
EVT_BUTTON(self, 100, self.OnMultipleTest)
|
||||
EVT_BUTTON(self, 101, self.OnMessageTest)
|
||||
|
||||
def OnMultipleTest(self, event):
|
||||
self.lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
|
||||
'etc', 'etc..', 'etc...' ]
|
||||
dlg = wxMultipleChoiceDialog(self,
|
||||
"Pick some from\n this list\nblabla",
|
||||
"m.s.d.", self.lst)
|
||||
if (dlg.ShowModal() == wxID_OK):
|
||||
print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString()
|
||||
|
||||
def OnMessageTest(self, event):
|
||||
import sys;
|
||||
f = open(sys.argv[0],"r")
|
||||
msg = f.read()
|
||||
dlg = wxScrolledMessageDialog(self, msg, "message test")
|
||||
dlg.ShowModal()
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = MyFrame()
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
262
utils/wxPython/lib/layoutf.py
Normal file
@ -0,0 +1,262 @@
|
||||
from wxPython.wx import wxLayoutConstraints,\
|
||||
wxTop, wxLeft, wxBottom, wxRight, \
|
||||
wxHeight, wxWidth, wxCentreX, wxCentreY
|
||||
import re,string
|
||||
|
||||
class Layoutf(wxLayoutConstraints):
|
||||
"""
|
||||
The class Layoutf(wxLayoutConstraints) presents a simplification
|
||||
of the wxLayoutConstraints syntax. The name Layoutf is choosen
|
||||
because of the similarity with C's printf function.
|
||||
|
||||
Quick Example:
|
||||
|
||||
lc = Layoutf('t=t#1;l=r10#2;r!100;h%h50#1', (self, self.panel))
|
||||
|
||||
is equivalent to
|
||||
|
||||
lc = wxLayoutContraints()
|
||||
lc.top.SameAs(self, wxTop)
|
||||
lc.left.SameAs(self.panel, wxRight, 10)
|
||||
lc.right.Absolute(100)
|
||||
lc.height.PercentOf(self, wxHeight, 50)
|
||||
|
||||
Usage:
|
||||
|
||||
You can give a constraint string to the Layoutf constructor,
|
||||
or use the 'pack' method. The following are equivalent:
|
||||
|
||||
lc = Layoutf('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
|
||||
|
||||
and
|
||||
|
||||
lc = Layoutf()
|
||||
lc.pack('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
|
||||
|
||||
Besides 'pack' there's also 'debug_pack' which does not set
|
||||
constraints, but prints traditional wxLayoutConstraint calls to
|
||||
stdout.
|
||||
|
||||
The calls to the Layoutf constructor and pack methods have
|
||||
the following argument list:
|
||||
|
||||
(constraint_string, objects_tuple)
|
||||
|
||||
Constraint String syntax:
|
||||
|
||||
Constraint directives are separated by semi-colons. You
|
||||
generally (always?) need four directives to completely describe a
|
||||
subwindow's location.
|
||||
|
||||
A single directive has either of the following forms:
|
||||
|
||||
1. <own attribute><compare operation>[numerical argument]
|
||||
for example r!100 -> lc.right.Absolute(100) )
|
||||
and w* -> lc.width.AsIs()
|
||||
|
||||
2. <own attribute><compare operation>[numerical argument]
|
||||
#<compare object nr.>
|
||||
for example t_10#2 (lc.top.Below(<second obj>, 10)
|
||||
|
||||
3. <own attribute><compare operation><compare attribute>
|
||||
[numerical argument]#<compare object nr.>
|
||||
for example w%h50#2 ( lc.width.PercentOf(<second obj>,
|
||||
wxHeight, 50) and t=b#1 ( lc.top.SameAs(<first obj>,
|
||||
wxBottom) )
|
||||
|
||||
Which one you need is defined by the <compare operation>
|
||||
type. The following take type 1 (no object to compare with):
|
||||
|
||||
'!': 'Absolute', '?': 'Unconstrained', '*': 'AsIs'
|
||||
|
||||
These take type 2 (need to be compared with another object)
|
||||
|
||||
'<': 'LeftOf', '>': 'RightOf', '^': 'Above', '_': 'Below'
|
||||
|
||||
These take type 3 (need to be compared to another object
|
||||
attribute)
|
||||
|
||||
'=': 'SameAs', '%': 'PercentOf'
|
||||
|
||||
For all types, the <own attribute> letter can be any of
|
||||
|
||||
't': 'top', 'l': 'left', 'b': 'bottom',
|
||||
'r': 'right', 'h': 'height', 'w': 'width',
|
||||
'x': 'centreX', 'y': 'centreY'
|
||||
|
||||
If the operation takes an (optional) numerical argument, place it
|
||||
in [numerical argument]. For type 3 directives, the <compare
|
||||
attribute> letter can be any of
|
||||
|
||||
't': 'wxTop', 'l': 'wxLeft', 'b': 'wxBottom'
|
||||
'r': 'wxRight', 'h': 'wxHeight', 'w': 'wxWidth',
|
||||
'x': 'wxCentreX', 'y': 'wxCentreY'
|
||||
|
||||
Note that these are the same letters as used for <own attribute>,
|
||||
so you'll only need to remember one set. Finally, the object
|
||||
whose attribute is refered to, is specified by #<compare object
|
||||
nr>, where <compare object nr> is the 1-based (stupid, I know,
|
||||
but I've gotten used to it) index of the object in the
|
||||
objects_tuple argument.
|
||||
|
||||
Bugs:
|
||||
|
||||
Not entirely happy about the logic in the order of arguments
|
||||
after the <compare operation> character.
|
||||
|
||||
Not all wxLayoutConstraint methods are included in the
|
||||
syntax. However, the type 3 directives are generally the most
|
||||
used. Further excuse: wxWindows layout constraints are at the
|
||||
time of this writing not documented.
|
||||
|
||||
"""
|
||||
|
||||
attr_d = { 't': 'top', 'l': 'left', 'b': 'bottom',
|
||||
'r': 'right', 'h': 'height', 'w': 'width',
|
||||
'x': 'centreX', 'y': 'centreY' }
|
||||
op_d = { '=': 'SameAs', '%': 'PercentOf', '<': 'LeftOf',
|
||||
'>': 'RightOf', '^': 'Above', '_': 'Below',
|
||||
'!': 'Absolute', '?': 'Unconstrained', '*': 'AsIs' }
|
||||
cmp_d = { 't': 'wxTop', 'l': 'wxLeft', 'b': 'wxBottom',
|
||||
'r': 'wxRight', 'h': 'wxHeight', 'w': 'wxWidth',
|
||||
'x': 'wxCentreX', 'y': 'wxCentreY' }
|
||||
|
||||
rexp1 = re.compile('^\s*([tlrbhwxy])\s*([!\?\*])\s*(\d*)\s*$')
|
||||
rexp2 = re.compile('^\s*([tlrbhwxy])\s*([=%<>^_])\s*([tlrbhwxy]?)\s*(\d*)\s*#(\d+)\s*$')
|
||||
|
||||
def __init__(self,pstr=None,winlist=None):
|
||||
wxLayoutConstraints.__init__(self)
|
||||
if pstr:
|
||||
self.pack(pstr,winlist)
|
||||
|
||||
def pack(self, pstr, winlist):
|
||||
pstr = string.lower(pstr)
|
||||
for item in string.split(pstr,';'):
|
||||
m = self.rexp1.match(item)
|
||||
if m:
|
||||
g = list(m.groups())
|
||||
attr = getattr(self, self.attr_d[g[0]])
|
||||
func = getattr(attr, self.op_d[g[1]])
|
||||
if g[1] == '!':
|
||||
func(int(g[2]))
|
||||
else:
|
||||
func()
|
||||
continue
|
||||
m = self.rexp2.match(item)
|
||||
if not m: raise ValueError
|
||||
g = list(m.groups())
|
||||
attr = getattr(self, self.attr_d[g[0]])
|
||||
func = getattr(attr, self.op_d[g[1]])
|
||||
if g[3]: g[3] = int(g[3])
|
||||
else: g[3] = None;
|
||||
g[4] = int(g[4]) - 1
|
||||
if g[1] in '<>^_':
|
||||
if g[3]: func(winlist[g[4]], g[3])
|
||||
else: func(winlist[g[4]])
|
||||
else:
|
||||
cmp = eval(self.cmp_d[g[2]])
|
||||
if g[3]: func(winlist[g[4]], cmp, g[3])
|
||||
else: func(winlist[g[4]], cmp)
|
||||
|
||||
def debug_pack(self, pstr, winlist):
|
||||
pstr = string.lower(pstr)
|
||||
for item in string.split(pstr,';'):
|
||||
m = self.rexp1.match(item)
|
||||
if m:
|
||||
g = list(m.groups())
|
||||
attr = getattr(self, self.attr_d[g[0]])
|
||||
func = getattr(attr, self.op_d[g[1]])
|
||||
if g[1] == '!':
|
||||
print "%s.%s.%s(%s)" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]],g[2])
|
||||
else:
|
||||
print "%s.%s.%s()" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]])
|
||||
continue
|
||||
m = self.rexp2.match(item)
|
||||
if not m: raise ValueError
|
||||
g = list(m.groups())
|
||||
if g[3]: g[3] = int(g[3])
|
||||
else: g[3] = 0;
|
||||
g[4] = int(g[4]) - 1
|
||||
if g[1] in '<>^_':
|
||||
if g[3]: print "%s.%s.%s(%s,%d)" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]],winlist[g[4]],
|
||||
g[3])
|
||||
else: print "%s.%s.%s(%s)" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]],winlist[g[4]])
|
||||
else:
|
||||
if g[3]: print "%s.%s.%s(%s,%s,%d)" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]],winlist[g[4]],
|
||||
self.cmp_d[g[2]],g[3])
|
||||
else: print "%s.%s.%s(%s,%s)" % \
|
||||
('self',self.attr_d[g[0]],self.op_d[g[1]],winlist[g[4]],
|
||||
self.cmp_d[g[2]])
|
||||
|
||||
if __name__=='__main__':
|
||||
from wxPython.wx import *
|
||||
|
||||
class TestLayoutf(wxFrame):
|
||||
def __init__(self, parent):
|
||||
wxFrame.__init__(self, parent, -1, 'Test Layout Constraints',
|
||||
wxPyDefaultPosition, wxSize(500, 300))
|
||||
|
||||
self.SetAutoLayout(true)
|
||||
EVT_BUTTON(self, 100, self.OnButton)
|
||||
EVT_BUTTON(self, 101, self.OnAbout)
|
||||
|
||||
self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelA.SetBackgroundColour(wxBLUE)
|
||||
self.panelA.SetConstraints(Layoutf('t=t10#1;l=l10#1;b=b10#1;r%r50#1',(self,)))
|
||||
|
||||
self.panelB = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelB.SetBackgroundColour(wxRED)
|
||||
self.panelB.SetConstraints(Layoutf('t=t10#1;r=r10#1;b%b30#1;l>10#2', (self,self.panelA)))
|
||||
|
||||
self.panelC = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelC.SetBackgroundColour(wxWHITE)
|
||||
self.panelC.SetConstraints(Layoutf('t_10#3;r=r10#1;b=b10#1;l>10#2', (self,self.panelA,self.panelB)))
|
||||
|
||||
b = wxButton(self.panelA, 101, ' About: ')
|
||||
b.SetConstraints(Layoutf('X=X#1;Y=Y#1;h*;w%w50#1', (self.panelA,)))
|
||||
|
||||
b = wxButton(self.panelB, 100, ' Panel B ')
|
||||
b.SetConstraints(Layoutf('t=t2#1;r=r4#1;h*;w*', (self.panelB,)))
|
||||
|
||||
self.panelD = wxWindow(self.panelC, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelD.SetBackgroundColour(wxGREEN)
|
||||
self.panelD.SetConstraints(Layoutf('b%h50#1;r%w50#1;h=h#2;w=w#2', (self.panelC, b)))
|
||||
|
||||
b = wxButton(self.panelC, 100, ' Panel C ')
|
||||
b.SetConstraints(Layoutf('t_#1;l>#1;h*;w*', (self.panelD,)))
|
||||
|
||||
wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
|
||||
|
||||
def OnButton(self, event):
|
||||
self.Close(true)
|
||||
|
||||
def OnAbout(self, event):
|
||||
try:
|
||||
from dialogs import wxScrolledMessageDialog
|
||||
msg = wxScrolledMessageDialog(self, Layoutf.__doc__, "about")
|
||||
msg.ShowModal()
|
||||
except:
|
||||
print msg
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
class TestApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = TestLayoutf(NULL)
|
||||
frame.Show(1)
|
||||
self.SetTopWindow(frame)
|
||||
return 1
|
||||
|
||||
app = TestApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
468
utils/wxPython/lib/wxPlotCanvas.py
Normal file
@ -0,0 +1,468 @@
|
||||
"""
|
||||
This is a port of Konrad Hinsen's tkPlotCanvas.py plotting module.
|
||||
After thinking long and hard I came up with the name "wxPlotCanvas.py".
|
||||
|
||||
This file contains two parts; first the re-usable library stuff, then, after
|
||||
a "if __name__=='__main__'" test, a simple frame and a few default plots
|
||||
for testing.
|
||||
|
||||
Harm van der Heijden, feb 1999
|
||||
|
||||
Original comment follows below:
|
||||
# This module defines a plot widget for Tk user interfaces.
|
||||
# It supports only elementary line plots at the moment.
|
||||
# See the example at the end for documentation...
|
||||
#
|
||||
# Written by Konrad Hinsen <hinsen@cnrs-orleans.fr>
|
||||
# With contributions from RajGopal Srinivasan <raj@cherubino.med.jhmi.edu>
|
||||
# Last revision: 1998-7-28
|
||||
#
|
||||
"""
|
||||
|
||||
from wxPython import wx
|
||||
import string
|
||||
|
||||
# Not everybody will have Numeric, so let's be cool about it...
|
||||
try:
|
||||
import Numeric
|
||||
except:
|
||||
# bummer!
|
||||
d = wx.wxMessageDialog(wx.NULL,
|
||||
"""This module requires the Numeric module, which could not be imported.
|
||||
It probably is not installed (it's not part of the standard Python
|
||||
distribution). See the Python site (http://www.python.org) for
|
||||
information on downloading source or binaries.""",
|
||||
"Numeric not found")
|
||||
if d.ShowModal() == wx.wxID_CANCEL:
|
||||
d = wx.wxMessageDialog(wx.NULL, "I kid you not! Pressing Cancel won't help you!", "Not a joke", wx.wxOK)
|
||||
d.ShowModal()
|
||||
import sys
|
||||
sys.exit()
|
||||
|
||||
#
|
||||
# Plotting classes...
|
||||
#
|
||||
class PolyPoints:
|
||||
|
||||
def __init__(self, points, attr):
|
||||
self.points = Numeric.array(points)
|
||||
self.scaled = self.points
|
||||
self.attributes = {}
|
||||
for name, value in self._attributes.items():
|
||||
try:
|
||||
value = attr[name]
|
||||
except KeyError: pass
|
||||
self.attributes[name] = value
|
||||
|
||||
def boundingBox(self):
|
||||
return Numeric.minimum.reduce(self.points), \
|
||||
Numeric.maximum.reduce(self.points)
|
||||
|
||||
def scaleAndShift(self, scale=1, shift=0):
|
||||
self.scaled = scale*self.points+shift
|
||||
|
||||
|
||||
class PolyLine(PolyPoints):
|
||||
|
||||
def __init__(self, points, **attr):
|
||||
PolyPoints.__init__(self, points, attr)
|
||||
|
||||
_attributes = {'color': 'black',
|
||||
'width': 1}
|
||||
|
||||
def draw(self, dc):
|
||||
color = self.attributes['color']
|
||||
width = self.attributes['width']
|
||||
arguments = []
|
||||
dc.SetPen(wx.wxPen(wx.wxNamedColour(color), width))
|
||||
dc.DrawLines(map(tuple,self.scaled))
|
||||
|
||||
|
||||
class PolyMarker(PolyPoints):
|
||||
|
||||
def __init__(self, points, **attr):
|
||||
|
||||
PolyPoints.__init__(self, points, attr)
|
||||
|
||||
_attributes = {'color': 'black',
|
||||
'width': 1,
|
||||
'fillcolor': None,
|
||||
'size': 2,
|
||||
'fillstyle': wx.wxSOLID,
|
||||
'outline': 'black',
|
||||
'marker': 'circle'}
|
||||
|
||||
def draw(self, dc):
|
||||
color = self.attributes['color']
|
||||
width = self.attributes['width']
|
||||
size = self.attributes['size']
|
||||
fillcolor = self.attributes['fillcolor']
|
||||
fillstyle = self.attributes['fillstyle']
|
||||
marker = self.attributes['marker']
|
||||
|
||||
dc.SetPen(wx.wxPen(wx.wxNamedColour(color),width))
|
||||
if fillcolor:
|
||||
dc.SetBrush(wx.wxBrush(wx.wxNamedColour(fillcolor),fillstyle))
|
||||
else:
|
||||
dc.SetBrush(wx.wxBrush(wx.wxNamedColour('black'), wx.wxTRANSPARENT))
|
||||
|
||||
self._drawmarkers(dc, self.scaled, marker, size)
|
||||
|
||||
def _drawmarkers(self, dc, coords, marker,size=1):
|
||||
f = eval('self._' +marker)
|
||||
for xc, yc in coords:
|
||||
f(dc, xc, yc, size)
|
||||
|
||||
def _circle(self, dc, xc, yc, size=1):
|
||||
dc.DrawEllipse(xc-2.5*size,yc-2.5*size,5.*size,5.*size)
|
||||
|
||||
def _dot(self, dc, xc, yc, size=1):
|
||||
dc.DrawPoint(xc,yc)
|
||||
|
||||
def _square(self, dc, xc, yc, size=1):
|
||||
dc.DrawRectangle(xc-2.5*size,yc-2.5*size,5.*size,5.*size)
|
||||
|
||||
def _triangle(self, dc, xc, yc, size=1):
|
||||
dc.DrawPolygon([(-0.5*size*5,0.2886751*size*5),
|
||||
(0.5*size*5,0.2886751*size*5),
|
||||
(0.0,-0.577350*size*5)],xc,yc)
|
||||
|
||||
def _triangle_down(self, dc, xc, yc, size=1):
|
||||
dc.DrawPolygon([(-0.5*size*5,-0.2886751*size*5),
|
||||
(0.5*size*5,-0.2886751*size*5),
|
||||
(0.0,0.577350*size*5)],xc,yc)
|
||||
|
||||
def _cross(self, dc, xc, yc, size=1):
|
||||
dc.DrawLine(xc-2.5*size,yc-2.5*size,xc+2.5*size,yc+2.5*size)
|
||||
dc.DrawLine(xc-2.5*size,yc+2.5*size,xc+2.5*size,yc-2.5*size)
|
||||
|
||||
def _plus(self, dc, xc, yc, size=1):
|
||||
dc.DrawLine(xc-2.5*size,yc,xc+2.5*size,yc)
|
||||
dc.DrawLine(xc,yc-2.5*size,xc,yc+2.5*size)
|
||||
|
||||
class PlotGraphics:
|
||||
|
||||
def __init__(self, objects):
|
||||
self.objects = objects
|
||||
|
||||
def boundingBox(self):
|
||||
p1, p2 = self.objects[0].boundingBox()
|
||||
for o in self.objects[1:]:
|
||||
p1o, p2o = o.boundingBox()
|
||||
p1 = Numeric.minimum(p1, p1o)
|
||||
p2 = Numeric.maximum(p2, p2o)
|
||||
return p1, p2
|
||||
|
||||
def scaleAndShift(self, scale=1, shift=0):
|
||||
for o in self.objects:
|
||||
o.scaleAndShift(scale, shift)
|
||||
|
||||
def draw(self, canvas):
|
||||
for o in self.objects:
|
||||
o.draw(canvas)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.objects)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.objects[item]
|
||||
|
||||
|
||||
class PlotCanvas(wx.wxWindow):
|
||||
|
||||
def __init__(self, parent, id = -1):
|
||||
wx.wxWindow.__init__(self, parent, id, wx.wxPyDefaultPosition, wx.wxPyDefaultSize)
|
||||
self.border = (1,1)
|
||||
self.SetClientSizeWH(400,400)
|
||||
self.SetBackgroundColour(wx.wxNamedColour("white"))
|
||||
|
||||
wx.EVT_SIZE(self,self.reconfigure)
|
||||
self._setsize()
|
||||
self.last_draw = None
|
||||
# self.font = self._testFont(font)
|
||||
|
||||
def OnPaint(self, event):
|
||||
pdc = wx.wxPaintDC(self)
|
||||
if self.last_draw is not None:
|
||||
apply(self.draw, self.last_draw + (pdc,))
|
||||
|
||||
def reconfigure(self, event):
|
||||
(new_width,new_height) = self.GetClientSizeTuple()
|
||||
if new_width == self.width and new_height == self.height:
|
||||
return
|
||||
self._setsize()
|
||||
# self.redraw()
|
||||
|
||||
def _testFont(self, font):
|
||||
if font is not None:
|
||||
bg = self.canvas.cget('background')
|
||||
try:
|
||||
item = CanvasText(self.canvas, 0, 0, anchor=NW,
|
||||
text='0', fill=bg, font=font)
|
||||
self.canvas.delete(item)
|
||||
except TclError:
|
||||
font = None
|
||||
return font
|
||||
|
||||
def _setsize(self):
|
||||
(self.width,self.height) = self.GetClientSizeTuple();
|
||||
self.plotbox_size = 0.97*Numeric.array([self.width, -self.height])
|
||||
xo = 0.5*(self.width-self.plotbox_size[0])
|
||||
yo = self.height-0.5*(self.height+self.plotbox_size[1])
|
||||
self.plotbox_origin = Numeric.array([xo, yo])
|
||||
|
||||
def draw(self, graphics, xaxis = None, yaxis = None, dc = None):
|
||||
if dc == None: dc = wx.wxClientDC(self)
|
||||
dc.BeginDrawing()
|
||||
dc.Clear()
|
||||
self.last_draw = (graphics, xaxis, yaxis)
|
||||
p1, p2 = graphics.boundingBox()
|
||||
xaxis = self._axisInterval(xaxis, p1[0], p2[0])
|
||||
yaxis = self._axisInterval(yaxis, p1[1], p2[1])
|
||||
text_width = [0., 0.]
|
||||
text_height = [0., 0.]
|
||||
if xaxis is not None:
|
||||
p1[0] = xaxis[0]
|
||||
p2[0] = xaxis[1]
|
||||
xticks = self._ticks(xaxis[0], xaxis[1])
|
||||
bb = dc.GetTextExtent(xticks[0][1])
|
||||
text_height[1] = bb[1]
|
||||
text_width[0] = 0.5*bb[0]
|
||||
bb = dc.GetTextExtent(xticks[-1][1])
|
||||
text_width[1] = 0.5*bb[0]
|
||||
else:
|
||||
xticks = None
|
||||
if yaxis is not None:
|
||||
p1[1] = yaxis[0]
|
||||
p2[1] = yaxis[1]
|
||||
yticks = self._ticks(yaxis[0], yaxis[1])
|
||||
for y in yticks:
|
||||
bb = dc.GetTextExtent(y[1])
|
||||
text_width[0] = max(text_width[0],bb[0])
|
||||
h = 0.5*bb[1]
|
||||
text_height[0] = h
|
||||
text_height[1] = max(text_height[1], h)
|
||||
else:
|
||||
yticks = None
|
||||
text1 = Numeric.array([text_width[0], -text_height[1]])
|
||||
text2 = Numeric.array([text_width[1], -text_height[0]])
|
||||
scale = (self.plotbox_size-text1-text2) / (p2-p1)
|
||||
shift = -p1*scale + self.plotbox_origin + text1
|
||||
self._drawAxes(dc, xaxis, yaxis, p1, p2,
|
||||
scale, shift, xticks, yticks)
|
||||
graphics.scaleAndShift(scale, shift)
|
||||
graphics.draw(dc)
|
||||
dc.EndDrawing()
|
||||
|
||||
def _axisInterval(self, spec, lower, upper):
|
||||
if spec is None:
|
||||
return None
|
||||
if spec == 'minimal':
|
||||
if lower == upper:
|
||||
return lower-0.5, upper+0.5
|
||||
else:
|
||||
return lower, upper
|
||||
if spec == 'automatic':
|
||||
range = upper-lower
|
||||
if range == 0.:
|
||||
return lower-0.5, upper+0.5
|
||||
log = Numeric.log10(range)
|
||||
power = Numeric.floor(log)
|
||||
fraction = log-power
|
||||
if fraction <= 0.05:
|
||||
power = power-1
|
||||
grid = 10.**power
|
||||
lower = lower - lower % grid
|
||||
mod = upper % grid
|
||||
if mod != 0:
|
||||
upper = upper - mod + grid
|
||||
return lower, upper
|
||||
if type(spec) == type(()):
|
||||
lower, upper = spec
|
||||
if lower <= upper:
|
||||
return lower, upper
|
||||
else:
|
||||
return upper, lower
|
||||
raise ValueError, str(spec) + ': illegal axis specification'
|
||||
|
||||
def _drawAxes(self, dc, xaxis, yaxis,
|
||||
bb1, bb2, scale, shift, xticks, yticks):
|
||||
dc.SetPen(wx.wxPen(wx.wxNamedColour('BLACK'),1))
|
||||
if xaxis is not None:
|
||||
lower, upper = xaxis
|
||||
text = 1
|
||||
for y, d in [(bb1[1], -3), (bb2[1], 3)]:
|
||||
p1 = scale*Numeric.array([lower, y])+shift
|
||||
p2 = scale*Numeric.array([upper, y])+shift
|
||||
dc.DrawLine(p1[0],p1[1],p2[0],p2[1])
|
||||
for x, label in xticks:
|
||||
p = scale*Numeric.array([x, y])+shift
|
||||
dc.DrawLine(p[0],p[1],p[0],p[1]+d)
|
||||
if text:
|
||||
dc.DrawText(label,p[0],p[1])
|
||||
text = 0
|
||||
|
||||
if yaxis is not None:
|
||||
lower, upper = yaxis
|
||||
text = 1
|
||||
h = dc.GetCharHeight()
|
||||
for x, d in [(bb1[0], -3), (bb2[0], 3)]:
|
||||
p1 = scale*Numeric.array([x, lower])+shift
|
||||
p2 = scale*Numeric.array([x, upper])+shift
|
||||
dc.DrawLine(p1[0],p1[1],p2[0],p2[1])
|
||||
for y, label in yticks:
|
||||
p = scale*Numeric.array([x, y])+shift
|
||||
dc.DrawLine(p[0],p[1],p[0]-d,p[1])
|
||||
if text:
|
||||
dc.DrawText(label,p[0]-dc.GetTextExtent(label)[0],
|
||||
p[1]-0.5*h)
|
||||
text = 0
|
||||
|
||||
def _ticks(self, lower, upper):
|
||||
ideal = (upper-lower)/7.
|
||||
log = Numeric.log10(ideal)
|
||||
power = Numeric.floor(log)
|
||||
fraction = log-power
|
||||
factor = 1.
|
||||
error = fraction
|
||||
for f, lf in self._multiples:
|
||||
e = Numeric.fabs(fraction-lf)
|
||||
if e < error:
|
||||
error = e
|
||||
factor = f
|
||||
grid = factor * 10.**power
|
||||
if power > 3 or power < -3:
|
||||
format = '%+7.0e'
|
||||
elif power >= 0:
|
||||
digits = max(1, int(power))
|
||||
format = '%' + `digits`+'.0f'
|
||||
else:
|
||||
digits = -int(power)
|
||||
format = '%'+`digits+2`+'.'+`digits`+'f'
|
||||
ticks = []
|
||||
t = -grid*Numeric.floor(-lower/grid)
|
||||
while t <= upper:
|
||||
ticks.append(t, format % (t,))
|
||||
t = t + grid
|
||||
return ticks
|
||||
|
||||
_multiples = [(2., Numeric.log10(2.)), (5., Numeric.log10(5.))]
|
||||
|
||||
def redraw(self,dc=None):
|
||||
if self.last_draw is not None:
|
||||
apply(self.draw, self.last_draw + (dc,))
|
||||
|
||||
def clear(self):
|
||||
self.canvas.delete('all')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone...
|
||||
#
|
||||
# ...a sample implementation using the above
|
||||
#
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def _InitObjects():
|
||||
# 100 points sin function, plotted as green circles
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
|
||||
data1.shape = (100, 2)
|
||||
data1[:,1] = Numeric.sin(data1[:,0])
|
||||
markers1 = PolyMarker(data1, color='green', marker='circle',size=1)
|
||||
|
||||
# 50 points cos function, plotted as red line
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
|
||||
data1.shape = (50,2)
|
||||
data1[:,1] = Numeric.cos(data1[:,0])
|
||||
lines = PolyLine(data1, color='red')
|
||||
|
||||
# A few more points...
|
||||
pi = Numeric.pi
|
||||
markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
|
||||
(3.*pi/4., -1)], color='blue',
|
||||
fillcolor='green', marker='cross')
|
||||
|
||||
return PlotGraphics([markers1, lines, markers2])
|
||||
|
||||
|
||||
class AppFrame(wx.wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wx.wxFrame.__init__(self, parent, id, title,
|
||||
wx.wxPyDefaultPosition, wx.wxSize(400, 400))
|
||||
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wx.wxMenuBar()
|
||||
|
||||
menu = wx.wxMenu()
|
||||
menu.Append(200, '&Print...', 'Print the current plot')
|
||||
wx.EVT_MENU(self, 200, self.OnFilePrint)
|
||||
menu.Append(209, 'E&xit', 'Enough of this already!')
|
||||
wx.EVT_MENU(self, 209, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
menu = wx.wxMenu()
|
||||
menu.Append(210, '&Draw', 'Draw plots')
|
||||
wx.EVT_MENU(self,210,self.OnPlotDraw)
|
||||
menu.Append(211, '&Redraw', 'Redraw plots')
|
||||
wx.EVT_MENU(self,211,self.OnPlotRedraw)
|
||||
menu.Append(212, '&Clear', 'Clear canvas')
|
||||
wx.EVT_MENU(self,212,self.OnPlotClear)
|
||||
self.mainmenu.Append(menu, '&Plot')
|
||||
|
||||
menu = wx.wxMenu()
|
||||
menu.Append(220, '&About', 'About this thing...')
|
||||
wx.EVT_MENU(self, 220, self.OnHelpAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
# A status bar to tell people what's happening
|
||||
self.CreateStatusBar(1)
|
||||
|
||||
self.client = PlotCanvas(self)
|
||||
|
||||
def OnFilePrint(self, event):
|
||||
d = wx.wxMessageDialog(self,
|
||||
"""As of this writing, printing support in wxPython is shaky at best.
|
||||
Are you sure you want to do this?""", "Danger!", wx.wxYES_NO)
|
||||
if d.ShowModal() == wx.wxID_YES:
|
||||
psdc = wx.wxPostScriptDC("out.ps", wx.TRUE, self)
|
||||
self.client.redraw(psdc)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnPlotDraw(self, event):
|
||||
self.client.draw(_InitObjects(),'automatic','automatic');
|
||||
|
||||
def OnPlotRedraw(self,event):
|
||||
self.client.redraw()
|
||||
|
||||
def OnPlotClear(self,event):
|
||||
self.client.last_draw = None
|
||||
dc = wx.wxClientDC(self.client)
|
||||
dc.Clear()
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = wx.wxMessageDialog(self, __doc__, "About...", wx.wxOK)
|
||||
about.ShowModal()
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
class MyApp(wx.wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(wx.NULL, -1, "wxPlotCanvas")
|
||||
frame.Show(wx.TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return wx.TRUE
|
||||
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
@ -5,10 +5,12 @@ Setup
|
||||
Setup.save
|
||||
Setup.save
|
||||
config.c
|
||||
glcanvasc.exp
|
||||
make.bat
|
||||
sedscript
|
||||
templates
|
||||
transfer.zip
|
||||
utilsc.exp
|
||||
vc50.pdb
|
||||
vc60.pdb
|
||||
wxPython.001
|
||||
|
@ -325,7 +325,7 @@ distclean: clobber
|
||||
#
|
||||
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -D__WXGTK__
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -D__WXGTK__ $(SEPARATE)
|
||||
|
||||
|
||||
PYMODULES = $(GENCODEDIR)/wx.py $(GENCODEDIR)/events.py \
|
||||
@ -350,6 +350,12 @@ $(GENCODEDIR)/%.py : %.i
|
||||
$(GENCODEDIR)/wx.cpp $(GENCODEDIR)/wx.py : wx.i my_typemaps.i _defs.i _extras.py
|
||||
swig $(SWIGFLAGS) -o $(GENCODEDIR)/wx.cpp wx.i
|
||||
|
||||
ifdef SEPARATE
|
||||
$(GENCODEDIR)/utils.cpp $(GENCODEDIR)/utils.py : utils.i my_typemaps.i
|
||||
swig $(SWIGFLAGS) -o $(GENCODEDIR)/utils.cpp utils.i
|
||||
else
|
||||
$(GENCODEDIR)/utils.cpp $(GENCODEDIR)/utils.py : utils.i my_typemaps.i _defs.i
|
||||
endif
|
||||
|
||||
# define some dependencies
|
||||
$(GENCODEDIR)/windows.cpp $(GENCODEDIR)/windows.py : windows.i my_typemaps.i _defs.i
|
||||
|
@ -1,44 +1,47 @@
|
||||
# This file gives the details of what is needed to build this extension
|
||||
# module so the Makefile can be created.
|
||||
## This file gives the details of what is needed to build this extension
|
||||
## module so the Makefile can be created.
|
||||
|
||||
###
|
||||
### This file should be created by configure. Currently it is tweaked by hand.
|
||||
###
|
||||
## If you have not done "make install" for wxWindows then see Setup.in.linux
|
||||
## for a more verbose version of this file.
|
||||
|
||||
*shared*
|
||||
|
||||
CCC=c++
|
||||
WXWIN=../../..
|
||||
GENCODEDIR=gtk
|
||||
srcdir=$(GENCODEDIR)
|
||||
WX_CONFIG_CFLAGS=`wx-config --cflags`
|
||||
WX_CONFIG_LIBS=`wx-config --libs`
|
||||
|
||||
# Depending on how your Python was built, you may have to set this
|
||||
# value to use the C++ driver to link with instead of the default
|
||||
# C driver. For example:
|
||||
|
||||
## Depending on how your Python was built, you may have to set this
|
||||
## value to use the C++ driver to link with instead of the default
|
||||
## C driver. For example:
|
||||
MY_LDSHARED=$(CCC) -shared
|
||||
|
||||
# Same as above, but for statically linking Python and wxPython together,
|
||||
# in other words, if you comment out the *shared* above. If this is the
|
||||
# case then you should ensure that the main() function is Python's, not
|
||||
# wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
# to force this...
|
||||
## Same as above, but for statically linking Python and wxPython together,
|
||||
## in other words, if you comment out the *shared* above. If this is the
|
||||
## case then you should ensure that the main() function is Python's, not
|
||||
## wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
## to force this...
|
||||
MY_LINKCC=$(CCC)
|
||||
|
||||
|
||||
## Pick one of these, or set your own. This is where the
|
||||
## wxPython module should be installed. It should be a
|
||||
## subdirectory named wxPython.
|
||||
## Pick one of these, or set your own. This is where the wxPython module
|
||||
## should be installed. It should be a subdirectory named wxPython.
|
||||
TARGETDIR=..
|
||||
#TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
#TARGETDIR=$(BINLIBDEST)/wxPython
|
||||
|
||||
SEPARATE=-DSEPARATE
|
||||
|
||||
utilsc utils.cpp \
|
||||
-I. $(WX_CONFIG_CFLAGS) \
|
||||
-DSWIG_GLOBAL -DWXP_WITH_THREAD $(SEPARATE) -Xlinker $(WX_CONFIG_LIBS)
|
||||
|
||||
wxc wx.cpp helpers.cpp windows.cpp events.cpp misc.cpp gdi.cpp \
|
||||
mdi.cpp controls.cpp controls2.cpp windows2.cpp cmndlgs.cpp \
|
||||
frames.cpp stattool.cpp utils.cpp windows3.cpp \
|
||||
# CFLAGS
|
||||
-I. -I$(WXWIN)/include -I/usr/lib/glib/include -I$(WXWIN)/src \
|
||||
-I/usr/X11R6/include -DSWIG_GLOBAL -D__WXGTK__ \
|
||||
#-D__WXDEBUG__ \
|
||||
# LFLAGS
|
||||
-L$(WXWIN)/lib/Linux -L/usr/X11R6/lib \
|
||||
-lwx_gtk2 -lgtk -lgdk -lglib -lXext -lX11
|
||||
frames.cpp stattool.cpp windows3.cpp \
|
||||
-I. $(WX_CONFIG_CFLAGS) -I/usr/local/lib/glib/include \
|
||||
-DSWIG_GLOBAL -DWXP_WITH_THREAD $(SEPARATE) -Xlinker $(WX_CONFIG_LIBS)
|
||||
|
||||
|
||||
|
@ -31,13 +31,25 @@ MY_LINKCC=$(CCC)
|
||||
TARGETDIR=..
|
||||
#TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
|
||||
SEPARATE=-DSEPARATE
|
||||
|
||||
wxc wx.cpp helpers.cpp windows.cpp events.cpp misc.cpp gdi.cpp \
|
||||
mdi.cpp controls.cpp controls2.cpp windows2.cpp cmndlgs.cpp \
|
||||
frames.cpp stattool.cpp utils.cpp windows3.cpp \
|
||||
frames.cpp stattool.cpp windows3.cpp \
|
||||
# CFLAGS
|
||||
-I. -I$(WXWIN)/include -I/usr/lib/glib/include -I$(WXWIN)/src \
|
||||
-I/usr/X11R6/include -DSWIG_GLOBAL -D__WXGTK__ \
|
||||
-DWXP_WITH_THREAD $(SEPARATE) \
|
||||
#-D__WXDEBUG__ \
|
||||
# LFLAGS
|
||||
-L$(WXWIN)/lib/Linux -L/usr/X11R6/lib \
|
||||
-lwx_gtk2 -lgtk -lgdk -lglib -lXext -lX11
|
||||
|
||||
utilsc utils.cpp \
|
||||
# CFLAGS
|
||||
-I. -I$(WXWIN)/include -I/usr/lib/glib/include -I$(WXWIN)/src \
|
||||
-I/usr/X11R6/include -DSWIG_GLOBAL -D__WXGTK__ \
|
||||
-DWXP_WITH_THREAD $(SEPARATE) \
|
||||
#-D__WXDEBUG__ \
|
||||
# LFLAGS
|
||||
-L$(WXWIN)/lib/Linux -L/usr/X11R6/lib \
|
||||
|
@ -254,6 +254,7 @@ enum {
|
||||
wxSL_SELRANGE,
|
||||
wxSB_HORIZONTAL,
|
||||
wxSB_VERTICAL,
|
||||
wxST_SIZEGRIP,
|
||||
wxBU_AUTODRAW,
|
||||
wxBU_NOAUTODRAW,
|
||||
wxTR_HAS_BUTTONS,
|
||||
@ -283,11 +284,6 @@ enum {
|
||||
wxSP_NOBORDER,
|
||||
wxSP_3D,
|
||||
wxSP_BORDER,
|
||||
wxTAB_MULTILINE,
|
||||
wxTAB_RIGHTJUSTIFY,
|
||||
wxTAB_FIXEDWIDTH,
|
||||
wxTAB_OWNERDRAW,
|
||||
// wxSB_SIZEGRIP,
|
||||
wxFLOOD_SURFACE,
|
||||
wxFLOOD_BORDER,
|
||||
wxODDEVEN_RULE,
|
||||
@ -362,6 +358,7 @@ enum {
|
||||
wxID_APPLY,
|
||||
wxID_YES,
|
||||
wxID_NO,
|
||||
wxID_STATIC,
|
||||
wxBITMAP_TYPE_BMP,
|
||||
wxBITMAP_TYPE_BMP_RESOURCE,
|
||||
wxBITMAP_TYPE_ICO,
|
||||
@ -380,6 +377,7 @@ enum {
|
||||
wxBITMAP_TYPE_PNG_RESOURCE,
|
||||
wxBITMAP_TYPE_ANY,
|
||||
wxBITMAP_TYPE_RESOURCE,
|
||||
wxBITMAP_TYPE_JPEG,
|
||||
|
||||
wxOPEN,
|
||||
wxSAVE,
|
||||
@ -392,14 +390,14 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
/// Standard error codes
|
||||
enum ErrCode
|
||||
{
|
||||
ERR_PARAM = (-4000),
|
||||
ERR_NODATA,
|
||||
ERR_CANCEL,
|
||||
ERR_SUCCESS = 0
|
||||
};
|
||||
// // Standard error codes
|
||||
// enum ErrCode
|
||||
// {
|
||||
// ERR_PARAM = (-4000),
|
||||
// ERR_NODATA,
|
||||
// ERR_CANCEL,
|
||||
// ERR_SUCCESS = 0
|
||||
// };
|
||||
|
||||
|
||||
enum {
|
||||
@ -576,6 +574,81 @@ typedef enum {
|
||||
} _standard_cursors_t;
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
wxPAPER_NONE, // Use specific dimensions
|
||||
wxPAPER_LETTER, // Letter, 8 1/2 by 11 inches
|
||||
wxPAPER_LEGAL, // Legal, 8 1/2 by 14 inches
|
||||
wxPAPER_A4, // A4 Sheet, 210 by 297 millimeters
|
||||
wxPAPER_CSHEET, // C Sheet, 17 by 22 inches
|
||||
wxPAPER_DSHEET, // D Sheet, 22 by 34 inches
|
||||
wxPAPER_ESHEET, // E Sheet, 34 by 44 inches
|
||||
wxPAPER_LETTERSMALL, // Letter Small, 8 1/2 by 11 inches
|
||||
wxPAPER_TABLOID, // Tabloid, 11 by 17 inches
|
||||
wxPAPER_LEDGER, // Ledger, 17 by 11 inches
|
||||
wxPAPER_STATEMENT, // Statement, 5 1/2 by 8 1/2 inches
|
||||
wxPAPER_EXECUTIVE, // Executive, 7 1/4 by 10 1/2 inches
|
||||
wxPAPER_A3, // A3 sheet, 297 by 420 millimeters
|
||||
wxPAPER_A4SMALL, // A4 small sheet, 210 by 297 millimeters
|
||||
wxPAPER_A5, // A5 sheet, 148 by 210 millimeters
|
||||
wxPAPER_B4, // B4 sheet, 250 by 354 millimeters
|
||||
wxPAPER_B5, // B5 sheet, 182-by-257-millimeter paper
|
||||
wxPAPER_FOLIO, // Folio, 8-1/2-by-13-inch paper
|
||||
wxPAPER_QUARTO, // Quarto, 215-by-275-millimeter paper
|
||||
wxPAPER_10X14, // 10-by-14-inch sheet
|
||||
wxPAPER_11X17, // 11-by-17-inch sheet
|
||||
wxPAPER_NOTE, // Note, 8 1/2 by 11 inches
|
||||
wxPAPER_ENV_9, // #9 Envelope, 3 7/8 by 8 7/8 inches
|
||||
wxPAPER_ENV_10, // #10 Envelope, 4 1/8 by 9 1/2 inches
|
||||
wxPAPER_ENV_11, // #11 Envelope, 4 1/2 by 10 3/8 inches
|
||||
wxPAPER_ENV_12, // #12 Envelope, 4 3/4 by 11 inches
|
||||
wxPAPER_ENV_14, // #14 Envelope, 5 by 11 1/2 inches
|
||||
wxPAPER_ENV_DL, // DL Envelope, 110 by 220 millimeters
|
||||
wxPAPER_ENV_C5, // C5 Envelope, 162 by 229 millimeters
|
||||
wxPAPER_ENV_C3, // C3 Envelope, 324 by 458 millimeters
|
||||
wxPAPER_ENV_C4, // C4 Envelope, 229 by 324 millimeters
|
||||
wxPAPER_ENV_C6, // C6 Envelope, 114 by 162 millimeters
|
||||
wxPAPER_ENV_C65, // C65 Envelope, 114 by 229 millimeters
|
||||
wxPAPER_ENV_B4, // B4 Envelope, 250 by 353 millimeters
|
||||
wxPAPER_ENV_B5, // B5 Envelope, 176 by 250 millimeters
|
||||
wxPAPER_ENV_B6, // B6 Envelope, 176 by 125 millimeters
|
||||
wxPAPER_ENV_ITALY, // Italy Envelope, 110 by 230 millimeters
|
||||
wxPAPER_ENV_MONARCH, // Monarch Envelope, 3 7/8 by 7 1/2 inches
|
||||
wxPAPER_ENV_PERSONAL, // 6 3/4 Envelope, 3 5/8 by 6 1/2 inches
|
||||
wxPAPER_FANFOLD_US, // US Std Fanfold, 14 7/8 by 11 inches
|
||||
wxPAPER_FANFOLD_STD_GERMAN, // German Std Fanfold, 8 1/2 by 12 inches
|
||||
wxPAPER_FANFOLD_LGL_GERMAN, // German Legal Fanfold, 8 1/2 by 13 inches
|
||||
|
||||
wxPAPER_ISO_B4, // B4 (ISO) 250 x 353 mm
|
||||
wxPAPER_JAPANESE_POSTCARD, // Japanese Postcard 100 x 148 mm
|
||||
wxPAPER_9X11, // 9 x 11 in
|
||||
wxPAPER_10X11, // 10 x 11 in
|
||||
wxPAPER_15X11, // 15 x 11 in
|
||||
wxPAPER_ENV_INVITE, // Envelope Invite 220 x 220 mm
|
||||
wxPAPER_LETTER_EXTRA, // Letter Extra 9 \275 x 12 in
|
||||
wxPAPER_LEGAL_EXTRA, // Legal Extra 9 \275 x 15 in
|
||||
wxPAPER_TABLOID_EXTRA, // Tabloid Extra 11.69 x 18 in
|
||||
wxPAPER_A4_EXTRA, // A4 Extra 9.27 x 12.69 in
|
||||
wxPAPER_LETTER_TRANSVERSE, // Letter Transverse 8 \275 x 11 in
|
||||
wxPAPER_A4_TRANSVERSE, // A4 Transverse 210 x 297 mm
|
||||
wxPAPER_LETTER_EXTRA_TRANSVERSE, // Letter Extra Transverse 9\275 x 12 in
|
||||
wxPAPER_A_PLUS, // SuperA/SuperA/A4 227 x 356 mm
|
||||
wxPAPER_B_PLUS, // SuperB/SuperB/A3 305 x 487 mm
|
||||
wxPAPER_LETTER_PLUS, // Letter Plus 8.5 x 12.69 in
|
||||
wxPAPER_A4_PLUS, // A4 Plus 210 x 330 mm
|
||||
wxPAPER_A5_TRANSVERSE, // A5 Transverse 148 x 210 mm
|
||||
wxPAPER_B5_TRANSVERSE, // B5 (JIS) Transverse 182 x 257 mm
|
||||
wxPAPER_A3_EXTRA, // A3 Extra 322 x 445 mm
|
||||
wxPAPER_A5_EXTRA, // A5 Extra 174 x 235 mm
|
||||
wxPAPER_B5_EXTRA, // B5 (ISO) Extra 201 x 276 mm
|
||||
wxPAPER_A2, // A2 420 x 594 mm
|
||||
wxPAPER_A3_TRANSVERSE, // A3 Transverse 297 x 420 mm
|
||||
wxPAPER_A3_EXTRA_TRANSVERSE // A3 Extra Transverse 322 x 445 mm
|
||||
|
||||
} wxPaperSize ;
|
||||
|
||||
|
||||
|
||||
#define FALSE 0
|
||||
#define false 0
|
||||
#define TRUE 1
|
||||
@ -756,7 +829,26 @@ enum wxEventType {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.13 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.12.4.2 1999/03/28 06:35:01 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.12.4.1 1999/03/27 23:29:13 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.12 1999/02/27 04:21:58 RD
|
||||
//
|
||||
// Added missing wxRA_SPECIFY_ROWS, wxRA_SPECIFY_COLS
|
||||
//
|
||||
// Revision 1.11 1999/02/20 09:02:54 RD
|
||||
|
@ -35,8 +35,9 @@ def _StdWindowCallbacks(win):
|
||||
_checkForCallback(win, "OnEraseBackground", wxEVT_ERASE_BACKGROUND)
|
||||
_checkForCallback(win, "OnSysColourChanged", wxEVT_SYS_COLOUR_CHANGED)
|
||||
_checkForCallback(win, "OnInitDialog", wxEVT_INIT_DIALOG)
|
||||
_checkForCallback(win, "OnIdle", wxEVT_IDLE)
|
||||
_checkForCallback(win, "OnPaint", wxEVT_PAINT)
|
||||
_checkForCallback(win, "OnIdle", wxEVT_IDLE)
|
||||
|
||||
|
||||
def _StdFrameCallbacks(win):
|
||||
_StdWindowCallbacks(win)
|
||||
@ -54,7 +55,7 @@ def _StdDialogCallbacks(win):
|
||||
_checkForCallback(win, "OnCharHook", wxEVT_CHAR_HOOK)
|
||||
|
||||
|
||||
def _StdOnScrollCallback(win):
|
||||
def _StdOnScrollCallbacks(win):
|
||||
try: cb = getattr(win, "OnScroll")
|
||||
except: pass
|
||||
else: EVT_SCROLL(win, cb)
|
||||
@ -133,6 +134,9 @@ def EVT_ICONIZE(win, func):
|
||||
def EVT_NAVIGATION_KEY(win, func):
|
||||
win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func)
|
||||
|
||||
def EVT_IDLE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_IDLE, func)
|
||||
|
||||
|
||||
# Mouse Events
|
||||
def EVT_LEFT_DOWN(win, func):
|
||||
@ -559,27 +563,32 @@ class wxAcceleratorTable(wxAcceleratorTablePtr):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
## class wxPyStdOutWindow(wxFrame):
|
||||
## def __init__(self, title = "wxPython: stdout/stderr"):
|
||||
## wxFrame.__init__(self, NULL, title)
|
||||
## self.title = title
|
||||
## self.text = wxTextWindow(self)
|
||||
## self.text.SetFont(wxFont(10, wxMODERN, wxNORMAL, wxBOLD))
|
||||
## self.SetSize(-1,-1,400,200)
|
||||
## self.Show(false)
|
||||
## self.isShown = false
|
||||
## class wxPyStdOutWindow:
|
||||
## def __init__(self, title = "wxPython: stdout/stderr"):
|
||||
## self.frame = None
|
||||
## self.title = title
|
||||
|
||||
## def write(self, str): # with this method,
|
||||
## if not self.isShown:
|
||||
## self.Show(true)
|
||||
## self.isShown = true
|
||||
## self.text.WriteText(str)
|
||||
## def write(self, str):
|
||||
## if not self.frame:
|
||||
## self.frame = wxFrame(NULL, -1, self.title)
|
||||
## self.text = wxTextCtrl(self.frame, -1, "", wxPoint(0,0), wxDefaultSize,
|
||||
## wxTE_MULTILINE|wxTE_READONLY)
|
||||
## self.frame.SetSize(wxSize(450, 300))
|
||||
## self.frame.Show(true)
|
||||
## EVT_CLOSE(self.frame, self.OnCloseWindow)
|
||||
## self.text.AppendText(str)
|
||||
|
||||
## def OnCloseWindow(self, event): # doesn't allow the window to close, just hides it
|
||||
## self.Show(false)
|
||||
## self.isShown = false
|
||||
## def OnCloseWindow(self, event):
|
||||
## wxBell()
|
||||
## self.frame.Destroy()
|
||||
## self.frame = None
|
||||
## self.text = None
|
||||
|
||||
|
||||
## def close(self):
|
||||
## if self.frame:
|
||||
## self.frame.Close(true)
|
||||
|
||||
_defRedirect = (wxPlatform == '__WXMSW__')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -610,20 +619,36 @@ class wxApp(wxPyApp):
|
||||
if filename:
|
||||
sys.stdout = sys.stderr = open(filename, 'a')
|
||||
else:
|
||||
raise self.error, 'wxPyStdOutWindow not yet implemented.'
|
||||
#self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow()
|
||||
#raise self.error, 'wxPyStdOutWindow not yet implemented.'
|
||||
self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow()
|
||||
|
||||
def RestoreStdio(self):
|
||||
sys.stdout, sys.stderr = self.saveStdio
|
||||
if self.stdioWin != None:
|
||||
self.stdioWin.Show(false)
|
||||
self.stdioWin.Destroy()
|
||||
self.stdioWin = None
|
||||
self.stdioWin.close()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.12 1999/04/30 03:29:18 RD
|
||||
# wxPython 2.0b9, first phase (win32)
|
||||
# Added gobs of stuff, see wxPython/README.txt for details
|
||||
#
|
||||
# Revision 1.11.4.2 1999/03/28 06:35:01 RD
|
||||
#
|
||||
# wxPython 2.0b8
|
||||
# Python thread support
|
||||
# various minor additions
|
||||
# various minor fixes
|
||||
#
|
||||
# Revision 1.11.4.1 1999/03/27 23:29:13 RD
|
||||
#
|
||||
# wxPython 2.0b8
|
||||
# Python thread support
|
||||
# various minor additions
|
||||
# various minor fixes
|
||||
#
|
||||
# Revision 1.11 1999/02/20 09:02:55 RD
|
||||
# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
# window handle. If you can get the window handle into the python code,
|
||||
|
@ -198,22 +198,17 @@ public:
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxPageSetupData {
|
||||
|
||||
class wxPageSetupDialogData {
|
||||
public:
|
||||
wxPageSetupData();
|
||||
~wxPageSetupData();
|
||||
wxPageSetupDialogData();
|
||||
~wxPageSetupDialogData();
|
||||
|
||||
void EnableHelp(bool flag);
|
||||
void EnableMargins(bool flag);
|
||||
void EnableOrientation(bool flag);
|
||||
void EnablePaper(bool flag);
|
||||
void EnablePrinter(bool flag);
|
||||
wxPoint GetPaperSize();
|
||||
wxPoint GetMarginTopLeft();
|
||||
wxPoint GetMarginBottomRight();
|
||||
wxPoint GetMinMarginTopLeft();
|
||||
wxPoint GetMinMarginBottomRight();
|
||||
int GetOrientation();
|
||||
bool GetDefaultMinMargins();
|
||||
bool GetEnableMargins();
|
||||
bool GetEnableOrientation();
|
||||
@ -221,33 +216,42 @@ public:
|
||||
bool GetEnablePrinter();
|
||||
bool GetEnableHelp();
|
||||
bool GetDefaultInfo();
|
||||
void SetPaperSize(const wxPoint& size);
|
||||
wxPoint GetMarginTopLeft();
|
||||
wxPoint GetMarginBottomRight();
|
||||
wxPoint GetMinMarginTopLeft();
|
||||
wxPoint GetMinMarginBottomRight();
|
||||
wxPaperSize GetPaperId();
|
||||
wxSize GetPaperSize();
|
||||
wxPrintData& GetPrintData();
|
||||
void SetDefaultInfo(bool flag);
|
||||
void SetDefaultMinMargins(bool flag);
|
||||
void SetMarginTopLeft(const wxPoint& pt);
|
||||
void SetMarginBottomRight(const wxPoint& pt);
|
||||
void SetMinMarginTopLeft(const wxPoint& pt);
|
||||
void SetMinMarginBottomRight(const wxPoint& pt);
|
||||
void SetOrientation(int orientation);
|
||||
void SetDefaultMinMargins(bool flag);
|
||||
void SetDefaultInfo(bool flag);
|
||||
void SetPaperId(wxPaperSize& id);
|
||||
void SetPaperSize(const wxSize& size);
|
||||
void SetPrintData(const wxPrintData& printData);
|
||||
};
|
||||
|
||||
|
||||
class wxPageSetupDialog : public wxDialog {
|
||||
public:
|
||||
wxPageSetupDialog(wxWindow* parent, wxPageSetupData* data = NULL);
|
||||
wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
|
||||
|
||||
%pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
|
||||
|
||||
wxPageSetupData& GetPageSetupData();
|
||||
wxPageSetupDialogData& GetPageSetupData();
|
||||
int ShowModal();
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxPrintData {
|
||||
|
||||
class wxPrintDialogData {
|
||||
public:
|
||||
wxPrintData();
|
||||
~wxPrintData();
|
||||
wxPrintDialogData();
|
||||
~wxPrintDialogData();
|
||||
|
||||
void EnableHelp(bool flag);
|
||||
void EnablePageNumbers(bool flag);
|
||||
@ -259,14 +263,15 @@ public:
|
||||
int GetMaxPage();
|
||||
int GetMinPage();
|
||||
int GetNoCopies();
|
||||
int GetOrientation();
|
||||
wxPrintData& GetPrintData();
|
||||
bool GetPrintToFile();
|
||||
int GetToPage();
|
||||
void SetCollate(bool flag);
|
||||
void SetFromPage(int page);
|
||||
void SetMaxPage(int page);
|
||||
void SetMinPage(int page);
|
||||
void SetOrientation(int orientation);
|
||||
void SetNoCopies(int n);
|
||||
void SetPrintData(const wxPrintData& printData);
|
||||
void SetPrintToFile(bool flag);
|
||||
void SetSetupDialog(bool flag);
|
||||
void SetToPage(int page);
|
||||
@ -275,11 +280,11 @@ public:
|
||||
|
||||
class wxPrintDialog : public wxDialog {
|
||||
public:
|
||||
wxPrintDialog(wxWindow* parent, wxPrintData* data = NULL);
|
||||
wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
|
||||
|
||||
%pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
|
||||
|
||||
wxPrintData& GetPrintData();
|
||||
wxPrintDialogData& GetPrintDialogData();
|
||||
%new wxDC* GetPrintDC();
|
||||
int ShowModal();
|
||||
};
|
||||
@ -305,7 +310,12 @@ public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.9 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.8 1998/12/17 14:07:25 RR
|
||||
//
|
||||
// Removed minor differences between wxMSW and wxGTK
|
||||
//
|
||||
// Revision 1.7 1998/12/15 20:41:14 RD
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "helpers.h"
|
||||
#include <wx/slider.h>
|
||||
#include <wx/spinbutt.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
@ -255,7 +256,20 @@ public:
|
||||
int FindString(const wxString& string);
|
||||
// TODO: char* GetClientData(const int n);
|
||||
int GetSelection();
|
||||
// TODO: int GetSelections(int **selections);
|
||||
|
||||
// int GetSelections(int **selections);
|
||||
%addmethods {
|
||||
PyObject* GetSelections() {
|
||||
wxArrayInt lst;
|
||||
self->GetSelections(lst);
|
||||
PyObject *tup = PyTuple_New(lst.GetCount());
|
||||
for(int i=0; i<lst.GetCount(); i++) {
|
||||
PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
|
||||
}
|
||||
return tup;
|
||||
}
|
||||
}
|
||||
|
||||
wxString GetString(int n);
|
||||
wxString GetStringSelection();
|
||||
int Number();
|
||||
@ -328,6 +342,7 @@ public:
|
||||
void SetValue(const wxString& value);
|
||||
void ShowPosition(long pos);
|
||||
void WriteText(const wxString& text);
|
||||
void AppendText(const wxString& text);
|
||||
long XYToPosition(long x, long y);
|
||||
};
|
||||
|
||||
@ -384,7 +399,7 @@ public:
|
||||
|
||||
%pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
|
||||
|
||||
wxBitmap& GetBitmap();
|
||||
const wxBitmap& GetBitmap();
|
||||
void SetBitmap(const wxBitmap& bitmap);
|
||||
};
|
||||
|
||||
@ -483,7 +498,19 @@ public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.12 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.11.4.1 1999/03/27 23:29:14 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.11 1999/02/25 07:08:30 RD
|
||||
//
|
||||
// wxPython version 2.0b5
|
||||
//
|
||||
// Revision 1.10 1998/12/17 17:52:19 RD
|
||||
|
@ -233,20 +233,50 @@ public:
|
||||
|
||||
|
||||
|
||||
// **** This isn't very useful yet. This needs to be specialized to enable
|
||||
// derived Python classes...
|
||||
class wxTreeItemData {
|
||||
%{
|
||||
class wxPyTreeItemData : public wxTreeItemData {
|
||||
public:
|
||||
wxTreeItemData();
|
||||
~wxTreeItemData();
|
||||
wxPyTreeItemData(PyObject* obj = NULL) {
|
||||
if (obj == NULL)
|
||||
obj = Py_None;
|
||||
Py_INCREF(obj);
|
||||
m_obj = obj;
|
||||
}
|
||||
|
||||
~wxPyTreeItemData() {
|
||||
Py_DECREF(m_obj);
|
||||
}
|
||||
|
||||
PyObject* GetData() {
|
||||
Py_INCREF(m_obj);
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
void SetData(PyObject* obj) {
|
||||
Py_DECREF(m_obj);
|
||||
m_obj = obj;
|
||||
Py_INCREF(obj);
|
||||
}
|
||||
|
||||
PyObject* m_obj;
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
|
||||
%name(wxTreeItemData) class wxPyTreeItemData {
|
||||
public:
|
||||
wxPyTreeItemData(PyObject* obj = NULL);
|
||||
|
||||
PyObject* GetData();
|
||||
void SetData(PyObject* obj);
|
||||
|
||||
const wxTreeItemId& GetId();
|
||||
void SetId(const wxTreeItemId& id);
|
||||
void SetId(const wxTreeItemId& id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class wxTreeEvent : public wxCommandEvent {
|
||||
public:
|
||||
wxTreeItemId GetItem();
|
||||
@ -284,14 +314,50 @@ public:
|
||||
wxString GetItemText(const wxTreeItemId& item);
|
||||
int GetItemImage(const wxTreeItemId& item);
|
||||
int GetItemSelectedImage(const wxTreeItemId& item);
|
||||
wxTreeItemData *GetItemData(const wxTreeItemId& item);
|
||||
|
||||
void SetItemText(const wxTreeItemId& item, const wxString& text);
|
||||
void SetItemImage(const wxTreeItemId& item, int image);
|
||||
void SetItemSelectedImage(const wxTreeItemId& item, int image);
|
||||
void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
|
||||
void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE);
|
||||
|
||||
%addmethods {
|
||||
// [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
|
||||
// if needed.
|
||||
wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
|
||||
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||
if (data == NULL) {
|
||||
data = new wxPyTreeItemData();
|
||||
self->SetItemData(item, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
|
||||
self->SetItemData(item, data);
|
||||
}
|
||||
|
||||
// [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
|
||||
// automatically creating data classes.
|
||||
PyObject* GetPyData(const wxTreeItemId& item) {
|
||||
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||
if (data == NULL) {
|
||||
data = new wxPyTreeItemData();
|
||||
self->SetItemData(item, data);
|
||||
}
|
||||
return data->GetData();
|
||||
}
|
||||
|
||||
void SetPyData(const wxTreeItemId& item, PyObject* obj) {
|
||||
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||
if (data == NULL) {
|
||||
data = new wxPyTreeItemData(obj);
|
||||
self->SetItemData(item, data);
|
||||
} else
|
||||
data->SetData(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsVisible(const wxTreeItemId& item);
|
||||
bool ItemHasChildren(const wxTreeItemId& item);
|
||||
bool IsExpanded(const wxTreeItemId& item);
|
||||
@ -312,20 +378,20 @@ public:
|
||||
|
||||
wxTreeItemId AddRoot(const wxString& text,
|
||||
int image = -1, int selectedImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxPyTreeItemData *data = NULL);
|
||||
wxTreeItemId PrependItem(const wxTreeItemId& parent,
|
||||
const wxString& text,
|
||||
int image = -1, int selectedImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxPyTreeItemData *data = NULL);
|
||||
wxTreeItemId InsertItem(const wxTreeItemId& parent,
|
||||
const wxTreeItemId& idPrevious,
|
||||
const wxString& text,
|
||||
int image = -1, int selectedImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxPyTreeItemData *data = NULL);
|
||||
wxTreeItemId AppendItem(const wxTreeItemId& parent,
|
||||
const wxString& text,
|
||||
int image = -1, int selectedImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxPyTreeItemData *data = NULL);
|
||||
|
||||
void Delete(const wxTreeItemId& item);
|
||||
void DeleteChildren(const wxTreeItemId& item);
|
||||
@ -417,7 +483,12 @@ public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.17 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.16 1999/02/25 07:08:32 RD
|
||||
//
|
||||
// wxPython version 2.0b5
|
||||
//
|
||||
// Revision 1.15 1999/02/20 09:02:56 RD
|
||||
|
@ -70,9 +70,8 @@ public:
|
||||
long GetExtraLong();
|
||||
int GetInt();
|
||||
int GetSelection();
|
||||
char* GetString();
|
||||
wxString GetString();
|
||||
bool IsSelection();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -291,10 +290,32 @@ public:
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxPyEvent : public wxCommandEvent {
|
||||
public:
|
||||
wxPyEvent(wxEventType commandType = wxEVT_NULL, PyObject* userData = Py_None);
|
||||
~wxPyEvent();
|
||||
|
||||
void SetUserData(PyObject* userData);
|
||||
PyObject* GetUserData();
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.8 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.7.4.1 1999/03/27 23:29:14 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.7 1999/02/20 09:02:57 RD
|
||||
// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
// window handle. If you can get the window handle into the python code,
|
||||
|
@ -66,9 +66,10 @@ wxBitmap* wxNoRefBitmap(char* name, long flags);
|
||||
return new wxBitmap(width, height, depth);
|
||||
}
|
||||
|
||||
// This one won't own the reference, so Python won't call
|
||||
// the dtor, this is good for toolbars and such where
|
||||
// the parent will manage the bitmap.
|
||||
// This one won't own the reference, so Python
|
||||
// won't call the dtor, this is good for
|
||||
// toolbars and such where the parent will
|
||||
// manage the bitmap.
|
||||
wxBitmap* wxNoRefBitmap(char* name, long flags) {
|
||||
return new wxBitmap(name, flags);
|
||||
}
|
||||
@ -546,98 +547,3 @@ public:
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.14 1999/02/20 10:02:36 RD
|
||||
// Changes needed to enable wxGTK compatibility.
|
||||
//
|
||||
// Revision 1.13 1999/02/20 09:02:58 RD
|
||||
// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
// window handle. If you can get the window handle into the python code,
|
||||
// it should just work... More news on this later.
|
||||
//
|
||||
// Added wxImageList, wxToolTip.
|
||||
//
|
||||
// Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
|
||||
// wxRegConfig class.
|
||||
//
|
||||
// As usual, some bug fixes, tweaks, etc.
|
||||
//
|
||||
// Revision 1.12 1999/01/30 07:30:11 RD
|
||||
//
|
||||
// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
|
||||
//
|
||||
// Various cleanup, tweaks, minor additions, etc. to maintain
|
||||
// compatibility with the current wxWindows.
|
||||
//
|
||||
// Revision 1.11 1998/12/18 15:49:05 RR
|
||||
//
|
||||
// wxClipboard now serves the primary selection as well
|
||||
// wxPython fixes
|
||||
// warning mesages
|
||||
//
|
||||
// Revision 1.10 1998/12/17 18:05:50 RD
|
||||
//
|
||||
// wxPython 0.5.2
|
||||
// Minor fixes and SWIG code generation for RR's changes. MSW and GTK
|
||||
// versions are much closer now!
|
||||
//
|
||||
// Revision 1.9 1998/12/17 14:07:37 RR
|
||||
//
|
||||
// Removed minor differences between wxMSW and wxGTK
|
||||
//
|
||||
// Revision 1.8 1998/12/16 22:10:54 RD
|
||||
//
|
||||
// Tweaks needed to be able to build wxPython with wxGTK.
|
||||
//
|
||||
// Revision 1.7 1998/12/15 20:41:18 RD
|
||||
// Changed the import semantics from "from wxPython import *" to "from
|
||||
// wxPython.wx import *" This is for people who are worried about
|
||||
// namespace pollution, they can use "from wxPython import wx" and then
|
||||
// prefix all the wxPython identifiers with "wx."
|
||||
//
|
||||
// Added wxTaskbarIcon for wxMSW.
|
||||
//
|
||||
// Made the events work for wxGrid.
|
||||
//
|
||||
// Added wxConfig.
|
||||
//
|
||||
// Added wxMiniFrame for wxGTK, (untested.)
|
||||
//
|
||||
// Changed many of the args and return values that were pointers to gdi
|
||||
// objects to references to reflect changes in the wxWindows API.
|
||||
//
|
||||
// Other assorted fixes and additions.
|
||||
//
|
||||
// Revision 1.6 1998/11/25 08:45:24 RD
|
||||
//
|
||||
// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
|
||||
// Added events for wxGrid
|
||||
// Other various fixes and additions
|
||||
//
|
||||
// Revision 1.5 1998/10/20 06:43:57 RD
|
||||
// New wxTreeCtrl wrappers (untested)
|
||||
// some changes in helpers
|
||||
// etc.
|
||||
//
|
||||
// Revision 1.4 1998/10/02 06:40:38 RD
|
||||
//
|
||||
// Version 0.4 of wxPython for MSW.
|
||||
//
|
||||
// Revision 1.3 1998/08/18 19:48:16 RD
|
||||
// more wxGTK compatibility things.
|
||||
//
|
||||
// It builds now but there are serious runtime problems...
|
||||
//
|
||||
// Revision 1.2 1998/08/15 07:36:35 RD
|
||||
// - Moved the header in the .i files out of the code that gets put into
|
||||
// the .cpp files. It caused CVS conflicts because of the RCS ID being
|
||||
// different each time.
|
||||
//
|
||||
// - A few minor fixes.
|
||||
//
|
||||
// Revision 1.1 1998/08/09 08:25:50 RD
|
||||
// Initial version
|
||||
//
|
||||
//
|
||||
|
1093
utils/wxPython/src/glcanvas.i
Normal file
2
utils/wxPython/src/glcanvasc.def
Normal file
@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
initglcanvasc
|
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
#include <wx/module.h>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//wxHashTable* wxPyWindows = NULL;
|
||||
@ -62,6 +63,15 @@ BOOL WINAPI DllMain(
|
||||
wxPyApp *wxPythonApp = NULL; // Global instance of application object
|
||||
|
||||
|
||||
wxPyApp::wxPyApp() {
|
||||
// printf("**** ctor\n");
|
||||
}
|
||||
|
||||
wxPyApp::~wxPyApp() {
|
||||
// printf("**** dtor\n");
|
||||
}
|
||||
|
||||
|
||||
// This one isn't acutally called... See __wxStart()
|
||||
bool wxPyApp::OnInit(void) {
|
||||
return false;
|
||||
@ -139,7 +149,9 @@ void __wxPreStart()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
static PyThreadState *event_tstate = NULL;
|
||||
#endif
|
||||
static char* __nullArgv[1] = { 0 };
|
||||
|
||||
// Start the user application, user App's OnInit method is a parameter here
|
||||
@ -150,6 +162,9 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
|
||||
PyObject* result;
|
||||
long bResult;
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
event_tstate = PyThreadState_Get();
|
||||
#endif
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &onInitFunc))
|
||||
return NULL;
|
||||
@ -162,13 +177,18 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
|
||||
|
||||
// This is the next part of the wxEntry functionality...
|
||||
wxPythonApp->argc = 0;
|
||||
wxPythonApp->argv = __nullArgv;
|
||||
wxPythonApp->argv = NULL;
|
||||
wxPythonApp->OnInitGui();
|
||||
|
||||
|
||||
// Call the Python App's OnInit function
|
||||
arglist = PyTuple_New(0);
|
||||
|
||||
// Py_END_ALLOW_THREADS; **** __wxStart was called from Python,
|
||||
// should already have the lock
|
||||
result = PyEval_CallObject(onInitFunc, arglist);
|
||||
// Py_BEGIN_ALLOW_THREADS;
|
||||
|
||||
if (!result) {
|
||||
PyErr_Print();
|
||||
exit(1);
|
||||
@ -260,6 +280,27 @@ PyObject* wxPyConstructObject(void* ptr, char* className)
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxPyCallback::wxPyCallback(PyObject* func) {
|
||||
m_func = func;
|
||||
Py_INCREF(m_func);
|
||||
}
|
||||
|
||||
wxPyCallback::~wxPyCallback() {
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(event_tstate);
|
||||
#endif
|
||||
|
||||
Py_DECREF(m_func);
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// This function is used for all events destined for Python event handlers.
|
||||
void wxPyCallback::EventThunker(wxEvent& event) {
|
||||
wxPyCallback* cb = (wxPyCallback*)event.m_callbackUserData;
|
||||
@ -268,6 +309,10 @@ void wxPyCallback::EventThunker(wxEvent& event) {
|
||||
PyObject* arg;
|
||||
PyObject* tuple;
|
||||
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(event_tstate);
|
||||
#endif
|
||||
arg = wxPyConstructObject((void*)&event, event.GetClassInfo()->GetClassName());
|
||||
|
||||
tuple = PyTuple_New(1);
|
||||
@ -280,6 +325,9 @@ void wxPyCallback::EventThunker(wxEvent& event) {
|
||||
} else {
|
||||
PyErr_Print();
|
||||
}
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -301,6 +349,9 @@ wxPyMenu::~wxPyMenu() {
|
||||
|
||||
|
||||
void wxPyMenu::MenuCallback(wxMenu& menu, wxCommandEvent& evt) {
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(event_tstate);
|
||||
#endif
|
||||
PyObject* evtobj = wxPyConstructObject((void*)&evt, "wxCommandEvent");
|
||||
PyObject* menuobj = wxPyConstructObject((void*)&menu, "wxMenu");
|
||||
if (PyErr_Occurred()) {
|
||||
@ -316,6 +367,9 @@ void wxPyMenu::MenuCallback(wxMenu& menu, wxCommandEvent& evt) {
|
||||
PyObject* res = PyEval_CallObject(func, args);
|
||||
Py_DECREF(args);
|
||||
Py_XDECREF(res); /* In case res is a NULL pointer */
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -331,6 +385,9 @@ wxPyTimer::~wxPyTimer() {
|
||||
}
|
||||
|
||||
void wxPyTimer::Notify() {
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(event_tstate);
|
||||
#endif
|
||||
PyObject* result;
|
||||
PyObject* args = Py_BuildValue("()");
|
||||
|
||||
@ -342,9 +399,49 @@ void wxPyTimer::Notify() {
|
||||
} else {
|
||||
PyErr_Print();
|
||||
}
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxCommandEvent)
|
||||
|
||||
wxPyEvent::wxPyEvent(wxEventType commandType, PyObject* userData)
|
||||
: wxCommandEvent(commandType), m_userData(Py_None)
|
||||
{
|
||||
m_userData = userData;
|
||||
if (m_userData != Py_None) {
|
||||
Py_INCREF(m_userData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxPyEvent::~wxPyEvent() {
|
||||
if (m_userData != Py_None) {
|
||||
Py_DECREF(m_userData);
|
||||
m_userData = Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxPyEvent::SetUserData(PyObject* userData) {
|
||||
if (m_userData != Py_None) {
|
||||
Py_DECREF(m_userData);
|
||||
m_userData = Py_None;
|
||||
}
|
||||
m_userData = userData;
|
||||
if (m_userData != Py_None) {
|
||||
Py_INCREF(m_userData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PyObject* wxPyEvent::GetUserData() {
|
||||
return m_userData;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
@ -584,6 +681,17 @@ wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source) {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.20 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.19.4.1 1999/03/27 23:29:14 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.19 1999/02/20 09:02:59 RD
|
||||
// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
// window handle. If you can get the window handle into the python code,
|
||||
|
@ -16,11 +16,29 @@
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// if we want to handle threads and Python threads are available...
|
||||
#if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
|
||||
|
||||
#define WXP_WITH_THREAD
|
||||
#define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
|
||||
#define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
|
||||
|
||||
#else // no Python threads...
|
||||
#undef WXP_WITH_THREAD
|
||||
#define wxPy_BEGIN_ALLOW_THREADS
|
||||
#define wxPy_END_ALLOW_THREADS
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxPyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
wxPyApp();
|
||||
~wxPyApp();
|
||||
int MainLoop(void);
|
||||
bool OnInit(void);
|
||||
void AfterMainLoop(void);
|
||||
@ -66,8 +84,8 @@ extern wxString wxPyEmptyStr;
|
||||
|
||||
class wxPyCallback : public wxObject {
|
||||
public:
|
||||
wxPyCallback(PyObject* func) { m_func = func; Py_INCREF(m_func); }
|
||||
~wxPyCallback() { Py_DECREF(m_func); }
|
||||
wxPyCallback(PyObject* func);
|
||||
~wxPyCallback();
|
||||
|
||||
void EventThunker(wxEvent& event);
|
||||
|
||||
@ -100,11 +118,38 @@ private:
|
||||
PyObject* func;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxPyEvent : public wxCommandEvent {
|
||||
DECLARE_DYNAMIC_CLASS(wxPyEvent)
|
||||
public:
|
||||
wxPyEvent(wxEventType commandType = wxEVT_NULL, PyObject* userData = Py_None);
|
||||
~wxPyEvent();
|
||||
|
||||
void SetUserData(PyObject* userData);
|
||||
PyObject* GetUserData();
|
||||
|
||||
private:
|
||||
PyObject* m_userData;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.7 1999/04/30 03:29:18 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.6.4.1 1999/03/27 23:29:14 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.6 1998/11/25 08:45:26 RD
|
||||
//
|
||||
// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
|
||||
// Added events for wxGrid
|
||||
// Other various fixes and additions
|
||||
|
152
utils/wxPython/src/image.i
Normal file
@ -0,0 +1,152 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: image.i
|
||||
// Purpose: SWIG interface file for wxImage, wxImageHandler, etc.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 28-Apr-1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%module image
|
||||
|
||||
%{
|
||||
#include "helpers.h"
|
||||
#include <wx/image.h>
|
||||
%}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
// Import some definitions of other classes, etc.
|
||||
%import _defs.i
|
||||
%import misc.i
|
||||
%import gdi.i
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxImageHandler {
|
||||
public:
|
||||
wxImageHandler();
|
||||
wxString GetName();
|
||||
wxString GetExtension();
|
||||
long GetType();
|
||||
wxString GetMimeType();
|
||||
|
||||
//bool LoadFile(wxImage* image, wxInputStream& stream);
|
||||
//bool SaveFile(wxImage* image, wxOutputStream& stream);
|
||||
|
||||
void SetName(const wxString& name);
|
||||
void SetExtension(const wxString& extension);
|
||||
void SetType(long type);
|
||||
void SetMimeType(const wxString& mimetype);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxPNGHandler : public wxImageHandler {
|
||||
public:
|
||||
wxPNGHandler();
|
||||
};
|
||||
|
||||
|
||||
class wxJPEGHandler : public wxImageHandler {
|
||||
public:
|
||||
wxJPEGHandler();
|
||||
};
|
||||
|
||||
|
||||
class wxBMPHandler : public wxImageHandler {
|
||||
public:
|
||||
wxBMPHandler();
|
||||
};
|
||||
|
||||
|
||||
class wxGIFHandler : public wxImageHandler {
|
||||
public:
|
||||
wxGIFHandler();
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxImage {
|
||||
public:
|
||||
wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG );
|
||||
~wxImage();
|
||||
|
||||
wxBitmap ConvertToBitmap();
|
||||
void Create( int width, int height );
|
||||
void Destroy();
|
||||
wxImage Scale( int width, int height );
|
||||
|
||||
void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
|
||||
unsigned char GetRed( int x, int y );
|
||||
unsigned char GetGreen( int x, int y );
|
||||
unsigned char GetBlue( int x, int y );
|
||||
|
||||
bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
|
||||
%name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
|
||||
|
||||
bool SaveFile( const wxString& name, int type );
|
||||
%name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
|
||||
|
||||
bool Ok();
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
|
||||
unsigned char *GetData();
|
||||
void SetData( unsigned char *data );
|
||||
|
||||
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
|
||||
unsigned char GetMaskRed();
|
||||
unsigned char GetMaskGreen();
|
||||
unsigned char GetMaskBlue();
|
||||
void SetMask( bool mask = TRUE );
|
||||
bool HasMask();
|
||||
|
||||
};
|
||||
|
||||
// Alternate constructors
|
||||
%new wxImage* wxNullImage();
|
||||
%new wxImage* wxEmptyImage(int width, int height);
|
||||
%new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype);
|
||||
%new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
|
||||
%{
|
||||
wxImage* wxNullImage() {
|
||||
return new wxImage;
|
||||
}
|
||||
|
||||
wxImage* wxEmptyImage(int width, int height) {
|
||||
return new wxImage(width, height);
|
||||
}
|
||||
|
||||
wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
|
||||
return new wxImage(name, mimetype);
|
||||
}
|
||||
|
||||
wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
|
||||
return new wxImage(bitmap);
|
||||
}
|
||||
%}
|
||||
|
||||
// Static Methods
|
||||
void wxImage_AddHandler(wxImageHandler *handler);
|
||||
%{
|
||||
void wxImage_AddHandler(wxImageHandler *handler) {
|
||||
wxImage::AddHandler(handler);
|
||||
}
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
VERSION=2.0b6
|
||||
VERSION=2.0b9
|
||||
|
||||
# Set WXDIR to the root wxWindows directory for your system
|
||||
WXDIR = $(WXWIN)
|
||||
@ -26,27 +26,49 @@ FINAL=0
|
||||
TARGETDIR=..
|
||||
|
||||
# Set this to 1 for make to pre-compile the Python modules, 0 to
|
||||
# just copy the sources and let Python compile them at the first
|
||||
# runtime.
|
||||
# just copy the sources and let Python compile them the first
|
||||
# time they are imported.
|
||||
COMPILEPY=0
|
||||
|
||||
# If your wxWindows is built as a DLL, set this to 1. Using 0 means
|
||||
# that wxWindows will be staticaly linked with wxPython.
|
||||
WXUSINGDLL=1
|
||||
# If your wxWindows is built as a DLL, set this to 1. Using 0 or unset
|
||||
# means that wxWindows will be staticaly linked with wxPython.
|
||||
#WXUSINGDLL=1
|
||||
|
||||
# If you want to compile in code to aquire/release the Python
|
||||
# Interpreter Lock at the appropriate places
|
||||
WXP_USE_THREAD=1
|
||||
|
||||
|
||||
# Set this if you want to build the wxGLCanvas
|
||||
WITH_GLCANVAS=1
|
||||
|
||||
# (experimental)
|
||||
SEPARATE=0
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
!if "$(WXP_USE_THREAD)" == "1"
|
||||
THREAD=-DWXP_USE_THREAD=1
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
NOPCH=1
|
||||
THISDIR=$(WXDIR)\utils\wxPython
|
||||
|
||||
EXTRALIBS=$(PYTHONDIR)\libs\python15.lib
|
||||
EXTRAINC=-I$(PYTHONDIR)\include -I.
|
||||
EXTRAFLAGS=/Fpwxp.pch /YXhelpers.h -DSWIG_GLOBAL -DHAVE_CONFIG_H
|
||||
OVERRIDEFLAGS=/GX- /DwxUSE_GLOBAL_MEMORY_OPERATORS=0 $(OTHERCFLAGS)
|
||||
|
||||
EXTRALIBS=$(PYTHONDIR)\libs\python15.lib $(GLLIBS)
|
||||
#EXTRALIBS=$(PYTHONDIR)\PCbuild\python15_d.lib -D_DEBUG
|
||||
EXTRAINC=-I$(PYTHONDIR)\include -I. -I$(WXDIR)\utils\glcanvas\win
|
||||
EXTRAFLAGS=/Fpwxp.pch /YXhelpers.h -DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD)
|
||||
OVERRIDEFLAGS=/GX- $(OTHERCFLAGS)
|
||||
|
||||
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
GLLIBS=$(WXDIR)\lib\glcanvas.lib glu32.lib opengl32.lib
|
||||
OTHERSWIGFLAGS=-DWITH_GLCANVAS
|
||||
OTHERCFLAGS=-DWITH_GLCANVAS
|
||||
!endif
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -D__WXMSW__ $(OTHERSWIGFLAGS)
|
||||
GENCODEDIR=msw
|
||||
@ -61,16 +83,23 @@ TARGET = wxc
|
||||
OBJECTS = wx.obj helpers.obj windows.obj events.obj \
|
||||
misc.obj gdi.obj mdi.obj controls.obj \
|
||||
controls2.obj windows2.obj cmndlgs.obj stattool.obj \
|
||||
frames.obj windows3.obj \
|
||||
frames.obj windows3.obj image.obj \
|
||||
!if "$(SEPARATE)" == "0"
|
||||
utils.obj
|
||||
utils.obj \
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
glcanvas.obj
|
||||
!endif
|
||||
!else
|
||||
|
||||
OTHERCFLAGS=-DSEPARATE=1
|
||||
OTHERSWIGFLAGS=-DSEPARATE
|
||||
OTHERCFLAGS=$(OTHERCFLAGS) -DSEPARATE=1
|
||||
OTHERSWIGFLAGS=$(OTHERSWIGFLAGS) -DSEPARATE
|
||||
TARGET2 = utilsc
|
||||
OBJECTS2 = utils.obj
|
||||
target2=$(TARGETDIR)\$(TARGET2).pyd
|
||||
|
||||
TARGET3 = glcanvasc
|
||||
OBJECTS3 = glcanvas.obj
|
||||
target3=$(TARGETDIR)\$(TARGET3).pyd
|
||||
!endif
|
||||
|
||||
PYMODULES = $(TARGETDIR)\wx.py $(TARGETDIR)\events.py \
|
||||
@ -79,9 +108,11 @@ PYMODULES = $(TARGETDIR)\wx.py $(TARGETDIR)\events.py \
|
||||
$(TARGETDIR)\controls.py $(TARGETDIR)\controls2.py \
|
||||
$(TARGETDIR)\windows2.py $(TARGETDIR)\cmndlgs.py \
|
||||
$(TARGETDIR)\stattool.py $(TARGETDIR)\frames.py \
|
||||
$(TARGETDIR)\utils.py $(TARGETDIR)\windows3.py \
|
||||
$(TARGETDIR)\__init__.py
|
||||
|
||||
$(TARGETDIR)\windows3.py $(TARGETDIR)\__init__.py \
|
||||
$(TARGETDIR)\utils.py $(TARGETDIR)\image.py \
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
$(TARGETDIR)\glcanvas.py
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@ -91,17 +122,13 @@ DEBUGLFLAGS = /DEBUG /INCREMENTAL:YES
|
||||
DEBUGLFLAGS = /INCREMENTAL:NO
|
||||
!endif
|
||||
|
||||
LFLAGS= $(DEBUGLFLAGS) /DLL /def:$(TARGET).def /subsystem:windows,3.50 \
|
||||
/machine:I386 /implib:./$(TARGET).lib /nologo
|
||||
|
||||
LFLAGS2=$(DEBUGLFLAGS) /DLL /def:$(TARGET2).def /subsystem:windows,3.50 \
|
||||
/machine:I386 /implib:./$(TARGET2).lib /nologo
|
||||
LFLAGS= $(DEBUGLFLAGS) /DLL /subsystem:windows,3.50 /machine:I386 /nologo
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
default: $(TARGETDIR)\$(TARGET).pyd $(target2) pycfiles
|
||||
default: $(TARGETDIR)\$(TARGET).pyd $(target2) $(target3) pycfiles
|
||||
|
||||
all: wx $(TARGET) $(TARGET2)
|
||||
all: wx $(TARGET) $(TARGET2) $(TARGET3)
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
@ -125,7 +152,7 @@ pycfiles : $(PYMODULES)
|
||||
$(TARGETDIR)\$(TARGET).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(TARGET).res
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS)
|
||||
$(LFLAGS) /def:$(TARGET).def /implib:./$(TARGET).lib
|
||||
$(DUMMYOBJ) $(OBJECTS) $(TARGET).res
|
||||
$(LIBS)
|
||||
<<
|
||||
@ -133,9 +160,17 @@ $(LIBS)
|
||||
$(TARGETDIR)\$(TARGET2).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS2)
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS2)
|
||||
$(LFLAGS) /def:$(TARGET2).def /implib:./$(TARGET2).lib
|
||||
$(DUMMYOBJ) $(OBJECTS2)
|
||||
$(LIBS)
|
||||
$(LIBS) wxc.lib
|
||||
<<
|
||||
|
||||
$(TARGETDIR)\$(TARGET3).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS3)
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS) /def:$(TARGET3).def /implib:./$(TARGET3).lib
|
||||
$(DUMMYOBJ) $(OBJECTS3)
|
||||
$(LIBS) $(WXDIR)\lib\glcanvas.lib glu32.lib opengl32.lib wxc.lib
|
||||
<<
|
||||
|
||||
|
||||
@ -171,6 +206,9 @@ clean:
|
||||
-erase $(TARGET2).exp
|
||||
-erase $(TARGET2).lib
|
||||
-erase $(TARGETDIR)\$(TARGET2).*
|
||||
-erase $(TARGET3).exp
|
||||
-erase $(TARGET3).lib
|
||||
-erase $(TARGETDIR)\$(TARGET3).*
|
||||
!endif
|
||||
-erase $(TARGETDIR)\$(TARGET).pyd
|
||||
-erase $(TARGETDIR)\*.py
|
||||
@ -224,12 +262,21 @@ $(GENCODEDIR)/controls2.cpp $(GENCODEDIR)/controls2.py : controls2.i my_typemap
|
||||
$(GENCODEDIR)/cmndlgs.cpp $(GENCODEDIR)/cmndlgs.py : cmndlgs.i my_typemaps.i _defs.i
|
||||
$(GENCODEDIR)/stattool.cpp $(GENCODEDIR)/stattool.py : stattool.i my_typemaps.i _defs.i
|
||||
$(GENCODEDIR)/frames.cpp $(GENCODEDIR)/frames.py : frames.i my_typemaps.i _defs.i
|
||||
$(GENCODEDIR)/image.cpp $(GENCODEDIR)/image.py : image.i my_typemaps.i _defs.i
|
||||
|
||||
!if "$(SEPARATE)" == "1"
|
||||
$(GENCODEDIR)\utils.cpp $(GENCODEDIR)\utils.py : utils.i my_typemaps.i
|
||||
swig $(SWIGFLAGS) -o $(GENCODEDIR)/utils.cpp utils.i
|
||||
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
$(GENCODEDIR)\glcanvas.cpp $(GENCODEDIR)\glcanvas.py : glcanvas.i my_typemaps.i
|
||||
swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/glcanvas.cpp glcanvas.i
|
||||
!endif
|
||||
!else
|
||||
$(GENCODEDIR)/utils.cpp $(GENCODEDIR)/utils.py : utils.i my_typemaps.i _defs.i
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
$(GENCODEDIR)/glcanvas.cpp $(GENCODEDIR)/glcanvas.py : glcanvas.i my_typemaps.i _defs.i
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
@ -246,8 +293,12 @@ $(TARGETDIR)\controls2.py : $(GENCODEDIR)\controls2.py
|
||||
$(TARGETDIR)\cmndlgs.py : $(GENCODEDIR)\cmndlgs.py
|
||||
$(TARGETDIR)\frames.py : $(GENCODEDIR)\frames.py
|
||||
$(TARGETDIR)\stattool.py : $(GENCODEDIR)\stattool.py
|
||||
$(TARGETDIR)\utils.py : $(GENCODEDIR)\utils.py
|
||||
$(TARGETDIR)\__init__.py : __init__.py
|
||||
$(TARGETDIR)\utils.py : $(GENCODEDIR)\utils.py
|
||||
$(TARGETDIR)\image.py : $(GENCODEDIR)\utils.py
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
$(TARGETDIR)\glcanvas.py : $(GENCODEDIR)\glcanvas.py
|
||||
!endif
|
||||
|
||||
|
||||
SOURCES = $(GENCODEDIR)\wx.cpp $(GENCODEDIR)\wx.py \
|
||||
@ -264,6 +315,10 @@ SOURCES = $(GENCODEDIR)\wx.cpp $(GENCODEDIR)\wx.py \
|
||||
$(GENCODEDIR)/stattool.cpp $(GENCODEDIR)/stattool.py \
|
||||
$(GENCODEDIR)/frames.cpp $(GENCODEDIR)/frames.py \
|
||||
$(GENCODEDIR)/utils.cpp $(GENCODEDIR)/utils.py \
|
||||
$(GENCODEDIR)/image.cpp $(GENCODEDIR)/image.py \
|
||||
!if "$(WITH_GLCANVAS)" == "1"
|
||||
$(GENCODEDIR)/glcanvas.cpp $(GENCODEDIR)/glcanvas.py \
|
||||
!endif
|
||||
|
||||
|
||||
sources : $(SOURCES)
|
||||
@ -275,86 +330,3 @@ dist:
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.4 1999/03/05 07:22:30 RD
|
||||
# Minor wxPython changes for wxWin 2.0
|
||||
#
|
||||
# Revision 1.3 1999/02/25 07:08:33 RD
|
||||
#
|
||||
# wxPython version 2.0b5
|
||||
#
|
||||
# Revision 1.2 1999/02/20 09:03:00 RD
|
||||
# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
# window handle. If you can get the window handle into the python code,
|
||||
# it should just work... More news on this later.
|
||||
#
|
||||
# Added wxImageList, wxToolTip.
|
||||
#
|
||||
# Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
|
||||
# wxRegConfig class.
|
||||
#
|
||||
# As usual, some bug fixes, tweaks, etc.
|
||||
#
|
||||
# Revision 1.1 1999/02/06 23:47:03 RD
|
||||
#
|
||||
# Changing makefile.nt to makefile.vc as in rest of wxWindows
|
||||
#
|
||||
# Revision 1.10 1999/02/01 00:10:40 RD
|
||||
#
|
||||
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
|
||||
#
|
||||
# Revision 1.9 1999/01/30 07:30:13 RD
|
||||
#
|
||||
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
|
||||
#
|
||||
# Various cleanup, tweaks, minor additions, etc. to maintain
|
||||
# compatibility with the current wxWindows.
|
||||
#
|
||||
# Revision 1.8 1998/12/21 19:58:06 RD
|
||||
#
|
||||
# Now compiles with /GX- on MSW.
|
||||
#
|
||||
# Revision 1.7 1998/12/15 20:41:20 RD
|
||||
# Changed the import semantics from "from wxPython import *" to "from
|
||||
# wxPython.wx import *" This is for people who are worried about
|
||||
# namespace pollution, they can use "from wxPython import wx" and then
|
||||
# prefix all the wxPython identifiers with "wx."
|
||||
#
|
||||
# Added wxTaskbarIcon for wxMSW.
|
||||
#
|
||||
# Made the events work for wxGrid.
|
||||
#
|
||||
# Added wxConfig.
|
||||
#
|
||||
# Added wxMiniFrame for wxGTK, (untested.)
|
||||
#
|
||||
# Changed many of the args and return values that were pointers to gdi
|
||||
# objects to references to reflect changes in the wxWindows API.
|
||||
#
|
||||
# Other assorted fixes and additions.
|
||||
#
|
||||
# Revision 1.6 1998/10/02 06:40:41 RD
|
||||
#
|
||||
# Version 0.4 of wxPython for MSW.
|
||||
#
|
||||
# Revision 1.5 1998/08/19 00:38:23 RD
|
||||
#
|
||||
# A few tweaks
|
||||
#
|
||||
# Revision 1.4 1998/08/18 21:55:10 RD
|
||||
#
|
||||
# New build directory structure
|
||||
#
|
||||
# Revision 1.3 1998/08/15 07:36:37 RD
|
||||
# - Moved the header in the .i files out of the code that gets put into
|
||||
# the .cpp files. It caused CVS conflicts because of the RCS ID being
|
||||
# different each time.
|
||||
#
|
||||
# - A few minor fixes.
|
||||
#
|
||||
# Revision 1.2 1998/08/14 03:34:23 RD
|
||||
# made pre-compiling the python files optional
|
||||
#
|
||||
# Revision 1.1 1998/08/09 08:25:51 RD
|
||||
# Initial version
|
||||
#
|
||||
|
@ -193,8 +193,11 @@ void wxSetCursor(wxCursor& cursor);
|
||||
//---------------------------------------------------------------------------
|
||||
// Miscellaneous functions
|
||||
|
||||
long NewId();
|
||||
void RegisterId(long id);
|
||||
long wxNewId();
|
||||
void wxRegisterId(long id);
|
||||
%name(NewId) long wxNewId();
|
||||
%name(RegisterId) void wxRegisterId(long id);
|
||||
|
||||
void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
|
||||
void wxBell();
|
||||
void wxDisplaySize(int *OUTPUT, int *OUTPUT);
|
||||
@ -217,6 +220,7 @@ int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
|
||||
#endif
|
||||
|
||||
bool wxYield();
|
||||
bool wxSafeYield();
|
||||
|
||||
%inline %{
|
||||
char* wxGetResource(char *section, char *entry, char *file = NULL) {
|
||||
@ -407,7 +411,19 @@ public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.14 1999/04/30 03:29:19 RD
|
||||
// wxPython 2.0b9, first phase (win32)
|
||||
// Added gobs of stuff, see wxPython/README.txt for details
|
||||
//
|
||||
// Revision 1.13.4.1 1999/03/27 23:29:15 RD
|
||||
//
|
||||
// wxPython 2.0b8
|
||||
// Python thread support
|
||||
// various minor additions
|
||||
// various minor fixes
|
||||
//
|
||||
// Revision 1.13 1999/02/25 07:08:34 RD
|
||||
//
|
||||
// wxPython version 2.0b5
|
||||
//
|
||||
// Revision 1.12 1999/02/20 10:02:37 RD
|
||||
|
@ -318,106 +318,113 @@ class wxFontDialog(wxFontDialogPtr):
|
||||
|
||||
|
||||
|
||||
class wxPageSetupDataPtr :
|
||||
class wxPageSetupDialogDataPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __del__(self):
|
||||
if self.thisown == 1 :
|
||||
cmndlgsc.delete_wxPageSetupData(self.this)
|
||||
cmndlgsc.delete_wxPageSetupDialogData(self.this)
|
||||
def EnableHelp(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_EnableHelp(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_EnableHelp(self.this,arg0)
|
||||
return val
|
||||
def EnableMargins(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_EnableMargins(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_EnableMargins(self.this,arg0)
|
||||
return val
|
||||
def EnableOrientation(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_EnableOrientation(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_EnableOrientation(self.this,arg0)
|
||||
return val
|
||||
def EnablePaper(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_EnablePaper(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_EnablePaper(self.this,arg0)
|
||||
return val
|
||||
def EnablePrinter(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_EnablePrinter(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_EnablePrinter(self.this,arg0)
|
||||
return val
|
||||
def GetPaperSize(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetPaperSize(self.this)
|
||||
val = wxPointPtr(val)
|
||||
val.thisown = 1
|
||||
def GetDefaultMinMargins(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetDefaultMinMargins(self.this)
|
||||
return val
|
||||
def GetEnableMargins(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetEnableMargins(self.this)
|
||||
return val
|
||||
def GetEnableOrientation(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetEnableOrientation(self.this)
|
||||
return val
|
||||
def GetEnablePaper(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetEnablePaper(self.this)
|
||||
return val
|
||||
def GetEnablePrinter(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetEnablePrinter(self.this)
|
||||
return val
|
||||
def GetEnableHelp(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetEnableHelp(self.this)
|
||||
return val
|
||||
def GetDefaultInfo(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetDefaultInfo(self.this)
|
||||
return val
|
||||
def GetMarginTopLeft(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetMarginTopLeft(self.this)
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetMarginTopLeft(self.this)
|
||||
val = wxPointPtr(val)
|
||||
val.thisown = 1
|
||||
return val
|
||||
def GetMarginBottomRight(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetMarginBottomRight(self.this)
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetMarginBottomRight(self.this)
|
||||
val = wxPointPtr(val)
|
||||
val.thisown = 1
|
||||
return val
|
||||
def GetMinMarginTopLeft(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetMinMarginTopLeft(self.this)
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetMinMarginTopLeft(self.this)
|
||||
val = wxPointPtr(val)
|
||||
val.thisown = 1
|
||||
return val
|
||||
def GetMinMarginBottomRight(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetMinMarginBottomRight(self.this)
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetMinMarginBottomRight(self.this)
|
||||
val = wxPointPtr(val)
|
||||
val.thisown = 1
|
||||
return val
|
||||
def GetOrientation(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetOrientation(self.this)
|
||||
def GetPaperId(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetPaperId(self.this)
|
||||
return val
|
||||
def GetDefaultMinMargins(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetDefaultMinMargins(self.this)
|
||||
def GetPaperSize(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetPaperSize(self.this)
|
||||
val = wxSizePtr(val)
|
||||
val.thisown = 1
|
||||
return val
|
||||
def GetEnableMargins(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetEnableMargins(self.this)
|
||||
return val
|
||||
def GetEnableOrientation(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetEnableOrientation(self.this)
|
||||
return val
|
||||
def GetEnablePaper(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetEnablePaper(self.this)
|
||||
return val
|
||||
def GetEnablePrinter(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetEnablePrinter(self.this)
|
||||
return val
|
||||
def GetEnableHelp(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetEnableHelp(self.this)
|
||||
return val
|
||||
def GetDefaultInfo(self):
|
||||
val = cmndlgsc.wxPageSetupData_GetDefaultInfo(self.this)
|
||||
return val
|
||||
def SetPaperSize(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetPaperSize(self.this,arg0.this)
|
||||
return val
|
||||
def SetMarginTopLeft(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetMarginTopLeft(self.this,arg0.this)
|
||||
return val
|
||||
def SetMarginBottomRight(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetMarginBottomRight(self.this,arg0.this)
|
||||
return val
|
||||
def SetMinMarginTopLeft(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetMinMarginTopLeft(self.this,arg0.this)
|
||||
return val
|
||||
def SetMinMarginBottomRight(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetMinMarginBottomRight(self.this,arg0.this)
|
||||
return val
|
||||
def SetOrientation(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetOrientation(self.this,arg0)
|
||||
return val
|
||||
def SetDefaultMinMargins(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetDefaultMinMargins(self.this,arg0)
|
||||
def GetPrintData(self):
|
||||
val = cmndlgsc.wxPageSetupDialogData_GetPrintData(self.this)
|
||||
val = wxPrintDataPtr(val)
|
||||
return val
|
||||
def SetDefaultInfo(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupData_SetDefaultInfo(self.this,arg0)
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetDefaultInfo(self.this,arg0)
|
||||
return val
|
||||
def SetDefaultMinMargins(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetDefaultMinMargins(self.this,arg0)
|
||||
return val
|
||||
def SetMarginTopLeft(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetMarginTopLeft(self.this,arg0.this)
|
||||
return val
|
||||
def SetMarginBottomRight(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetMarginBottomRight(self.this,arg0.this)
|
||||
return val
|
||||
def SetMinMarginTopLeft(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetMinMarginTopLeft(self.this,arg0.this)
|
||||
return val
|
||||
def SetMinMarginBottomRight(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetMinMarginBottomRight(self.this,arg0.this)
|
||||
return val
|
||||
def SetPaperId(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetPaperId(self.this,arg0)
|
||||
return val
|
||||
def SetPaperSize(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetPaperSize(self.this,arg0.this)
|
||||
return val
|
||||
def SetPrintData(self,arg0):
|
||||
val = cmndlgsc.wxPageSetupDialogData_SetPrintData(self.this,arg0.this)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxPageSetupData instance>"
|
||||
class wxPageSetupData(wxPageSetupDataPtr):
|
||||
return "<C wxPageSetupDialogData instance>"
|
||||
class wxPageSetupDialogData(wxPageSetupDialogDataPtr):
|
||||
def __init__(self) :
|
||||
self.this = cmndlgsc.new_wxPageSetupData()
|
||||
self.this = cmndlgsc.new_wxPageSetupDialogData()
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
@ -429,7 +436,7 @@ class wxPageSetupDialogPtr(wxDialogPtr):
|
||||
self.thisown = 0
|
||||
def GetPageSetupData(self):
|
||||
val = cmndlgsc.wxPageSetupDialog_GetPageSetupData(self.this)
|
||||
val = wxPageSetupDataPtr(val)
|
||||
val = wxPageSetupDialogDataPtr(val)
|
||||
return val
|
||||
def ShowModal(self):
|
||||
val = cmndlgsc.wxPageSetupDialog_ShowModal(self.this)
|
||||
@ -449,81 +456,85 @@ class wxPageSetupDialog(wxPageSetupDialogPtr):
|
||||
|
||||
|
||||
|
||||
class wxPrintDataPtr :
|
||||
class wxPrintDialogDataPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __del__(self):
|
||||
if self.thisown == 1 :
|
||||
cmndlgsc.delete_wxPrintData(self.this)
|
||||
cmndlgsc.delete_wxPrintDialogData(self.this)
|
||||
def EnableHelp(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_EnableHelp(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_EnableHelp(self.this,arg0)
|
||||
return val
|
||||
def EnablePageNumbers(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_EnablePageNumbers(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_EnablePageNumbers(self.this,arg0)
|
||||
return val
|
||||
def EnablePrintToFile(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_EnablePrintToFile(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_EnablePrintToFile(self.this,arg0)
|
||||
return val
|
||||
def EnableSelection(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_EnableSelection(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_EnableSelection(self.this,arg0)
|
||||
return val
|
||||
def GetAllPages(self):
|
||||
val = cmndlgsc.wxPrintData_GetAllPages(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetAllPages(self.this)
|
||||
return val
|
||||
def GetCollate(self):
|
||||
val = cmndlgsc.wxPrintData_GetCollate(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetCollate(self.this)
|
||||
return val
|
||||
def GetFromPage(self):
|
||||
val = cmndlgsc.wxPrintData_GetFromPage(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetFromPage(self.this)
|
||||
return val
|
||||
def GetMaxPage(self):
|
||||
val = cmndlgsc.wxPrintData_GetMaxPage(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetMaxPage(self.this)
|
||||
return val
|
||||
def GetMinPage(self):
|
||||
val = cmndlgsc.wxPrintData_GetMinPage(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetMinPage(self.this)
|
||||
return val
|
||||
def GetNoCopies(self):
|
||||
val = cmndlgsc.wxPrintData_GetNoCopies(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetNoCopies(self.this)
|
||||
return val
|
||||
def GetOrientation(self):
|
||||
val = cmndlgsc.wxPrintData_GetOrientation(self.this)
|
||||
def GetPrintData(self):
|
||||
val = cmndlgsc.wxPrintDialogData_GetPrintData(self.this)
|
||||
val = wxPrintDataPtr(val)
|
||||
return val
|
||||
def GetPrintToFile(self):
|
||||
val = cmndlgsc.wxPrintDialogData_GetPrintToFile(self.this)
|
||||
return val
|
||||
def GetToPage(self):
|
||||
val = cmndlgsc.wxPrintData_GetToPage(self.this)
|
||||
val = cmndlgsc.wxPrintDialogData_GetToPage(self.this)
|
||||
return val
|
||||
def SetCollate(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetCollate(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetCollate(self.this,arg0)
|
||||
return val
|
||||
def SetFromPage(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetFromPage(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetFromPage(self.this,arg0)
|
||||
return val
|
||||
def SetMaxPage(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetMaxPage(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetMaxPage(self.this,arg0)
|
||||
return val
|
||||
def SetMinPage(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetMinPage(self.this,arg0)
|
||||
return val
|
||||
def SetOrientation(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetOrientation(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetMinPage(self.this,arg0)
|
||||
return val
|
||||
def SetNoCopies(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetNoCopies(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetNoCopies(self.this,arg0)
|
||||
return val
|
||||
def SetPrintData(self,arg0):
|
||||
val = cmndlgsc.wxPrintDialogData_SetPrintData(self.this,arg0.this)
|
||||
return val
|
||||
def SetPrintToFile(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetPrintToFile(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetPrintToFile(self.this,arg0)
|
||||
return val
|
||||
def SetSetupDialog(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetSetupDialog(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetSetupDialog(self.this,arg0)
|
||||
return val
|
||||
def SetToPage(self,arg0):
|
||||
val = cmndlgsc.wxPrintData_SetToPage(self.this,arg0)
|
||||
val = cmndlgsc.wxPrintDialogData_SetToPage(self.this,arg0)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxPrintData instance>"
|
||||
class wxPrintData(wxPrintDataPtr):
|
||||
return "<C wxPrintDialogData instance>"
|
||||
class wxPrintDialogData(wxPrintDialogDataPtr):
|
||||
def __init__(self) :
|
||||
self.this = cmndlgsc.new_wxPrintData()
|
||||
self.this = cmndlgsc.new_wxPrintDialogData()
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
@ -533,9 +544,9 @@ class wxPrintDialogPtr(wxDialogPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def GetPrintData(self):
|
||||
val = cmndlgsc.wxPrintDialog_GetPrintData(self.this)
|
||||
val = wxPrintDataPtr(val)
|
||||
def GetPrintDialogData(self):
|
||||
val = cmndlgsc.wxPrintDialog_GetPrintDialogData(self.this)
|
||||
val = wxPrintDialogDataPtr(val)
|
||||
return val
|
||||
def GetPrintDC(self):
|
||||
val = cmndlgsc.wxPrintDialog_GetPrintDC(self.this)
|
||||
|
@ -383,6 +383,9 @@ class wxListBoxPtr(wxControlPtr):
|
||||
def GetSelection(self):
|
||||
val = controlsc.wxListBox_GetSelection(self.this)
|
||||
return val
|
||||
def GetSelections(self):
|
||||
val = controlsc.wxListBox_GetSelections(self.this)
|
||||
return val
|
||||
def GetString(self,arg0):
|
||||
val = controlsc.wxListBox_GetString(self.this,arg0)
|
||||
return val
|
||||
@ -536,6 +539,9 @@ class wxTextCtrlPtr(wxControlPtr):
|
||||
def WriteText(self,arg0):
|
||||
val = controlsc.wxTextCtrl_WriteText(self.this,arg0)
|
||||
return val
|
||||
def AppendText(self,arg0):
|
||||
val = controlsc.wxTextCtrl_AppendText(self.this,arg0)
|
||||
return val
|
||||
def XYToPosition(self,arg0,arg1):
|
||||
val = controlsc.wxTextCtrl_XYToPosition(self.this,arg0,arg1)
|
||||
return val
|
||||
|