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