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, "Hello", wxPoint(20, 20))
15 EVT_BUTTON(self
, 10, self
.OnClick
)
16 b
.SetBackgroundColour(wxBLUE
)
17 b
.SetForegroundColour(wxWHITE
)
20 b
= wxButton(self
, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(120, 45))
21 EVT_BUTTON(self
, 20, self
.OnClick
)
22 b
.SetToolTipString("This is a Hello button...")
24 if 0: # a test case for catching wxPyAssertionError
26 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_SUPPRESS)
27 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION)
28 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_DIALOG)
29 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION | wxPYAPP_ASSERT_DIALOG)
32 bmp
= wxBitmap("nosuchfile.bmp", wxBITMAP_TYPE_BMP
)
33 mask
= wxMaskColour(bmp
, wxBLUE
)
34 except wxPyAssertionError
:
35 self
.log
.write("Caught wxPyAssertionError! I will fix the problem.\n")
36 bmp
= images
.getTest2Bitmap()
37 mask
= wxMaskColour(bmp
, wxBLUE
)
39 bmp
= images
.getTest2Bitmap()
40 mask
= wxMaskColour(bmp
, wxBLUE
)
43 wxBitmapButton(self
, 30, bmp
, wxPoint(160, 20),
44 wxSize(bmp
.GetWidth()+10, bmp
.GetHeight()+10))
45 EVT_BUTTON(self
, 30, self
.OnClick
)
48 def OnClick(self
, event
):
49 self
.log
.write("Click! (%d)\n" % event
.GetId())
50 ##wxLogDebug("debug message")
53 ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
55 #----------------------------------------------------------------------
57 def runTest(frame
, nb
, log
):
58 win
= TestPanel(nb
, log
)
61 #----------------------------------------------------------------------
64 overview
= """<html><body>
67 A button is a control that contains a text string or a bitmap and cab be
68 placed on nearly any kind of window.
75 if __name__
== '__main__':
78 run
.main(['', os
.path
.basename(sys
.argv
[0])])