1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
9 #----------------------------------------------------------------------
11 class TestPanel(wx
.Panel
):
12 def __init__(self
, parent
, log
):
13 wx
.Panel
.__init
__(self
, parent
, -1,
14 style
=wx
.NO_FULL_REPAINT_ON_RESIZE
)
17 b
= wx
.Button(self
, 10, "Default Button", (20, 20))
18 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
20 b
.SetSize(b
.GetBestSize())
22 b
= wx
.Button(self
, 20, "HELLO AGAIN!", (20, 80), (120, 45))
23 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
24 b
.SetToolTipString("This is a Hello button...")
26 if 0: # a test case for catching wx.PyAssertionError
28 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS)
29 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION)
30 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
31 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG)
34 bmp
= wx
.Bitmap("nosuchfile.bmp", wx
.BITMAP_TYPE_BMP
)
35 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
36 except wx
.PyAssertionError
:
37 self
.log
.write("Caught wx.PyAssertionError! I will fix the problem.\n")
38 bmp
= images
.getTest2Bitmap()
39 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
41 bmp
= images
.getTest2Bitmap()
42 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
45 wx
.BitmapButton(self
, 30, bmp
, (160, 20),
46 (bmp
.GetWidth()+10, bmp
.GetHeight()+10))
47 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, id=30)
50 def OnClick(self
, event
):
51 self
.log
.write("Click! (%d)\n" % event
.GetId())
52 ##wxLogDebug("debug message")
55 ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
57 #----------------------------------------------------------------------
59 def runTest(frame
, nb
, log
):
60 win
= TestPanel(nb
, log
)
63 #----------------------------------------------------------------------
66 overview
= """<html><body>
69 A button is a control that contains a text string or a bitmap and can be
70 placed on nearly any kind of window.
77 if __name__
== '__main__':
80 run
.main(['', os
.path
.basename(sys
.argv
[0])])