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