New typemaps for wxString when compiling for Python 2.0 and beyond

that allow Unicode objects to be passed as well as String objects.  If
a Unicode object is passed PyString_AsStringAndSize is used to convert
it to a wxString using the default encoding.

Fixed the generic buttons so tool tips work for them.

Fixed a bug in the demo's tree control.

Added a listbox to the listbox demo that shows how to find items with
a patching prefix as keys are typed.

Added code to the wxListCtrl demo to show how to get text from a
column in report mode.

Added code to the toolbar demo to clear the long help from the status
bar after 2 seconds.

Added wxJoystick.

Fixed wxTimer so it can be used as described in the docs, either with
a Notify method in a subclass, or sending an event to a wxEvtHandler
object, (usually a window.)

Added wxNotifyEvent.Allow()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8764 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2000-11-21 03:44:14 +00:00
parent baeea2909c
commit 185d7c3ee4
55 changed files with 6223 additions and 729 deletions

View File

@@ -1,6 +1,51 @@
from wxPython.wx import *
import string
#---------------------------------------------------------------------------
class wxFindPrefixListBox(wxListBox):
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize,
choices=[], style=0, validator=wxDefaultValidator):
wxListBox.__init__(self, parent, id, pos, size, choices, style, validator)
self.typedText = ''
EVT_KEY_UP(self, self.OnKey)
def FindPrefix(self, prefix):
if prefix:
prefix = string.lower(prefix)
length = len(prefix)
for x in range(self.Number()):
text = self.GetString(x)
text = string.lower(text)
if text[:length] == prefix:
return x
return -1
def OnKey(self, evt):
key = evt.GetKeyCode()
if key >= 32 and key <= 127:
self.typedText = self.typedText + chr(key)
item = self.FindPrefix(self.typedText)
if item != -1:
self.SetSelection(item)
elif key == WXK_BACK: # backspace removes one character and backs up
self.typedText = self.typedText[:-1]
if not self.typedText:
self.SetSelection(0)
else:
item = self.FindPrefix(self.typedText)
if item != -1:
self.SetSelection(item)
else:
evt.Skip()
#---------------------------------------------------------------------------
class TestListBox(wxPanel):
@@ -32,6 +77,16 @@ class TestListBox(wxPanel):
self.lb2.SetSelection(0)
sampleList = sampleList + ['test a', 'test aa', 'test aab',
'test ab', 'test abc', 'test abcc',
'test abcd' ]
sampleList.sort()
wxStaticText(self, -1, "Find Prefix:", wxPoint(15, 250))
fp = wxFindPrefixListBox(self, -1, wxPoint(80, 250), wxSize(80, 120),
sampleList, wxLB_SINGLE)
fp.SetSelection(0)
def EvtListBox(self, event):
self.log.WriteText('EvtListBox: %s\n' % event.GetString())