Second phase of OOR completed. (Original python object return for
wxEvtHandler and derived classes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -86,6 +86,5 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = """\
|
||||
A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).
|
||||
|
||||
"""
|
||||
|
@@ -14,6 +14,7 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.CreateGrid(25, 25)
|
||||
##self.EnableEditing(false)
|
||||
|
||||
# simple cell formatting
|
||||
self.SetColSize(3, 200)
|
||||
|
@@ -28,6 +28,9 @@ _treeList = [
|
||||
'VirtualListCtrl',
|
||||
'wxListCtrl',
|
||||
'TablePrint',
|
||||
'OOR',
|
||||
'wxFindReplaceDialog',
|
||||
##'wxPopupWindow',
|
||||
]),
|
||||
|
||||
('Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame',
|
||||
@@ -35,12 +38,15 @@ _treeList = [
|
||||
'wxScrolledWindow', 'wxSplitterWindow',
|
||||
'wxStatusBar', 'wxNotebook',
|
||||
'wxHtmlWindow',
|
||||
'wxStyledTextCtrl_1', 'wxStyledTextCtrl_2',]),
|
||||
'wxStyledTextCtrl_1', 'wxStyledTextCtrl_2',
|
||||
##'wxPopupWindow',
|
||||
]),
|
||||
|
||||
('Common Dialogs', ['wxColourDialog', 'wxDirDialog', 'wxFileDialog',
|
||||
'wxSingleChoiceDialog', 'wxTextEntryDialog',
|
||||
'wxFontDialog', 'wxPageSetupDialog', 'wxPrintDialog',
|
||||
'wxMessageDialog', 'wxProgressDialog']),
|
||||
'wxMessageDialog', 'wxProgressDialog', 'wxFindReplaceDialog',
|
||||
]),
|
||||
|
||||
('Controls', ['wxButton', 'wxCheckBox', 'wxCheckListBox', 'wxChoice',
|
||||
'wxComboBox', 'wxGauge', 'wxListBox', 'wxListCtrl', 'wxTextCtrl',
|
||||
|
@@ -59,6 +59,15 @@ class TestPanel(wxPanel):
|
||||
else:
|
||||
self.log.write("The objects are NOT the same! <frown>\n")
|
||||
|
||||
win = evt.GetEventObject()
|
||||
if win is None:
|
||||
self.log.write("***** OOPS! None returned...\n")
|
||||
return
|
||||
if win is self.btn2:
|
||||
self.log.write("The objects are the same! <grin>\n")
|
||||
else:
|
||||
self.log.write("The objects are NOT the same! <frown>\n")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -79,21 +88,21 @@ SWIG isn't able to tell the actual type it just creates a new Python
|
||||
shadow object of the base type to wrap around the base type pointer
|
||||
and returns it.
|
||||
|
||||
<p>In wxPython this can cause annoying issues. For example if you
|
||||
call:
|
||||
<p>In wxPython prior to 2.3.0 this could cause annoying issues. For
|
||||
example if you called:
|
||||
|
||||
<pre>
|
||||
|
||||
myText = someWindow.FindWindowById(txtID)
|
||||
</pre>
|
||||
|
||||
expecting to get a wxTextCtrl you will actually get a wxWindow object
|
||||
expecting to get a wxTextCtrl you would actually get a wxWindow object
|
||||
instead. If you then try to call SetValue on that object you'll get
|
||||
an exception since there is no such method. This is the reason for
|
||||
the wxPyTypeCast hack that has been in wxPython for so long.
|
||||
|
||||
<p>Even with wxPyTypeCast there is the issue that the object returned
|
||||
is not the same one that was created in Python originally, but a new
|
||||
<p>Even with wxPyTypeCast there was the issue that the object returned
|
||||
was not the same one that was created in Python originally, but a new
|
||||
object of the same type that wraps the same C++ pointer. If the
|
||||
programmer has set additional attributes of that original object they
|
||||
will not exist in the new object.
|
||||
@@ -112,7 +121,7 @@ and be able to then turn wxPyTypeCast in to a no-op.
|
||||
</ol>
|
||||
|
||||
<p>The first button below shows the first of these phases (<i>working</i>)
|
||||
and the second will show #2 (<i>not yet working.</i>)
|
||||
and the second will show #2 (<i>working as of 2.3.2</i>)
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
@@ -31,18 +31,18 @@ class MyPrintout(wxPrintout):
|
||||
self.base_OnPreparePrinting()
|
||||
|
||||
def HasPage(self, page):
|
||||
self.log.WriteText("wxPrintout.HasPage\n")
|
||||
if page == 1:
|
||||
self.log.WriteText("wxPrintout.HasPage: %d\n" % page)
|
||||
if page <= 2:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
def GetPageInfo(self):
|
||||
self.log.WriteText("wxPrintout.GetPageInfo\n")
|
||||
return (1, 1, 1, 1)
|
||||
return (1, 2, 1, 2)
|
||||
|
||||
def OnPrintPage(self, page):
|
||||
self.log.WriteText("wxPrintout.OnPrintPage\n")
|
||||
self.log.WriteText("wxPrintout.OnPrintPage: %d\n" % page)
|
||||
dc = self.GetDC()
|
||||
|
||||
#-------------------------------------------
|
||||
@@ -80,6 +80,8 @@ class MyPrintout(wxPrintout):
|
||||
#-------------------------------------------
|
||||
|
||||
self.canvas.DoDrawing(dc)
|
||||
dc.DrawText("Page: %d" % page, marginX/2, maxY-marginY)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
|
@@ -28,36 +28,4 @@ def runTest(frame, nb, log):
|
||||
overview = """\
|
||||
This class represents the file chooser dialog.
|
||||
|
||||
wxFileDialog()
|
||||
----------------------------
|
||||
|
||||
wxFileDialog(wxWindow* parent, const wxString& message = "Choose a file", const wxString& defaultDir = ""
|
||||
, const wxString& defaultFile = "", const wxString& wildcard = "*.*", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxFileDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultDir = The default directory, or the empty string.
|
||||
|
||||
defaultFile = The default filename, or the empty string.
|
||||
|
||||
wildcard = A wildcard, such as "*.*".
|
||||
|
||||
style = A dialog style. A bitlist of:
|
||||
|
||||
wxOPEN This is an open dialog (Windows only).
|
||||
|
||||
wxSAVE This is a save dialog (Windows only).
|
||||
|
||||
wxHIDE_READONLY Hide read-only files (Windows only).
|
||||
|
||||
wxOVERWRITE_PROMPT Prompt for a conformation if a file will be overridden (Windows only).
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
||||
|
78
wxPython/demo/wxFindReplaceDialog.py
Normal file
78
wxPython/demo/wxFindReplaceDialog.py
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
b = wxButton(self, -1, "Show Find Dialog", (25, 50))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnShowFind)
|
||||
|
||||
b = wxButton(self, -1, "Show Find && Replace Dialog", (25, 90))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnShowFindReplace)
|
||||
|
||||
EVT_COMMAND_FIND(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_REPLACE(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_REPLACE_ALL(self, -1, self.OnFind)
|
||||
EVT_COMMAND_FIND_CLOSE(self, -1, self.OnFindClose)
|
||||
|
||||
|
||||
def OnShowFind(self, evt):
|
||||
data = wxFindReplaceData()
|
||||
dlg = wxFindReplaceDialog(self, data, "Find")
|
||||
dlg.data = data # save a reference to it...
|
||||
dlg.Show(true)
|
||||
|
||||
|
||||
def OnShowFindReplace(self, evt):
|
||||
data = wxFindReplaceData()
|
||||
dlg = wxFindReplaceDialog(self, data, "Find & Replace", wxFR_REPLACEDIALOG)
|
||||
dlg.data = data # save a reference to it...
|
||||
dlg.Show(true)
|
||||
|
||||
|
||||
def OnFind(self, evt):
|
||||
map = {
|
||||
wxEVT_COMMAND_FIND : "FIND",
|
||||
wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT",
|
||||
wxEVT_COMMAND_FIND_REPLACE : "REPALCE",
|
||||
wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL",
|
||||
}
|
||||
et = evt.GetEventType()
|
||||
|
||||
try:
|
||||
evtType = map[et]
|
||||
except KeyError:
|
||||
evtType = "**Unknown Event Type**"
|
||||
|
||||
if et == wxEVT_COMMAND_FIND_REPLACE or et == wxEVT_COMMAND_FIND_REPLACE_ALL:
|
||||
replaceTxt = "Replace text: " + evt.GetReplaceString()
|
||||
else:
|
||||
replaceTxt = ""
|
||||
|
||||
self.log.write("%s -- Find text: %s %s Flags: %d \n" %
|
||||
(evtType, evt.GetFindString(), replaceTxt, evt.GetFlags()))
|
||||
|
||||
|
||||
def OnFindClose(self, evt):
|
||||
self.log.write("wxFindReplaceDialog closing...\n")
|
||||
evt.GetDialog().Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A generic find and replace dialog.
|
||||
"""
|
@@ -32,8 +32,13 @@ class MyHtmlWindow(wxHtmlWindow):
|
||||
self.log.WriteText('OnSetTitle: %s\n' % title)
|
||||
self.base_OnSetTitle(title)
|
||||
|
||||
## def __del__(self):
|
||||
## print 'MyHtmlWindow.__del__'
|
||||
def OnCellMouseHover(self, cell, x, y):
|
||||
self.log.WriteText('OnCellMouseHover: %s, (%d %d)\n' % (cell, x, y))
|
||||
self.base_OnCellMouseHover(cell, x, y)
|
||||
|
||||
def OnCellClicked(self, cell, x, y, evt):
|
||||
self.log.WriteText('OnCellClicked: %s, (%d %d)\n' % (cell, x, y))
|
||||
self.base_OnCellClicked(cell, x, y, evt)
|
||||
|
||||
|
||||
class TestHtmlPanel(wxPanel):
|
||||
|
62
wxPython/demo/wxPopupWindow.py
Normal file
62
wxPython/demo/wxPopupWindow.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPopup(wxPopupWindow):
|
||||
def __init__(self, parent, style):
|
||||
wxPopupWindow.__init__(self, parent, style)
|
||||
|
||||
EVT_LEFT_DOWN(self, self.OnMouseLeftDown)
|
||||
EVT_MOTION(self, self.OnMouseMotion)
|
||||
EVT_LEFT_UP(self, self.OnMouseLeftUp)
|
||||
|
||||
def OnMouseLeftDown(self, evt):
|
||||
self.ldPos = evt.GetPosition()
|
||||
self.CaptureMouse()
|
||||
|
||||
def OnMouseMotion(self, evt):
|
||||
if evt.Dragging():
|
||||
wPos = self.GetPosition()
|
||||
dPos = evt.GetPosition()
|
||||
self.Move((wPos.x + (dPos.x - self.ldPos.x),
|
||||
wPos.y + (dPos.y - self.ldPos.y)))
|
||||
print self.GetPosition()
|
||||
|
||||
def OnMouseLeftUp(self, evt):
|
||||
self.ReleaseMouse()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
b = wxButton(self, -1, "Show popup window", (25, 50))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnShowPopup)
|
||||
|
||||
|
||||
def OnShowPopup(self, evt):
|
||||
win = TestPopup(self, wxSIMPLE_BORDER)
|
||||
#win.SetPosition((200, 200))
|
||||
#win.SetSize((150, 150))
|
||||
win.Position((200, 200), (150, 150))
|
||||
win.SetBackgroundColour("CADET BLUE")
|
||||
win.Show(true)
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -10,6 +10,10 @@ class TestPanel(wxPanel):
|
||||
def OnKillFocus(self, evt):
|
||||
print "OnKillFocus"
|
||||
evt.Skip()
|
||||
def OnWindowDestroy(self, evt):
|
||||
print "OnWindowDestroy"
|
||||
evt.Skip()
|
||||
|
||||
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
@@ -22,6 +26,7 @@ class TestPanel(wxPanel):
|
||||
EVT_CHAR(t1, self.EvtChar)
|
||||
EVT_SET_FOCUS(t1, self.OnSetFocus)
|
||||
EVT_KILL_FOCUS(t1, self.OnKillFocus)
|
||||
EVT_WINDOW_DESTROY(t1, self.OnWindowDestroy)
|
||||
|
||||
l2 = wxStaticText(self, -1, "Passsword")
|
||||
t2 = wxTextCtrl(self, 20, "", size=(125, -1), style=wxTE_PASSWORD)
|
||||
|
Reference in New Issue
Block a user