5 #----------------------------------------------------------------------
7 class TestPanel(wx
.Panel
):
8 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1,
10 style
=wx
.NO_FULL_REPAINT_ON_RESIZE
)
13 b
= wx
.Button(self
, 10, "Default Button", (20, 20))
14 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
16 b
.SetSize(b
.GetBestSize())
18 b
= wx
.Button(self
, 20, "HELLO AGAIN!", (20, 80), (120, 45))
19 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
20 b
.SetToolTipString("This is a Hello button...")
22 if 0: # a test case for catching wx.PyAssertionError
24 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS)
25 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION)
26 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
27 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG)
30 bmp
= wx
.Bitmap("nosuchfile.bmp", wx
.BITMAP_TYPE_BMP
)
31 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
32 except wx
.PyAssertionError
:
33 self
.log
.write("Caught wx.PyAssertionError! I will fix the problem.\n")
34 bmp
= images
.getTest2Bitmap()
35 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
37 bmp
= images
.getTest2Bitmap()
38 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
41 b
= wx
.BitmapButton(self
, 30, bmp
, (260, 20),
42 (bmp
.GetWidth()+10, bmp
.GetHeight()+10))
43 b
.SetToolTipString("This is a bitmap button.")
44 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
47 b
= wx
.Button(self
, 40, "Flat Button?", (20,150), style
=wx
.NO_BORDER
)
48 b
.SetToolTipString("This button has a style flag of wx.NO_BORDER")
49 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
52 def OnClick(self
, event
):
53 self
.log
.write("Click! (%d)\n" % event
.GetId())
54 ##wxLogDebug("debug message")
57 ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
59 #----------------------------------------------------------------------
61 def runTest(frame
, nb
, log
):
62 win
= TestPanel(nb
, log
)
65 #----------------------------------------------------------------------
68 overview
= """<html><body>
71 A button is a control that contains a text string or a bitmap and can be
72 placed on nearly any kind of window.
79 if __name__
== '__main__':
82 run
.main(['', os
.path
.basename(sys
.argv
[0])])