2 from wxPython
.wx
import *
6 #----------------------------------------------------------------------
8 class TestPanel(wxPanel
):
9 def __init__(self
, parent
, log
):
10 wxPanel
.__init
__(self
, parent
, -1,
11 style
=wxNO_FULL_REPAINT_ON_RESIZE
)
14 b
= wxButton(self
, 10, "Default Button", wxPoint(20, 20))
15 EVT_BUTTON(self
, 10, self
.OnClick
)
17 b
.SetSize(b
.GetBestSize())
19 b
= wxButton(self
, 20, "HELLO AGAIN!", wxPoint(20, 80), wxSize(120, 45))
20 EVT_BUTTON(self
, 20, self
.OnClick
)
21 b
.SetToolTipString("This is a Hello button...")
23 if 0: # a test case for catching wxPyAssertionError
25 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_SUPPRESS)
26 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION)
27 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_DIALOG)
28 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION | wxPYAPP_ASSERT_DIALOG)
31 bmp
= wxBitmap("nosuchfile.bmp", wxBITMAP_TYPE_BMP
)
32 mask
= wxMaskColour(bmp
, wxBLUE
)
33 except wxPyAssertionError
:
34 self
.log
.write("Caught wxPyAssertionError! I will fix the problem.\n")
35 bmp
= images
.getTest2Bitmap()
36 mask
= wxMaskColour(bmp
, wxBLUE
)
38 bmp
= images
.getTest2Bitmap()
39 mask
= wxMaskColour(bmp
, wxBLUE
)
42 wxBitmapButton(self
, 30, bmp
, wxPoint(160, 20),
43 wxSize(bmp
.GetWidth()+10, bmp
.GetHeight()+10))
44 EVT_BUTTON(self
, 30, self
.OnClick
)
47 def OnClick(self
, event
):
48 self
.log
.write("Click! (%d)\n" % event
.GetId())
49 ##wxLogDebug("debug message")
52 ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
54 #----------------------------------------------------------------------
56 def runTest(frame
, nb
, log
):
57 win
= TestPanel(nb
, log
)
60 #----------------------------------------------------------------------
63 overview
= """<html><body>
66 A button is a control that contains a text string or a bitmap and cab be
67 placed on nearly any kind of window.
74 if __name__
== '__main__':
77 run
.main(['', os
.path
.basename(sys
.argv
[0])])