]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxButton.py
eaaefd2e6d0afbb12b153e9024153ee463beb21a
[wxWidgets.git] / wxPython / demo / wxButton.py
1
2 from wxPython.wx import *
3
4 import images
5
6 #----------------------------------------------------------------------
7
8 class TestPanel(wxPanel):
9 def __init__(self, parent, log):
10 wxPanel.__init__(self, parent, -1,
11 style=wxNO_FULL_REPAINT_ON_RESIZE)
12 self.log = log
13
14 b = wxButton(self, 10, "Default Button", wxPoint(20, 20))
15 EVT_BUTTON(self, 10, self.OnClick)
16 b.SetDefault()
17 b.SetSize(b.GetBestSize())
18
19 b = wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 80), wxSize(120, 45))
20 EVT_BUTTON(self, 20, self.OnClick)
21 b.SetToolTipString("This is a Hello button...")
22
23 if 0: # a test case for catching wxPyAssertionError
24
25 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_SUPPRESS)
26 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION)
27 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_DIALOG)
28 #wxGetApp().SetAssertMode(wxPYAPP_ASSERT_EXCEPTION | wxPYAPP_ASSERT_DIALOG)
29
30 try:
31 bmp = wxBitmap("nosuchfile.bmp", wxBITMAP_TYPE_BMP)
32 mask = wxMaskColour(bmp, wxBLUE)
33 except wxPyAssertionError:
34 self.log.write("Caught wxPyAssertionError! I will fix the problem.\n")
35 bmp = images.getTest2Bitmap()
36 mask = wxMaskColour(bmp, wxBLUE)
37 else:
38 bmp = images.getTest2Bitmap()
39 mask = wxMaskColour(bmp, wxBLUE)
40
41 bmp.SetMask(mask)
42 wxBitmapButton(self, 30, bmp, wxPoint(160, 20),
43 wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
44 EVT_BUTTON(self, 30, self.OnClick)
45
46
47 def OnClick(self, event):
48 self.log.write("Click! (%d)\n" % event.GetId())
49 ##wxLogDebug("debug message")
50
51
52 ## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
53
54 #----------------------------------------------------------------------
55
56 def runTest(frame, nb, log):
57 win = TestPanel(nb, log)
58 return win
59
60 #----------------------------------------------------------------------
61
62
63 overview = """<html><body>
64 <h2>wxButton</h2>
65
66 A button is a control that contains a text string or a bitmap and cab be
67 placed on nearly any kind of window.
68
69 </body></html>
70 """
71
72
73
74 if __name__ == '__main__':
75 import sys,os
76 import run
77 run.main(['', os.path.basename(sys.argv[0])])
78