wxPython stuff:
1. Added test for HTML printing 2. Update wxFontEnumerator 3. wxPyEvent and wxPyCommandEvent derived classes now return the actual Python object in the event handler. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,14 +3,14 @@ from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class MyFontEnumerator(wxFontEnumerator):
|
||||
def __init__(self, list):
|
||||
wxFontEnumerator.__init__(self)
|
||||
self.list = list
|
||||
## class MyFontEnumerator(wxFontEnumerator):
|
||||
## def __init__(self, list):
|
||||
## wxFontEnumerator.__init__(self)
|
||||
## self.list = list
|
||||
|
||||
def OnFacename(self, face):
|
||||
self.list.append(face)
|
||||
return true
|
||||
## def OnFacename(self, face):
|
||||
## self.list.append(face)
|
||||
## return true
|
||||
|
||||
|
||||
|
||||
@@ -18,9 +18,14 @@ class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
list = []
|
||||
e = MyFontEnumerator(list)
|
||||
## list = []
|
||||
## e = MyFontEnumerator(list)
|
||||
## e.EnumerateFacenames()
|
||||
|
||||
e = wxFontEnumerator()
|
||||
e.EnumerateFacenames()
|
||||
list = e.GetFacenames()
|
||||
|
||||
list.sort()
|
||||
|
||||
wxStaticText(self, -1, "Face names:", wxPoint(15, 50), wxSize(65, 18))
|
||||
|
@@ -42,7 +42,7 @@ _treeList = [
|
||||
|
||||
('Miscellaneous', [ 'DragAndDrop', 'CustomDragAndDrop', 'FontEnumerator',
|
||||
'wxTimer', 'wxValidator', 'wxGLCanvas', 'DialogUnits',
|
||||
'wxImage', 'PrintFramework', 'wxOGL']),
|
||||
'wxImage', 'PrintFramework', 'wxOGL', 'PythonEvents']),
|
||||
|
||||
('wxPython Library', ['OldSizers', 'Layoutf', 'wxScrolledMessageDialog',
|
||||
'wxMultipleChoiceDialog', 'wxPlotCanvas', 'wxFloatBar',
|
||||
|
85
utils/wxPython/demo/PythonEvents.py
Normal file
85
utils/wxPython/demo/PythonEvents.py
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import sys
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
myEVT_BUTTON_CLICKPOS = 5015
|
||||
|
||||
def EVT_BUTTON_CLICKPOS(win, id, func):
|
||||
win.Connect(id, -1, myEVT_BUTTON_CLICKPOS, func)
|
||||
|
||||
|
||||
|
||||
class MyEvent(wxPyCommandEvent):
|
||||
def __init__(self, evtType, id):
|
||||
wxPyCommandEvent.__init__(self, evtType, id)
|
||||
self.myVal = None
|
||||
|
||||
#def __del__(self):
|
||||
# print '__del__'
|
||||
# wxPyCommandEvent.__del__(self)
|
||||
|
||||
def SetMyVal(self, val):
|
||||
self.myVal = val
|
||||
|
||||
def GetMyVal(self):
|
||||
return self.myVal
|
||||
|
||||
|
||||
|
||||
class MyButton(wxButton):
|
||||
def __init__(self, parent, id, txt, pos):
|
||||
wxButton.__init__(self, parent, id, txt, pos)
|
||||
EVT_LEFT_DOWN(self, self.OnLeftDown)
|
||||
|
||||
def OnLeftDown(self, event):
|
||||
pt = event.GetPosition()
|
||||
evt = MyEvent(myEVT_BUTTON_CLICKPOS, self.GetId())
|
||||
evt.SetMyVal(pt)
|
||||
#print id(evt), sys.getrefcount(evt)
|
||||
self.GetEventHandler().ProcessEvent(evt)
|
||||
#print id(evt), sys.getrefcount(evt)
|
||||
event.Skip()
|
||||
|
||||
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
b = MyButton(self, -1, " Click me ", wxPoint(30,30))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnClick)
|
||||
EVT_BUTTON_CLICKPOS(self, b.GetId(), self.OnMyEvent)
|
||||
|
||||
wxStaticText(self, -1, "Please see the Overview and Demo Code for details...",
|
||||
wxPoint(30, 80))
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.WriteText("OnClick\n")
|
||||
|
||||
def OnMyEvent(self, event):
|
||||
#print id(event), sys.getrefcount(event)
|
||||
self.log.WriteText("MyEvent: %s\n" % (event.GetMyVal(), ) )
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This demo is a contrived example of defining an event class in wxPython and sending it up the containment heirachy for processing.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
@@ -36,6 +36,8 @@ class TestHtmlPanel(wxPanel):
|
||||
self.html.SetRelatedFrame(frame, "wxPython: (A Demonstration) -- %s")
|
||||
self.html.SetRelatedStatusBar(0)
|
||||
|
||||
self.printer = wxHtmlEasyPrinting()
|
||||
|
||||
self.box = wxBoxSizer(wxVERTICAL)
|
||||
self.box.Add(self.html, 1, wxGROW)
|
||||
|
||||
@@ -60,6 +62,10 @@ class TestHtmlPanel(wxPanel):
|
||||
EVT_BUTTON(self, 1205, self.OnForward)
|
||||
subbox.Add(btn, 1, wxGROW | wxALL, 2)
|
||||
|
||||
btn = wxButton(self, 1207, "Print")
|
||||
EVT_BUTTON(self, 1207, self.OnPrint)
|
||||
subbox.Add(btn, 1, wxGROW | wxALL, 2)
|
||||
|
||||
btn = wxButton(self, 1206, "View Source")
|
||||
EVT_BUTTON(self, 1206, self.OnViewSource)
|
||||
subbox.Add(btn, 1, wxGROW | wxALL, 2)
|
||||
@@ -116,6 +122,9 @@ class TestHtmlPanel(wxPanel):
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
def OnPrint(self, event):
|
||||
self.printer.PrintFile(self.html.GetOpenedPage())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
|
Reference in New Issue
Block a user