|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import wx |
| 4 | +import wx.lib.buttons |
| 5 | + |
| 6 | +class ButtonPanel(wx.Panel): |
| 7 | + def __init__(self, *args, **kwargs): |
| 8 | + wx.Panel.__init__(self, *args, **kwargs) |
| 9 | + |
| 10 | + btn = wx.Button(self, label = "Push Me", pos=(40,60), size=(120,-1)) |
| 11 | + btn = wx.Button(self, label = "Push Me Also", pos=(80,30), size=(200, 60)) |
| 12 | + btn = wx.Button(self, label = "No, push me!", pos=(90,110), size=(65, 80)) |
| 13 | + btn = wx.lib.buttons.GenButton(self, label = "better?", pos=(40,150), size=(60, 60)) |
| 14 | + |
| 15 | + btn.Bind(wx.EVT_BUTTON, self.OnButton ) |
| 16 | + |
| 17 | + def OnButton(self, evt): |
| 18 | + print "Button Clicked" |
| 19 | + |
| 20 | + |
| 21 | +class DemoFrame(wx.Frame): |
| 22 | + """ This frame displays a panel with a button] """ |
| 23 | + def __init__(self, title = "Micro App"): |
| 24 | + wx.Frame.__init__(self, None , -1, title) |
| 25 | + |
| 26 | + pnl = ButtonPanel(self) |
| 27 | + |
| 28 | + self.Bind(wx.EVT_CLOSE, self.OnQuit) |
| 29 | + |
| 30 | + |
| 31 | + def OnQuit(self,Event): |
| 32 | + self.Destroy() |
| 33 | + |
| 34 | + |
| 35 | +app = wx.App(False) |
| 36 | +frame = DemoFrame() |
| 37 | +frame.Show() |
| 38 | +app.MainLoop() |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
0 commit comments