]>
Commit | Line | Data |
---|---|---|
1 | # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) | |
2 | # | |
3 | # o Updated for wx namespace | |
4 | # | |
5 | ||
6 | import wx | |
7 | import images | |
8 | ||
9 | #---------------------------------------------------------------------- | |
10 | ||
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) | |
15 | self.log = log | |
16 | ||
17 | b = wx.Button(self, 10, "Default Button", (20, 20)) | |
18 | self.Bind(wx.EVT_BUTTON, self.OnClick, b) | |
19 | b.SetDefault() | |
20 | b.SetSize(b.GetBestSize()) | |
21 | ||
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...") | |
25 | ||
26 | if 0: # a test case for catching wx.PyAssertionError | |
27 | ||
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) | |
32 | ||
33 | try: | |
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) | |
40 | else: | |
41 | bmp = images.getTest2Bitmap() | |
42 | mask = wx.MaskColour(bmp, wx.BLUE) | |
43 | ||
44 | bmp.SetMask(mask) | |
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) | |
48 | ||
49 | ||
50 | def OnClick(self, event): | |
51 | self.log.write("Click! (%d)\n" % event.GetId()) | |
52 | ##wxLogDebug("debug message") | |
53 | ||
54 | ||
55 | ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message | |
56 | ||
57 | #---------------------------------------------------------------------- | |
58 | ||
59 | def runTest(frame, nb, log): | |
60 | win = TestPanel(nb, log) | |
61 | return win | |
62 | ||
63 | #---------------------------------------------------------------------- | |
64 | ||
65 | ||
66 | overview = """<html><body> | |
67 | <h2>Button</h2> | |
68 | ||
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. | |
71 | ||
72 | </body></html> | |
73 | """ | |
74 | ||
75 | ||
76 | ||
77 | if __name__ == '__main__': | |
78 | import sys,os | |
79 | import run | |
80 | run.main(['', os.path.basename(sys.argv[0])]) | |
81 |