]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxButton.py
focus setting must be possible even when not shown yet
[wxWidgets.git] / wxPython / demo / wxButton.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
96bfd053
RD
4import images
5
cf694132
RD
6#----------------------------------------------------------------------
7
8class TestPanel(wxPanel):
9 def __init__(self, parent, log):
fe953afb
RD
10 wxPanel.__init__(self, parent, -1,
11 style=wxNO_FULL_REPAINT_ON_RESIZE)
cf694132
RD
12 self.log = log
13
5ed3dab2 14 b = wxButton(self, 10, "Hello", wxPoint(20, 20))
cf694132 15 EVT_BUTTON(self, 10, self.OnClick)
5ed3dab2
RD
16 b.SetBackgroundColour(wxBLUE)
17 b.SetForegroundColour(wxWHITE)
9b3d3bc4 18 b.SetDefault()
cf694132 19
5a1eefc7 20 b = wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(120, 45))
cf694132 21 EVT_BUTTON(self, 20, self.OnClick)
185d7c3e
RD
22 b.SetToolTipString("This is a Hello button...")
23
1e4a197e
RD
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)
eec92d76 41
1e4a197e 42 bmp.SetMask(mask)
5a1eefc7 43 wxBitmapButton(self, 30, bmp, wxPoint(160, 20),
cf694132
RD
44 wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
45 EVT_BUTTON(self, 30, self.OnClick)
46
1e4a197e 47
cf694132 48 def OnClick(self, event):
1e4a197e
RD
49 self.log.write("Click! (%d)\n" % event.GetId())
50 ##wxLogDebug("debug message")
51
cf694132 52
1e4a197e 53## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
064f8bf6 54
cf694132
RD
55#----------------------------------------------------------------------
56
57def runTest(frame, nb, log):
58 win = TestPanel(nb, log)
59 return win
60
61#----------------------------------------------------------------------
62
63
1e4a197e
RD
64overview = """<html><body>
65<h2>wxButton</h2>
cf694132 66
1e4a197e
RD
67A button is a control that contains a text string or a bitmap and cab be
68placed on nearly any kind of window.
cf694132 69
1e4a197e
RD
70</body></html>
71"""
cf694132
RD
72
73
74
1e4a197e
RD
75if __name__ == '__main__':
76 import sys,os
77 import run
78 run.main(['', os.path.basename(sys.argv[0])])
cf694132 79