1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/env python
import wx
class RefactorExample(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Refactor Example',
size=(340, 200))
panel = wx.Panel(self, -1)
panel.SetBackgroundColour("White")
prevButton = wx.Button(panel, -1, "<< PREV", pos=(80, 0))
self.Bind(wx.EVT_BUTTON, self.OnPrev, prevButton)
nextButton = wx.Button(panel, -1, "NEXT >>", pos=(160, 0))
self.Bind(wx.EVT_BUTTON, self.OnNext, nextButton)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
menuBar = wx.MenuBar()
menu1 = wx.Menu()
openMenuItem = menu1.Append(-1, "&Open", "Copy in status bar")
self.Bind(wx.EVT_MENU, self.OnOpen, openMenuItem)
quitMenuItem = menu1.Append(-1, "&Quit", "Quit")
self.Bind(wx.EVT_MENU, self.OnCloseWindow, quitMenuItem)
menuBar.Append(menu1, "&File")
menu2 = wx.Menu()
copyItem = menu2.Append(-1, "&Copy", "Copy")
self.Bind(wx.EVT_MENU, self.OnCopy, copyItem)
cutItem = menu2.Append(-1, "C&ut", "Cut")
self.Bind(wx.EVT_MENU, self.OnCut, cutItem)
pasteItem = menu2.Append(-1, "Paste", "Paste")
self.Bind(wx.EVT_MENU, self.OnPaste, pasteItem)
menuBar.Append(menu2, "&Edit")
self.SetMenuBar(menuBar)
static = wx.StaticText(panel, wx.NewId(), "First Name",
pos=(10, 50))
static.SetBackgroundColour("White")
text = wx.TextCtrl(panel, wx.NewId(), "", size=(100, -1),
pos=(80, 50))
static2 = wx.StaticText(panel, wx.NewId(), "Last Name",
pos=(10, 80))
static2.SetBackgroundColour("White")
text2 = wx.TextCtrl(panel, wx.NewId(), "", size=(100, -1),
pos=(80, 80))
firstButton = wx.Button(panel, -1, "FIRST")
self.Bind(wx.EVT_BUTTON, self.OnFirst, firstButton)
menu2.AppendSeparator()
optItem = menu2.Append(-1, "&Options...", "Display Options")
self.Bind(wx.EVT_MENU, self.OnOptions, optItem)
lastButton = wx.Button(panel, -1, "LAST", pos=(240, 0))
self.Bind(wx.EVT_BUTTON, self.OnLast, lastButton)
# Just grouping the empty event handlers together
def OnPrev(self, event): pass
def OnNext(self, event): pass
def OnLast(self, event): pass
def OnFirst(self, event): pass
def OnOpen(self, event): pass
def OnCopy(self, event): pass
def OnCut(self, event): pass
def OnPaste(self, event): pass
def OnOptions(self, event): pass
def OnCloseWindow(self, event):
self.Destroy()
if __name__ == '__main__':
app = wx.App()
frame = RefactorExample(parent=None, id=-1)
frame.Show()
app.MainLoop()
|