]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Button.py
PrintFramework fixes
[wxWidgets.git] / wxPython / demo / Button.py
CommitLineData
cf694132 1
8fa876ca
RD
2import wx
3import images
96bfd053 4
cf694132
RD
5#----------------------------------------------------------------------
6
8fa876ca 7class TestPanel(wx.Panel):
cf694132 8 def __init__(self, parent, log):
8fa876ca
RD
9 wx.Panel.__init__(self, parent, -1,
10 style=wx.NO_FULL_REPAINT_ON_RESIZE)
cf694132
RD
11 self.log = log
12
8fa876ca 13 b = wx.Button(self, 10, "Default Button", (20, 20))
372bde9b 14 self.Bind(wx.EVT_BUTTON, self.OnClick, b)
9b3d3bc4 15 b.SetDefault()
c38400d0 16 b.SetSize(b.GetBestSize())
cf694132 17
8fa876ca 18 b = wx.Button(self, 20, "HELLO AGAIN!", (20, 80), (120, 45))
372bde9b 19 self.Bind(wx.EVT_BUTTON, self.OnClick, b)
185d7c3e
RD
20 b.SetToolTipString("This is a Hello button...")
21
8fa876ca 22 if 0: # a test case for catching wx.PyAssertionError
1e4a197e 23
8fa876ca
RD
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)
1e4a197e
RD
28
29 try:
8fa876ca
RD
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")
1e4a197e 34 bmp = images.getTest2Bitmap()
8fa876ca 35 mask = wx.MaskColour(bmp, wx.BLUE)
1e4a197e
RD
36 else:
37 bmp = images.getTest2Bitmap()
8fa876ca 38 mask = wx.MaskColour(bmp, wx.BLUE)
eec92d76 39
1e4a197e 40 bmp.SetMask(mask)
b4f1aaad 41 b = wx.BitmapButton(self, 30, bmp, (260, 20),
8fa876ca 42 (bmp.GetWidth()+10, bmp.GetHeight()+10))
95bfd958
RD
43 b.SetToolTipString("This is a bitmap button.")
44 self.Bind(wx.EVT_BUTTON, self.OnClick, b)
45
46
b4f1aaad 47 b = wx.Button(self, 40, "Flat Button?", (20,150), style=wx.NO_BORDER)
95bfd958
RD
48 b.SetToolTipString("This button has a style flag of wx.NO_BORDER")
49 self.Bind(wx.EVT_BUTTON, self.OnClick, b)
cf694132 50
1e4a197e 51
cf694132 52 def OnClick(self, event):
1e4a197e
RD
53 self.log.write("Click! (%d)\n" % event.GetId())
54 ##wxLogDebug("debug message")
55
cf694132 56
1e4a197e 57## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
064f8bf6 58
cf694132
RD
59#----------------------------------------------------------------------
60
61def runTest(frame, nb, log):
62 win = TestPanel(nb, log)
63 return win
64
65#----------------------------------------------------------------------
66
67
1e4a197e 68overview = """<html><body>
8fa876ca 69<h2>Button</h2>
cf694132 70
8fa876ca 71A button is a control that contains a text string or a bitmap and can be
1e4a197e 72placed on nearly any kind of window.
cf694132 73
1e4a197e
RD
74</body></html>
75"""
cf694132
RD
76
77
78
1e4a197e
RD
79if __name__ == '__main__':
80 import sys,os
81 import run
8eca4fef 82 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
cf694132 83