]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import wx | |
3 | import images | |
4 | ||
5 | #---------------------------------------------------------------------- | |
6 | ||
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) | |
11 | self.log = log | |
12 | ||
13 | b = wx.Button(self, 10, "Default Button", (20, 20)) | |
14 | self.Bind(wx.EVT_BUTTON, self.OnClick, b) | |
15 | b.SetDefault() | |
16 | b.SetSize(b.GetBestSize()) | |
17 | ||
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...") | |
21 | ||
22 | if 0: # a test case for catching wx.PyAssertionError | |
23 | ||
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) | |
28 | ||
29 | try: | |
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) | |
36 | else: | |
37 | bmp = images.getTest2Bitmap() | |
38 | mask = wx.MaskColour(bmp, wx.BLUE) | |
39 | ||
40 | bmp.SetMask(mask) | |
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) | |
45 | ||
46 | ||
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) | |
50 | ||
51 | ||
52 | def OnClick(self, event): | |
53 | self.log.write("Click! (%d)\n" % event.GetId()) | |
54 | ##wxLogDebug("debug message") | |
55 | ||
56 | ||
57 | ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message | |
58 | ||
59 | #---------------------------------------------------------------------- | |
60 | ||
61 | def runTest(frame, nb, log): | |
62 | win = TestPanel(nb, log) | |
63 | return win | |
64 | ||
65 | #---------------------------------------------------------------------- | |
66 | ||
67 | ||
68 | overview = """<html><body> | |
69 | <h2>Button</h2> | |
70 | ||
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. | |
73 | ||
74 | </body></html> | |
75 | """ | |
76 | ||
77 | ||
78 | ||
79 | if __name__ == '__main__': | |
80 | import sys,os | |
81 | import run | |
82 | run.main(['', os.path.basename(sys.argv[0])]) | |
83 |