Lots of wx namespace updates for the wx.lib package and the demo from

Jeff Grimmett with some tweaks and changes from Robin


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24889 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-12-17 00:34:40 +00:00
parent e1f4ff6ddc
commit b881fc787d
69 changed files with 2756 additions and 2103 deletions

View File

@@ -7,6 +7,10 @@
# o the three libraries below all have not been hit by the
# wx renamer.
#
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o A few changes to correct my own mistakes earlier :-).
#
import string
import sys
@@ -577,9 +581,9 @@ with right-insert for ordinal:""")
self.log.write(line)
def OnParensCheck( self, event ):
self.intctrl1.SetCtrlParameters(useParensForNegatives=event.Checked())
self.intctrl2.SetCtrlParameters(useParensForNegatives=event.Checked())
self.floatctrl.SetCtrlParameters(useParensForNegatives=event.Checked())
self.intctrl1.SetCtrlParameters(useParensForNegatives=event.IsChecked())
self.intctrl2.SetCtrlParameters(useParensForNegatives=event.IsChecked())
self.floatctrl.SetCtrlParameters(useParensForNegatives=event.IsChecked())
def OnIpAddrChange( self, event ):
ipaddr = self.FindWindowById( event.GetId() )
@@ -597,7 +601,7 @@ with right-insert for ordinal:""")
formatcodes += 'r'
mask = '###'
else:
choices = states
choices = med.states
mask = 'AA'
formatcodes += '!'
self.dynamicbox.SetCtrlParameters( mask = mask,

View File

@@ -1,76 +1,87 @@
# 11/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Updated for wx namespace
from wxPython.wx import *
import images
import wx
import images
#----------------------------------------------------------------------
text = """\
Right-click on the panel (or Ctrl-click on the Mac) to show a popup
menu. Then look at the code for this sample. Notice how the
PopupMenu method is similar to the ShowModal method of a wxDialog in
that it doesn't return until the popup menu has been dismissed. The
event handlers for the popup menu items can either be attached to the
menu itself, or to the window that invokes PopupMenu.
Right-click on any bare area of this panel (or Ctrl-click on the Mac)
to show a popup menu. Then look at the code for this sample. Notice
how the PopupMenu method is similar to the ShowModal method of a
wx.Dialog in that it doesn't return until the popup menu has been
dismissed. The event handlers for the popup menu items can either be
attached to the menu itself, or to the window that invokes PopupMenu.
"""
#----------------------------------------------------------------------
class TestPanel(wxPanel):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wxPanel.__init__(self, parent, -1)
box = wxBoxSizer(wxVERTICAL)
wx.Panel.__init__(self, parent, -1)
box = wx.BoxSizer(wx.VERTICAL)
# Make and layout the controls
fs = self.GetFont().GetPointSize()
bf = wxFont(fs+4, wxSWISS, wxNORMAL, wxBOLD)
nf = wxFont(fs+2, wxSWISS, wxNORMAL, wxNORMAL)
bf = wx.Font(fs+4, wx.SWISS, wx.NORMAL, wx.BOLD)
nf = wx.Font(fs+2, wx.SWISS, wx.NORMAL, wx.NORMAL)
t = wxStaticText(self, -1, "PopupMenu")
t = wx.StaticText(self, -1, "PopupMenu")
t.SetFont(bf)
box.Add(t, 0, wxCENTER|wxALL, 5)
box.Add(t, 0, wx.CENTER|wx.ALL, 5)
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
box.Add(wxStaticLine(self, -1), 0, wxEXPAND)
box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
box.Add((10,20))
t = wxStaticText(self, -1, text)
t = wx.StaticText(self, -1, text)
t.SetFont(nf)
box.Add(t, 0, wxCENTER|wxALL, 5)
box.Add(t, 0, wx.CENTER|wx.ALL, 5)
self.SetSizer(box)
EVT_RIGHT_UP(self, self.OnRightClick)
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
def OnRightClick(self, event):
self.log.WriteText("OnRightClick\n")
# only do this part the first time so the events are only bound once
#
# Yet another anternate way to do IDs. Some prefer them up top to
# avoid clutter, some prefer them close to the object of interest
# for clarity.
if not hasattr(self, "popupID1"):
self.popupID1 = wxNewId()
self.popupID2 = wxNewId()
self.popupID3 = wxNewId()
self.popupID4 = wxNewId()
self.popupID5 = wxNewId()
self.popupID6 = wxNewId()
self.popupID7 = wxNewId()
self.popupID8 = wxNewId()
self.popupID9 = wxNewId()
EVT_MENU(self, self.popupID1, self.OnPopupOne)
EVT_MENU(self, self.popupID2, self.OnPopupTwo)
EVT_MENU(self, self.popupID3, self.OnPopupThree)
EVT_MENU(self, self.popupID4, self.OnPopupFour)
EVT_MENU(self, self.popupID5, self.OnPopupFive)
EVT_MENU(self, self.popupID6, self.OnPopupSix)
EVT_MENU(self, self.popupID7, self.OnPopupSeven)
EVT_MENU(self, self.popupID8, self.OnPopupEIght)
EVT_MENU(self, self.popupID9, self.OnPopupNine)
self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID3 = wx.NewId()
self.popupID4 = wx.NewId()
self.popupID5 = wx.NewId()
self.popupID6 = wx.NewId()
self.popupID7 = wx.NewId()
self.popupID8 = wx.NewId()
self.popupID9 = wx.NewId()
self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
self.Bind(wx.EVT_MENU, self.OnPopupFour, id=self.popupID4)
self.Bind(wx.EVT_MENU, self.OnPopupFive, id=self.popupID5)
self.Bind(wx.EVT_MENU, self.OnPopupSix, id=self.popupID6)
self.Bind(wx.EVT_MENU, self.OnPopupSeven, id=self.popupID7)
self.Bind(wx.EVT_MENU, self.OnPopupEight, id=self.popupID8)
self.Bind(wx.EVT_MENU, self.OnPopupNine, id=self.popupID9)
# make a menu
menu = wxMenu()
menu = wx.Menu()
# Show how to put an icon in the menu
item = wxMenuItem(menu, self.popupID1,"One")
item = wx.MenuItem(menu, self.popupID1,"One")
item.SetBitmap(images.getSmilesBitmap())
menu.AppendItem(item)
# add some other items
@@ -80,7 +91,7 @@ class TestPanel(wxPanel):
menu.Append(self.popupID5, "Five")
menu.Append(self.popupID6, "Six")
# make a submenu
sm = wxMenu()
sm = wx.Menu()
sm.Append(self.popupID8, "sub item 1")
sm.Append(self.popupID9, "sub item 1")
menu.AppendMenu(self.popupID7, "Test Submenu", sm)
@@ -113,7 +124,7 @@ class TestPanel(wxPanel):
def OnPopupSeven(self, event):
self.log.WriteText("Popup seven\n")
def OnPopupEIght(self, event):
def OnPopupEight(self, event):
self.log.WriteText("Popup eight\n")
def OnPopupNine(self, event):

View File

@@ -9,6 +9,10 @@
# o printout.py is generating a snootful of errors all related to the
# requirement for tuples on the base DC calls now
#
# 12/10/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Issues corrected.
#
import os

View File

@@ -1,4 +1,10 @@
<html>
<!-- 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
o Updated for wx namespace.
-->
<head>
<title>wxHTML does wxPython!</title>
</head>
@@ -13,18 +19,18 @@ sources and doc-string <a href="../../lib/wxpTag.py">here</a>.
The button below is added to the page like this:
<pre>
&lt;center>&lt;wxp class="wxButton" width="50%">
&lt;center>&lt;wxp module="wx" class="Button" width="50%">
&lt;param name="label" value="It works!">
&lt;param name="id" value="wxID_OK">
&lt;param name="id" value="ID_OK">
&lt;/wxp>&lt;/center>
</pre>
<hr>
<center>
<wxp class="wxButton" width="50%">
<wxp module="wx" class="Button" width="50%">
<param name="label" value="It works!">
<param name="id" value="wxID_OK">
<param name="id" value="ID_OK">
</wxp>
</center>

View File

@@ -57,7 +57,7 @@ class MyFrame(wx.Frame):
# Get a copy of stdout and set it aside. We'll use it later.
self.save_stdout = sys.stdout
# Now point to the output object for stdout
sys.stdout = self.output = output
# ... and use it.
@@ -117,9 +117,10 @@ if __name__ == "__main__":
## sys.stdout.close()
## self.Destroy()
class MyApp(wx.App):
# Override the default output window and point it to the
# custom class.
#>>Todo: wx renamer didn't get this
outputWindowClass = infoframe.wxPyInformationalMessagesFrame
def OnInit(self):
@@ -141,7 +142,6 @@ if __name__ == "__main__":
self.SetTopWindow(frame)
# Associate the frame with stdout.
#>>Todo: wx renamer didn't get this
if isinstance(sys.stdout, infoframe.wxPyInformationalMessagesFrame):
sys.stdout.SetParent(frame)

View File

@@ -2,17 +2,20 @@
#
# o Updated for wx namespace
#
# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o got the wxpTag stuff working right.
#
import os
import sys
import wx
import wx.html as html
import wx.html as html
import wx.lib.wxpTag
from Main import opj
##wxTrap()
#----------------------------------------------------------------------
# This shows how to catch the OnLinkClicked non-event. (It's a virtual

View File

@@ -7,6 +7,10 @@
# o intctrl needs the renamer applied.
# o intctrl needs new event binders.
#
# 12/08/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o All issues corrected
#
import wx
import wx.lib.intctrl as intctrl
@@ -70,10 +74,9 @@ class TestPanel( wx.Panel ):
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none)
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowLong, self.allow_long)
# Once the intctrl library is updated, this should be too.
intctrl.EVT_INT(self, self.min.GetId(), self.SetTargetMinMax)
intctrl.EVT_INT(self, self.max.GetId(), self.SetTargetMinMax)
intctrl.EVT_INT(self, self.target_ctl.GetId(), self.OnTargetChange)
self.Bind(intctrl.EVT_INT, self.SetTargetMinMax, self.min)
self.Bind(intctrl.EVT_INT, self.SetTargetMinMax, self.max)
self.Bind(intctrl.EVT_INT, self.OnTargetChange, self.target_ctl)
def OnSetMin( self, event ):

View File

@@ -19,6 +19,11 @@
# o listctrl mixin needs wx renamer.
# o wx.ListItem.GetText() returns a wxString pointer, not the text.
#
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o ColumnSorterMixin implementation was broke - added event.Skip()
# to column click event to allow event to fall through to mixin.
#
import wx
import wx.lib.mixins.listctrl as listmix
@@ -263,6 +268,7 @@ class TestListCtrlPanel(wx.Panel, listmix.wxColumnSorterMixin):
def OnColClick(self, event):
self.log.WriteText("OnColClick: %d\n" % event.GetColumn())
event.Skip()
def OnColRightClick(self, event):
item = self.list.GetColumn(event.GetColumn())

View File

@@ -6,6 +6,10 @@
#
# o wx.lib.maskednumctrl needs hit up with the renamer and new binders
#
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Issues with lib corrected.
#
import string
import sys
@@ -148,15 +152,15 @@ value entry ctrl:""")
panel.Move( (50,10) )
self.panel = panel
mnum.EVT_MASKEDNUM( self, self.integerwidth.GetId(), self.OnSetIntWidth )
mnum.EVT_MASKEDNUM( self, self.fractionwidth.GetId(), self.OnSetFractionWidth )
self.Bind(mnum.EVT_MASKEDNUM, self.OnSetIntWidth, self.integerwidth )
self.Bind(mnum.EVT_MASKEDNUM, self.OnSetFractionWidth, self.fractionwidth )
self.Bind(wx.EVT_TEXT, self.OnSetGroupChar, self.groupchar )
self.Bind(wx.EVT_TEXT, self.OnSetDecimalChar, self.decimalchar )
self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min )
self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max )
mnum.EVT_MASKEDNUM( self, self.min.GetId(), self.SetTargetMinMax )
mnum.EVT_MASKEDNUM( self, self.max.GetId(), self.SetTargetMinMax )
self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.min )
self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.max )
self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target )
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none )
@@ -165,7 +169,7 @@ value entry ctrl:""")
self.Bind(wx.EVT_CHECKBOX, self.OnSetUseParens, self.use_parens )
self.Bind(wx.EVT_CHECKBOX, self.OnSetSelectOnEntry, self.select_on_entry )
mnum.EVT_MASKEDNUM( self, self.target_ctl.GetId(), self.OnTargetChange )
self.Bind(mnum.EVT_MASKEDNUM, self.OnTargetChange, self.target_ctl )
self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect )

View File

@@ -8,6 +8,10 @@
# o There appears to be a problem with the image that
# the library is trying to use for the alternate cursor
#
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o renamer issue shelved.
#
import wx
import wx.lib.multisash as sash
@@ -38,6 +42,10 @@ returned by GetSaveData, as it is just another object in the dictionary.
#---------------------------------------------------------------------------
class TestWindow(stc.StyledTextCtrl):
# shared document reference
doc = None
def __init__(self, parent):
stc.StyledTextCtrl.__init__(self, parent, -1, style=wx.NO_BORDER)
self.SetMarginWidth(1,0)
@@ -52,19 +60,18 @@ class TestWindow(stc.StyledTextCtrl):
wx.Font(fSize, wx.MODERN, wx.NORMAL, wx.NORMAL)
)
self.SetText(sampleText)
class TestFrame(wx.Frame):
def __init__(self, parent, log):
wx.Frame.__init__(self, parent, -1, "Multi Sash Demo", size=(640,480))
self.multi = sash.wxMultiSash(self,-1,pos=(0,0), size=(640,480))
# Use this method to set the default class that will be created when
# a new sash is created. The class's constructor needs 1 parameter
# which is the parent of the window
self.multi.SetDefaultChildClass(TestWindow)
if self.doc:
self.SetDocPointer(self.doc)
else:
self.SetText(sampleText)
TestWindow.doc = self.GetDocPointer()
def SutdownDemo(self):
# Reset doc reference in case this demo is run again
TestWindow.doc = None
#---------------------------------------------------------------------------
@@ -78,9 +85,6 @@ def runTest(frame, nb, log):
return multi
# win = TestPanel(nb, log)
# return win
#----------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
#
# o Updated for wx namespace
#
# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o wx renamer not applied to library.
# o Updated URL for SF link in overview.
#
import wx
@@ -54,7 +54,7 @@ wxPyColourChooser was written and is maintained by:
Michael Gilfix <mgilfix@eecs.tufts.edu>
You can find the latest wxPyColourChooser code at
http://www.sourceforge.net/wxcolourchooser. If you have
http://sourceforge.net/projects/wxcolourchooser/. If you have
any suggestions or want to submit a patch, please send
it my way at: mgilfix@eecs.tufts.edu
"""

View File

@@ -6,6 +6,11 @@
#
# o The rightalign library needs converted for this to work correctly.
#
# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o All issues resolved.
#
############################################################################\
# Note: this demo has been converted, but the control is deprecated because |

View File

@@ -6,6 +6,10 @@
#
# o scrolledpanel lib needs wx update
#
# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o lib updated, all is well.
#
import wx
import wx.lib.scrolledpanel as scrolled

View File

@@ -7,6 +7,10 @@
# o wx renamer needed for timectrl lib
# o presense of spin control causing probs (see spin ctrl demo for details)
#
# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o New binders applied. Issues still exist.
#
import wx
import wx.lib.timectrl as timectl
@@ -146,17 +150,14 @@ class TestPanel( scrolled.wxScrolledPanel ):
self.SetupScrolling()
self.Bind(wx.EVT_BUTTON, self.OnButtonClick, buttonChange )
timectl.EVT_TIMEUPDATE( self, self.time12.GetId(), self.OnTimeChange )
timectl.EVT_TIMEUPDATE( self, self.time24.GetId(), self.OnTimeChange )
timectl.EVT_TIMEUPDATE( self, self.spinless_ctrl.GetId(), self.OnTimeChange )
self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time12 )
self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time24 )
self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl )
self.Bind(wx.EVT_CHECKBOX, self.OnBoundsCheck, self.set_bounds )
self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_check )
timectl.EVT_TIMEUPDATE( self, self.min.GetId(), self.SetTargetMinMax )
timectl.EVT_TIMEUPDATE( self, self.max.GetId(), self.SetTargetMinMax )
timectl.EVT_TIMEUPDATE( self, self.target_ctrl.GetId(), self.OnTimeChange )
self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min )
self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max )
self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl )
def OnTimeChange( self, event ):