wxPython 2.1b1:
Added the missing wxWindow.GetUpdateRegion() method. Made a new change in SWIG (update your patches everybody) that provides a fix for global shadow objects that get an exception in their __del__ when their extension module has already been deleted. It was only a 1 line change in .../SWIG/Modules/pycpp.cxx at about line 496 if you want to do it by hand. It is now possible to run through MainLoop more than once in any one process. The cleanup that used to happen as MainLoop completed (and prevented it from running again) has been delayed until the wxc module is being unloaded by Python. wxWindow.PopupMenu() now takes a wxPoint instead of x,y. Added wxWindow.PopupMenuXY to be consistent with some other methods. Added wxGrid.SetEditInPlace and wxGrid.GetEditInPlace. You can now provide your own app.MainLoop method. See wxPython/demo/demoMainLoop.py for an example and some explaination. Got the in-place-edit for the wxTreeCtrl fixed and added some demo code to show how to use it. Put the wxIcon constructor back in for GTK as it now has one that matches MSW's. Added wxGrid.GetCells Added wxSystemSettings static methods as functions with names like wxSystemSettings_GetSystemColour. Removed wxPyMenu since using menu callbacks have been depreciated in wxWindows. Use wxMenu and events instead. Added alternate wxBitmap constructor (for MSW only) as wxBitmapFromData(data, type, width, height, depth = 1) Added a helper function named wxPyTypeCast that can convert shadow objects of one type into shadow objects of another type. (Like doing a down-cast.) See the implementation in wx.py for some docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
#!/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 *
|
||||
|
||||
@@ -22,4 +10,4 @@ class ColoredPanel(wxWindow):
|
||||
wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
|
||||
self.SetBackgroundColour(color)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/env python
|
||||
#!/usr/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: DialogUnits.py
|
||||
# Purpose: A minimal wxPython program that is a bit smarter than test1.
|
||||
@@ -46,6 +46,9 @@ class MyFrame(wxFrame):
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
print wxDLG_PNT(panel, wxPoint(24, 4)), wxDLG_SZE(panel, wxSize(36, -1))
|
||||
print wxDLG_PNT(panel, wxPoint(24, 16)),wxDLG_SZE(panel, wxSize(36, -1))
|
||||
|
||||
|
||||
# This method is called automatically when the CLOSE event is
|
||||
# sent to this window
|
||||
|
@@ -43,7 +43,7 @@ _treeList = [
|
||||
('wxPython Library', ['Sizers', 'Layoutf', 'wxScrolledMessageDialog',
|
||||
'wxMultipleChoiceDialog', 'wxPlotCanvas']),
|
||||
|
||||
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot']),
|
||||
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot', 'XMLtreeview']),
|
||||
|
||||
]
|
||||
|
||||
@@ -153,7 +153,8 @@ class wxPythonDemo(wxFrame):
|
||||
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))
|
||||
self.log.ShowPosition(self.log.XYToPosition(x, y-numLines))
|
||||
## self.log.ShowPosition(self.log.GetLastPosition())
|
||||
self.log.SetInsertionPointEnd()
|
||||
|
||||
def write(self, txt):
|
||||
@@ -218,7 +219,7 @@ class wxPythonDemo(wxFrame):
|
||||
# self.txt.WriteText("Cannot open %s file." % filename)
|
||||
try:
|
||||
self.txt.SetValue(open(filename).read())
|
||||
except IOException:
|
||||
except IOError:
|
||||
self.txt.WriteText("Cannot open %s file." % filename)
|
||||
|
||||
|
||||
|
@@ -111,21 +111,17 @@ def makeSimpleBorder3(win):
|
||||
def makeBoxInBox(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
btn = wxButton(win, 1010, "one")
|
||||
box.Add(btn)
|
||||
box.Add(wxButton(win, 1010, "one"))
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(win, 1010, "two")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "three")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "four")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "five")
|
||||
box2.Add(btn)
|
||||
box2.AddMany([ wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
])
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 1),
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
@@ -134,8 +130,7 @@ def makeBoxInBox(win):
|
||||
box2.Add(box3, 1)
|
||||
box.Add(box2, 1)
|
||||
|
||||
btn = wxButton(win, 1010, "ten")
|
||||
box.Add(btn)
|
||||
box.Add(wxButton(win, 1010, "ten"))
|
||||
|
||||
return box
|
||||
|
||||
@@ -154,11 +149,11 @@ def makeBorderInBox(win):
|
||||
insideBox = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ (wxButton(win, 1010, "one"), 0),
|
||||
(wxButton(win, 1010, "two"), 0),
|
||||
(wxButton(win, 1010, "three"), 0),
|
||||
(wxButton(win, 1010, "four"), 0),
|
||||
(wxButton(win, 1010, "five"), 0),
|
||||
box2.AddMany([ wxButton(win, 1010, "one"),
|
||||
wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
])
|
||||
|
||||
insideBox.Add(box2, 0)
|
||||
@@ -168,7 +163,7 @@ def makeBorderInBox(win):
|
||||
insideBox.Add(bdr, 1)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 1),
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
|
66
utils/wxPython/demo/XMLtreeview.py
Normal file
66
utils/wxPython/demo/XMLtreeview.py
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
import string
|
||||
|
||||
from wxPython.wx import *
|
||||
try:
|
||||
from xml.parsers import pyexpat
|
||||
haveXML = true
|
||||
except ImportError:
|
||||
haveXML = false
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveXML:
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame, 'This demo requires the XML package. See http://www.python.org/sigs/xml-sig/',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
else:
|
||||
|
||||
class XMLTree(wxTreeCtrl):
|
||||
def __init__(self, parent, ID):
|
||||
wxTreeCtrl.__init__(self, parent, ID)
|
||||
self.nodeStack = [self.AddRoot("Root")]
|
||||
|
||||
# Define a handler for start element events
|
||||
def StartElement(self, name, attrs ):
|
||||
self.nodeStack.append(self.AppendItem(self.nodeStack[-1], name))
|
||||
|
||||
def EndElement(self, name ):
|
||||
self.nodeStack = self.nodeStack[:-1]
|
||||
|
||||
def CharacterData(self, data ):
|
||||
if string.strip(data):
|
||||
self.AppendItem(self.nodeStack[-1], data)
|
||||
|
||||
|
||||
def LoadTree(self, filename):
|
||||
# Create a parser
|
||||
Parser = pyexpat.ParserCreate()
|
||||
|
||||
# Tell the parser what the start element handler is
|
||||
Parser.StartElementHandler = self.StartElement
|
||||
Parser.EndElementHandler = self.EndElement
|
||||
Parser.CharacterDataHandler = self.CharacterData
|
||||
|
||||
# Parse the XML File
|
||||
ParserStatus = Parser.Parse(open(filename,'r').read(), 1)
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = XMLTree(nb, -1)
|
||||
win.LoadTree("paper.xml")
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/env python
|
||||
#!/usr/bin/env python
|
||||
|
||||
import Main
|
||||
Main.main()
|
||||
|
119
utils/wxPython/demo/demoMainLoop.py
Executable file
119
utils/wxPython/demo/demoMainLoop.py
Executable file
@@ -0,0 +1,119 @@
|
||||
"""
|
||||
This demo attempts to override the C++ MainLoop and implement it
|
||||
in Python. This is not part of the demo framework.
|
||||
|
||||
|
||||
THIS FEATURE IS STILL EXPERIMENTAL...
|
||||
"""
|
||||
|
||||
|
||||
from wxPython.wx import *
|
||||
import time
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 150))
|
||||
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.count = 0
|
||||
|
||||
panel = wxPanel(self, -1)
|
||||
wxStaticText(panel, -1, "Size:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
|
||||
wxStaticText(panel, -1, "Pos:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 16)), wxDefaultSize)
|
||||
|
||||
wxStaticText(panel, -1, "Idle:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 28)), 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, 16)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
self.idleCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 28)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
app.keepGoing = false
|
||||
self.Destroy()
|
||||
|
||||
def OnIdle(self, event):
|
||||
self.idleCtrl.SetValue(str(self.count))
|
||||
self.count = self.count + 1
|
||||
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
|
||||
event.Skip()
|
||||
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wxApp):
|
||||
def MainLoop(self):
|
||||
# This outer loop determines when to exit the application, for
|
||||
# this example we let the main frame reset this flag when it
|
||||
# closes.
|
||||
while self.keepGoing:
|
||||
# At this point in the outer loop you could do whatever you
|
||||
# implemented your own MainLoop for. It should be quick and
|
||||
# non-blocking, otherwise your GUI will freeze. For example,
|
||||
# call Fnorb's reactor.do_one_event(0), etc.
|
||||
|
||||
# call_your_code_here()
|
||||
|
||||
|
||||
# This inner loop will process any GUI events until there
|
||||
# are no more waiting.
|
||||
while self.Pending():
|
||||
self.Dispatch()
|
||||
|
||||
# Send idle events to idle handlers. You may want to throtle
|
||||
# this back a bit so there is not too much CPU time spent in
|
||||
# the idle handlers. For this example, I'll just snooze a
|
||||
# little...
|
||||
time.sleep(0.25)
|
||||
self.ProcessIdle()
|
||||
|
||||
|
||||
|
||||
def OnInit(self):
|
||||
frame = MyFrame(NULL, -1, "This is a test")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
self.keepGoing = true
|
||||
|
||||
return true
|
||||
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
85
utils/wxPython/demo/paper.xml
Normal file
85
utils/wxPython/demo/paper.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE gcapaper SYSTEM "gcapap-X.dtd" [
|
||||
<!ENTITY footprint SYSTEM "footprint.tif" NDATA tiff >
|
||||
<!ENTITY footprint SYSTEM "footprint.eps" NDATA eps >
|
||||
<!ENTITY shoes SYSTEM "shoes.tif" NDATA tiff >
|
||||
<!ENTITY super1 "Z">
|
||||
]>
|
||||
|
||||
<gcapaper><front><title>Using SGML to make footprints in the sand
|
||||
</title><keyword>footprints</keyword><keyword>sand</keyword>
|
||||
<author><fname>Jane</fname><surname>Doe</surname>
|
||||
<jobtitle>Empress</jobtitle>
|
||||
<address><affil>Universe Corporation</affil>
|
||||
<aline>1 Main Street</aline>
|
||||
<city>Perfect City</city>
|
||||
<province>Dorado</province>
|
||||
<cntry>Neutral</cntry><postcode>999999</postcode>
|
||||
<phone>+55 555 555 5550</phone>
|
||||
<fax>+55 555 555 5555</fax>
|
||||
<email>jane@universe.com</email>
|
||||
<web>www.universe.com</web>
|
||||
</address>
|
||||
<bio><para>Jane Doe is the Empress of the Universe <bibref refloc="jd000"/>, a position to which she has always aspired.</para></bio>
|
||||
</author>
|
||||
<author><fname>Fred</fname><surname>Bloggs</surname>
|
||||
<jobtitle>Designer</jobtitle>
|
||||
<address><affil>Fred (The Shoe) Bloggs Ltd</affil>
|
||||
<aline>1 Shoe Lane</aline>
|
||||
<city>Perfect City</city>
|
||||
<province>Dorado</province>
|
||||
<cntry>Neutral</cntry><postcode>999999</postcode>
|
||||
<phone>+55 555 555 1122</phone>
|
||||
<fax>+55 555 555 1133</fax>
|
||||
<email>fred@shoebloggs.com</email>
|
||||
<web>www.shoebloggs.com</web></address>
|
||||
<bio><para>Fred has always wanted to create the perfect shoe for making footprints in the sand. Now with SGML and XML, he has been able to document his design.</para></bio>
|
||||
</author>
|
||||
<abstract>
|
||||
<para><keyword>ease</keyword><keyword>documentation</keyword>It's not easy being an Empress of the Universe (<a href="http://www.universe.com"/>), but with the right pair of shoes and the right documentation on how to make footprints in the sand of life, it's easier than it was. Since the introduction of <acronym.grp><acronym>SGML</acronym><expansion>Standard Generalized Markup Language</expansion></acronym.grp> and <acronym.grp><acronym>XML</acronym><expansion>Extensible Markup Language</expansion></acronym.grp> it is now possible to identify and manage the key bits of information on this process.</para>
|
||||
</abstract>
|
||||
</front>
|
||||
<body><section id="jd001"><title>Introduction</title>
|
||||
<para><keyword>documentation</keyword>Since its inception, the Universe has always had sand, now it has an Empress, a good shoe design, and <acronym>SGML</acronym> / <acronym>XML</acronym> documentation. The time is now ripe for making <highlight style="ital">footprints</highlight> in the sand.</para></section>
|
||||
<section id="jd002"><title>Footprints - truly a push technology</title><keyword>push</keyword>
|
||||
<para>One could safely say that making footprints is a push technology. This is even more true when the footprint maker is the Empress of the Universe. </para>
|
||||
<subsec1 id="jd003"><title>The sands of time</title><keyword>time</keyword>
|
||||
<para>The 1<super>st</super> think to remember about the Universe is the time/space continuum to which it conforms. This then confuses the sands of time to be something more like the sands of time/space continuum because if you wait on those sands long enough they may be somewhere else - not necessarily because of the time/space continuum but because the winds will <highlight style="ital">push</highlight> them down the beach.</para></subsec1>
|
||||
<subsec1 id="jd004"><title>Identifying the footprints</title>
|
||||
<para>In order to truly understand who has walked on the sands and left the footprints, it is important to identify the <keyword>characteristics</keyword>characteristics of the footprint. In the graphic <xref refloc="jd005" type="title"/>, we can see the footprints are large, well shaped, and evenly distributed from front to back and side to side.</para>
|
||||
<figure id="jd005"><title>Footprint in Sand</title><caption><para>Note the evenly distributed shape and indention</para></caption><graphic figname="footprint"/></figure>
|
||||
<para>This footprint begs the question, 'What kind of remarkable <keyword>shoe</keyword>shoe could make such a wonderful footprint?'</para>
|
||||
<table id="t1">
|
||||
<tgroup cols="2">
|
||||
<thead><row><entry>Shoe Type</entry><entry>Remarkability Rating</entry></row></thead>
|
||||
<tbody><row><entry>Acme Shoe</entry><entry>Unremarkable</entry></row>
|
||||
<row><entry>Budget Shoe</entry><entry>Not worth remarking on</entry></row>
|
||||
<row><entry>Super Duper Shoe</entry><entry>Absolutely Remarkable</entry></row></tbody>
|
||||
</tgroup></table></subsec1>
|
||||
<subsec1 id="jd006"><title>The Shoe What Made the Footprint</title>
|
||||
<para>The remarkable footprint is made by a combination of a terrific shoe worn on a fantastic foot propelled by a one-of-a-kind Empress. As can be seen in Figure <xref refloc="jd007" type="number"/>, the shoe is worthy of an Empress.</para>
|
||||
<figure id="jd007"><title>The Terrific Shoe</title><graphic figname="shoes"/></figure>
|
||||
<para>The design goals of the shoe were:
|
||||
<randlist style = "bulleted">
|
||||
<li><para>to minimize time-consuming manual tasks such as shoelace tying;</para></li>
|
||||
<li><para>to allow different decorations to be placed on the toes; and</para></li>
|
||||
<li><para>to enforce a good arch.</para></li></randlist></para></subsec1></section>
|
||||
<section id="jd008"><title>Documenting the Shoe</title>
|
||||
<para>Documenting the shoe was the best part for Fred Bloggs. His superior design could be captured for all time in a neutrally-encoded, content-specific manner. An excerpt from his DTD gives an insight into the type of information he captured in his documentation.</para>
|
||||
<code.block><!DOCTYPE shoedoc [
|
||||
<!ELEMENT shoedoc - - (design, mfg, care, recycle) >
|
||||
<!ATTLIST shoedoc designer CDATA #REQUIRED
|
||||
date CDATA #REQUIRED>
|
||||
<!ELEMENT design - - (specs, desc) >
|
||||
etc.
|
||||
</code.block>
|
||||
<para>An excerpt from the documentation also gives us insights.</para>
|
||||
<code.block><![CDATA[<design>
|
||||
<specs sizerange="4-12" widthrange="aa-d" color="navy black white red taupe">
|
||||
<para>The arch shall be high. The toe shall be narrow, but not pinch. The heel shall not come off in grates. Sand shall not get in.</para></specs>]]>
|
||||
</code.block>
|
||||
</section></body>
|
||||
<rear><acknowl>
|
||||
<para>The authors wish to express our thanks to the Universe for being there and to gravity for holding the sand down long enough to see the footprints.</para></acknowl>
|
||||
<bibliog>
|
||||
<bibitem id="jd000"><bib>Barrett 00</bib><pub>Barrett, B., Being Empress Made Easy, Galaxy Division of Universal Publishers. 0000</pub></bibitem></bibliog></rear></gcapaper>
|
13
utils/wxPython/demo/quotes.xml
Normal file
13
utils/wxPython/demo/quotes.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE quotations [
|
||||
<!ELEMENT collection (quotation)*>
|
||||
|
||||
<!ELEMENT em (#PCDATA) >
|
||||
<!ELEMENT foreign (#PCDATA) >
|
||||
<!ELEMENT cite (#PCDATA) >
|
||||
<!ELEMENT author (#PCDATA)>
|
||||
<!ELEMENT source (#PCDATA|cite)*>
|
||||
|
||||
<!ELEMENT quotation (#PCDATA|author|source)* >
|
||||
]>
|
||||
<collection><quotation>We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language. <source>Donald E. Knuth, "Structured Programming with goto Statements", Computing Surveys, Vol 6 No 4, Dec. 1974</source> </quotation> <quotation> The infinities aren't contagious except in that they often appear that way due to to their large size. <source>Tim Peters on the IEEE 754 floating point standard, 27 Apr 1998</source> </quotation> </collection>
|
@@ -15,9 +15,9 @@ class TestComboBox(wxPanel):
|
||||
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),
|
||||
wxComboBox(self, 500, "default value", wxPoint(80, 50), wxSize(95, 20),
|
||||
sampleList, wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, 50, self.EvtComboBox)
|
||||
EVT_COMBOBOX(self, 500, self.EvtComboBox)
|
||||
|
||||
|
||||
def EvtComboBox(self, event):
|
||||
|
@@ -25,6 +25,8 @@ class TestGrid(wxGrid):
|
||||
EVT_GRID_CELL_LCLICK(self, self.OnCellClick)
|
||||
EVT_GRID_LABEL_LCLICK(self, self.OnLabelClick)
|
||||
|
||||
self.SetEditInPlace(true)
|
||||
#print self.GetCells()
|
||||
|
||||
|
||||
def OnSelectCell(self, event):
|
||||
|
@@ -48,6 +48,7 @@ class TestListCtrlPanel(wxPanel):
|
||||
|
||||
self.currentItem = 0
|
||||
EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)
|
||||
EVT_LIST_DELETE_ITEM(self, tID, self.OnItemDelete)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnDoubleClick)
|
||||
EVT_RIGHT_DOWN(self.list, self.OnRightDown)
|
||||
|
||||
@@ -68,6 +69,10 @@ class TestListCtrlPanel(wxPanel):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemSelected: %s\n" % self.list.GetItemText(self.currentItem))
|
||||
|
||||
def OnItemDelete(self, event):
|
||||
self.log.WriteText("OnItemDelete\n")
|
||||
|
||||
|
||||
def OnDoubleClick(self, event):
|
||||
self.log.WriteText("OnDoubleClick item %s\n" % self.list.GetItemText(self.currentItem))
|
||||
|
||||
@@ -78,13 +83,16 @@ class TestListCtrlPanel(wxPanel):
|
||||
tPopupID1 = 0
|
||||
tPopupID2 = 1
|
||||
tPopupID3 = 2
|
||||
tPopupID4 = 3
|
||||
self.menu.Append(tPopupID1, "One")
|
||||
self.menu.Append(tPopupID2, "Two")
|
||||
self.menu.Append(tPopupID3, "Three")
|
||||
self.menu.Append(tPopupID4, "DeleteAllItems")
|
||||
EVT_MENU(self, tPopupID1, self.OnPopupOne)
|
||||
EVT_MENU(self, tPopupID2, self.OnPopupTwo)
|
||||
EVT_MENU(self, tPopupID3, self.OnPopupThree)
|
||||
self.PopupMenu(self.menu, self.x, self.y)
|
||||
EVT_MENU(self, tPopupID4, self.OnPopupFour)
|
||||
self.PopupMenu(self.menu, wxPoint(self.x, self.y))
|
||||
|
||||
def OnPopupOne(self, event):
|
||||
self.log.WriteText("Popup one\n")
|
||||
@@ -95,6 +103,9 @@ class TestListCtrlPanel(wxPanel):
|
||||
def OnPopupThree(self, event):
|
||||
self.log.WriteText("Popup three\n")
|
||||
|
||||
def OnPopupFour(self, event):
|
||||
self.list.DeleteAllItems()
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.list.SetDimensions(0, 0, w, h)
|
||||
|
@@ -12,6 +12,11 @@ class TestRadioButtons(wxPanel):
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(35, 30), wxDefaultSize,
|
||||
sampleList, 3, wxRA_SPECIFY_COLS)
|
||||
EVT_RADIOBOX(self, 30, self.EvtRadioBox)
|
||||
|
||||
|
||||
rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(35, 120), wxDefaultSize,
|
||||
sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER)
|
||||
EVT_RADIOBOX(self, 30, self.EvtRadioBox)
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTreeCtrlPanel(wxPanel):
|
||||
@@ -10,19 +12,23 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.tree = wxTreeCtrl(self, tID)
|
||||
root = self.tree.AddRoot("The Root Item")
|
||||
self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)
|
||||
|
||||
self.root = self.tree.AddRoot("The Root Item")
|
||||
for x in range(15):
|
||||
child = self.tree.AppendItem(root, "Item %d" % x)
|
||||
child = self.tree.AppendItem(self.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)
|
||||
self.tree.Expand(self.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)
|
||||
EVT_TREE_BEGIN_LABEL_EDIT(self, tID, self.OnBeginEdit)
|
||||
EVT_TREE_END_LABEL_EDIT (self, tID, self.OnEndEdit)
|
||||
|
||||
EVT_LEFT_DCLICK(self.tree, self.OnLeftDClick)
|
||||
EVT_RIGHT_DOWN(self.tree, self.OnRightClick)
|
||||
@@ -37,7 +43,30 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
def OnRightUp(self, event):
|
||||
(x,y) = event.Position();
|
||||
item = self.tree.HitTest(wxPoint(x,y))
|
||||
self.log.WriteText("OnRightUp: %s\n" % self.tree.GetItemText(item))
|
||||
self.log.WriteText("OnRightUp: %s (manually starting label edit)\n"
|
||||
% self.tree.GetItemText(item))
|
||||
self.tree.EditLabel(item)
|
||||
|
||||
|
||||
|
||||
def OnBeginEdit(self, event):
|
||||
self.log.WriteText("OnBeginEdit\n")
|
||||
# show how to prevent edit...
|
||||
if self.tree.GetItemText(event.GetItem()) == "The Root Item":
|
||||
wxBell()
|
||||
self.log.WriteText("You can't edit this one...\n")
|
||||
event.Veto()
|
||||
|
||||
def OnEndEdit(self, event):
|
||||
self.log.WriteText("OnEndEdit\n")
|
||||
# show how to reject edit, we'll not allow any digits
|
||||
for x in event.GetLabel():
|
||||
if x in string.digits:
|
||||
self.log.WriteText("You can't enter digits...\n")
|
||||
event.Veto()
|
||||
return
|
||||
|
||||
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
@@ -59,8 +88,8 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
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))
|
||||
self.item = event.GetItem()
|
||||
self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user