]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-07/generic_button.py
Added the sample code from wxPython In Action to the samples dir
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-07 / generic_button.py
1 import wx
2 import wx.lib.buttons as buttons
3
4 class GenericButtonFrame(wx.Frame):
5 def __init__(self):
6 wx.Frame.__init__(self, None, -1, 'Generic Button Example',
7 size=(500, 350))
8 panel = wx.Panel(self, -1)
9
10 sizer = wx.FlexGridSizer(1, 3, 20, 20)
11 b = wx.Button(panel, -1, "A wx.Button")
12 b.SetDefault()
13 sizer.Add(b)
14
15 b = wx.Button(panel, -1, "non-default wx.Button")
16 sizer.Add(b)
17 sizer.Add((10,10))
18
19 b = buttons.GenButton(panel, -1, 'Generic Button')
20 sizer.Add(b)
21
22 b = buttons.GenButton(panel, -1, 'disabled Generic')
23 b.Enable(False)
24 sizer.Add(b)
25
26 b = buttons.GenButton(panel, -1, 'bigger')
27 b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
28 b.SetBezelWidth(5)
29 b.SetBackgroundColour("Navy")
30 b.SetForegroundColour("white")
31 b.SetToolTipString("This is a BIG button...")
32 sizer.Add(b)
33
34 bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
35 b = buttons.GenBitmapButton(panel, -1, bmp)
36 sizer.Add(b)
37
38 b = buttons.GenBitmapToggleButton(panel, -1, bmp)
39 sizer.Add(b)
40
41 b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmapped Text",
42 size=(175, 75))
43 b.SetUseFocusIndicator(False)
44 sizer.Add(b)
45
46 b = buttons.GenToggleButton(panel, -1, "Toggle Button")
47 sizer.Add(b)
48
49 panel.SetSizer(sizer)
50
51 if __name__ == '__main__':
52 app = wx.PySimpleApp()
53 frame = GenericButtonFrame()
54 frame.Show()
55 app.MainLoop()
56