Added Python wrappers for wxRTTI for the wxVScrolledWindow,
wxVListBox, and wxHtmlListBox classes. Removed the calls to wxClassInfo::Cleanup and Initialize. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22713 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,14 +25,7 @@ import images
|
||||
_treeList = [
|
||||
# new stuff
|
||||
('Recent Additions', [
|
||||
'wxScrolledPanel',
|
||||
'ShapedWindow',
|
||||
'NewNamespace',
|
||||
'PopupMenu',
|
||||
'AnalogClockWindow',
|
||||
'MaskedEditControls',
|
||||
'wxTreeListCtrl',
|
||||
'wxGrid_MegaExample',
|
||||
'wxVListBox',
|
||||
]),
|
||||
|
||||
# managed windows == things with a (optional) caption you can close
|
||||
@@ -138,6 +131,7 @@ _treeList = [
|
||||
'wxStyledTextCtrl_2',
|
||||
'wxTimeCtrl',
|
||||
'wxTreeListCtrl',
|
||||
'wxVListBox',
|
||||
]),
|
||||
|
||||
# How to lay out the controls in a frame/dialog
|
||||
@@ -187,7 +181,9 @@ _treeList = [
|
||||
'DialogUnits',
|
||||
'DrawXXXList',
|
||||
'FontEnumerator',
|
||||
'NewNamespace',
|
||||
'PrintFramework',
|
||||
'ShapedWindow',
|
||||
'Throbber',
|
||||
'Unicode',
|
||||
'wxFileHistory',
|
||||
@@ -394,9 +390,8 @@ class wxPythonDemo(wx.Frame):
|
||||
# Create a TreeCtrl
|
||||
tID = wx.NewId()
|
||||
self.treeMap = {}
|
||||
self.tree = wx.TreeCtrl(splitter, tID,
|
||||
style=wx.TR_HAS_BUTTONS |
|
||||
wx.TR_HAS_VARIABLE_ROW_HEIGHT
|
||||
self.tree = wx.TreeCtrl(splitter, tID, style =
|
||||
wx.TR_DEFAULT_STYLE #| wx.TR_HAS_VARIABLE_ROW_HEIGHT
|
||||
)
|
||||
|
||||
root = self.tree.AddRoot("wxPython Overview")
|
||||
|
BIN
wxPython/demo/bmp_source/copy2.bmp
Normal file
BIN
wxPython/demo/bmp_source/copy2.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 246 B |
@@ -38,6 +38,7 @@ command_lines = [
|
||||
"-a -u -n New -m #C0C0C0 bmp_source/new.bmp images.py",
|
||||
"-a -u -n Open -m #C0C0C0 bmp_source/open.bmp images.py",
|
||||
"-a -u -n Copy -m #C0C0C0 bmp_source/copy.bmp images.py",
|
||||
"-a -u -n Copy2 -m #C0C0C0 bmp_source/copy2.bmp images.py",
|
||||
"-a -u -n Paste -m #C0C0C0 bmp_source/paste.bmp images.py",
|
||||
"-a -u -n Tog1 -m #C0C0C0 bmp_source/tog1.bmp images.py",
|
||||
"-a -u -n Tog2 -m #C0C0C0 bmp_source/tog2.bmp images.py",
|
||||
|
@@ -3439,6 +3439,26 @@ def getCopyImage():
|
||||
stream = cStringIO.StringIO(getCopyData())
|
||||
return wxImageFromStream(stream)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def getCopy2Data():
|
||||
return \
|
||||
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
|
||||
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
|
||||
\x00\x00\x9fIDATx\x9c\xa5\x93\xdb\x0e\x830\x0cC\xed\x84\xdfF\xeb\xb4\xef\xa6\
|
||||
\xde\x030z\t\x94\tK\x91z\xcb\x01\xbb*i\x8e\'\x9a\x00@yQ\xb4Is\x8e\x00\xb6\
|
||||
\x0f$Uu\x05\x0e\x01\x91$\r!\xa49\x94\x17I\x02\xc9_\xe3:Nq\x93}XL|\xeb\xe9\
|
||||
\x05\xa4p\rH\xa29h^[ Y\xd5\xb9\xb5\x17\x94gu\x19DA\x96\xe0c\xfe^\xcf\xe7Y\
|
||||
\x95\x05\x00M\xf5\x16Z;\x7f\xfdAd\xcf\xee\x1cj\xc1%|\xdan"LL\x19\xda\xe1}\
|
||||
\x90:\x00#\x95_l5\x04\xec\x89\x9f\xef?|\x8d\x97o\xe1\x8e\xbeJ\xfc\xb1\xde\
|
||||
\xf4x\xe1\x1d\x00\x00\x00\x00IEND\xaeB`\x82'
|
||||
|
||||
def getCopy2Bitmap():
|
||||
return wxBitmapFromImage(getCopy2Image())
|
||||
|
||||
def getCopy2Image():
|
||||
stream = cStringIO.StringIO(getCopy2Data())
|
||||
return wxImageFromStream(stream)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def getPasteData():
|
||||
return \
|
||||
|
33
wxPython/demo/templateold.py
Normal file
33
wxPython/demo/templateold.py
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Say something nice here</center></h2>
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
@@ -138,7 +138,7 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
# register some images for use in the AutoComplete box.
|
||||
self.RegisterImage(1, images.getSmilesBitmap())
|
||||
self.RegisterImage(2, images.getFile1Bitmap())
|
||||
self.RegisterImage(3, images.getCopyBitmap())
|
||||
self.RegisterImage(3, images.getCopy2Bitmap())
|
||||
|
||||
|
||||
|
||||
|
@@ -110,13 +110,25 @@ class TestPanel(wxPanel):
|
||||
text = self.tc.GetValue()
|
||||
if wxPlatform == "__WXMSW__": # This is why GetStringSelection was added
|
||||
text = text.replace('\n', '\r\n')
|
||||
self.log.write("GetSelection(): (%d, %d)\n"
|
||||
self.log.write("multi-line GetSelection(): (%d, %d)\n"
|
||||
"\tGetStringSelection(): %s\n"
|
||||
"\tSelectedText: %s\n" %
|
||||
(start, end,
|
||||
self.tc.GetStringSelection(),
|
||||
repr(text[start:end])))
|
||||
|
||||
start, end = self.tc1.GetSelection()
|
||||
text = self.tc1.GetValue()
|
||||
if wxPlatform == "__WXMSW__": # This is why GetStringSelection was added
|
||||
text = text.replace('\n', '\r\n')
|
||||
self.log.write("single-line GetSelection(): (%d, %d)\n"
|
||||
"\tGetStringSelection(): %s\n"
|
||||
"\tSelectedText: %s\n" %
|
||||
(start, end,
|
||||
self.tc1.GetStringSelection(),
|
||||
repr(text[start:end])))
|
||||
|
||||
|
||||
def OnT5LeftDown(self, evt):
|
||||
evt.Skip()
|
||||
wxCallAfter(self.LogT5Position, evt)
|
||||
|
124
wxPython/demo/wxVListBox.py
Normal file
124
wxPython/demo/wxVListBox.py
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# The wxVListBox is much like a regular wxListBox except you draw the
|
||||
# items yourself and the items can vary in height.
|
||||
class MyVListBox(wxVListBox):
|
||||
|
||||
# This method must be overridden. When called it should draw the
|
||||
# n'th item on the dc within the rect. How it is drawn, and what
|
||||
# is drawn is entirely up to you.
|
||||
def OnDrawItem(self, dc, rect, n):
|
||||
dc.DrawLabel(self._getItemText(n), rect,
|
||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL)
|
||||
|
||||
# This method must be overridden. It should return the height
|
||||
# required to draw the n'th item.
|
||||
def OnMeasureItem(self, n):
|
||||
height = 0
|
||||
for line in self._getItemText(n).split('\n'):
|
||||
w, h = self.GetTextExtent(line)
|
||||
height += h
|
||||
return height + 5
|
||||
|
||||
|
||||
# These are also overridable:
|
||||
#
|
||||
# OnDrawSeparator(dc, rect, n)
|
||||
# Draw a separator between items. Note that rect may be reduced
|
||||
# in size if desired so OnDrawItem gets a smaller rect.
|
||||
#
|
||||
# OnDrawBackground(dc, rect, n)
|
||||
# Draw the background and maybe a border if desired.
|
||||
|
||||
|
||||
def _getItemText(self, item):
|
||||
if item % 2 == 0:
|
||||
return "This is item# %d" % item
|
||||
else:
|
||||
return "This is item# %d\n with an extra line" % item
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# The wxHtmlListBox derives from wxVListBox, but draws each item
|
||||
# itself as a wxHtmlCell.
|
||||
class MyHtmlListBox(wxHtmlListBox):
|
||||
|
||||
def OnGetItem(self, n):
|
||||
if n % 2 == 0:
|
||||
return "This is item# <b>%d</b>" % n
|
||||
else:
|
||||
return "This is item# <b>%d</b> <br>Any <font color='RED'>HTML</font> is okay." % n
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
spacer = 50
|
||||
|
||||
vlb = MyVListBox(self, -1, size=(150, 250), style=wxBORDER_SUNKEN)
|
||||
vlb.SetItemCount(50)
|
||||
vlb.SetSelection(0)
|
||||
vlb.SetFocus()
|
||||
vlbSizer = wxBoxSizer(wxVERTICAL)
|
||||
vlbSizer.Add((spacer, spacer))
|
||||
vlbSizer.Add(wxStaticText(self, -1, "wxVListBox"), 0, 5, wxALL)
|
||||
vlbSizer.Add(vlb)
|
||||
|
||||
hlb = MyHtmlListBox(self, -1, size=(150, 250), style=wxBORDER_SUNKEN)
|
||||
hlb.SetItemCount(50)
|
||||
hlb.SetSelection(0)
|
||||
hlbSizer = wxBoxSizer(wxVERTICAL)
|
||||
hlbSizer.Add((spacer, spacer))
|
||||
hlbSizer.Add(wxStaticText(self, -1, "wxHtmlListBox"), 0, 5, wxALL)
|
||||
hlbSizer.Add(hlb)
|
||||
|
||||
sizer = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer.Add((spacer, spacer))
|
||||
sizer.Add(vlbSizer)
|
||||
sizer.Add((spacer, spacer))
|
||||
sizer.Add((spacer, spacer))
|
||||
sizer.Add(hlbSizer)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>wxVListBox and wxHtmlListBox</center></h2>
|
||||
<hr>
|
||||
|
||||
The "V" in wxVListBox stands for both "virtual" because it can have an
|
||||
unlimited number of items since it doesn't store them itself, and
|
||||
"variable" since items can vary in height. It has much the same
|
||||
interface as wxListBox and also emits the same events so you can use
|
||||
the same EVT_LISTBOX function to connect a handler.
|
||||
<p>
|
||||
|
||||
The wxHtmlListBox derives from wxVListBox, but draws each item itself
|
||||
as a wxHtmlCell. This means that you just need to provide a snippet
|
||||
of HTML for each item when requested.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
Reference in New Issue
Block a user