wxpython grid刷新数据_wxpython grid
#!/usr/bin/env PythonimportwxclassRefactorExample(wx.Frame):def __init__(self, parent, id):wx.Frame.__init__(self, parent, id, ‘Refactor Example‘,size=(340, 200))panel= wx.Panel(self, -1)panel.SetBack
#!/usr/bin/env Python
importwxclassRefactorExample(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")
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.createMenuBar()
self.createButtonBar(panel)
self.createTextFields(panel)defmenuData(self):return (("&File",
("&Open", "Open in status bar", self.OnOpen),
("&Quit", "Quit", self.OnCloseWindow)),
("&Edit",
("&Copy", "Copy", self.OnCopy),
("C&ut", "Cut", self.OnCut),
("&Paste", "Paste", self.OnPaste),
("", "", ""),
("&Options...", "DisplayOptions", self.OnOptions)))defcreateMenuBar(self):
menuBar=wx.MenuBar()for eachMenuData inself.menuData():
menuLabel=eachMenuData[0]
menuItems= eachMenuData[1:]
menuBar.Append(self.createMenu(menuItems), menuLabel)
self.SetMenuBar(menuBar)defcreateMenu(self, menuData):
menu=wx.Menu()for eachLabel, eachStatus, eachHandler inmenuData:if noteachLabel:
menu.AppendSeparator()continuemenuItem= menu.Append(-1, eachLabel, eachStatus)
self.Bind(wx.EVT_MENU, eachHandler, menuItem)returnmenudefbuttonData(self):return (("First", self.OnFirst),
("<< PREV", self.OnPrev),
("NEXT >>", self.OnNext),
("Last", self.OnLast))def createButtonBar(self, panel, yPos =0):
xPos=0for eachLabel, eachHandler inself.buttonData():
pos=(xPos, yPos)
button=self.buildOneButton(panel, eachLabel, eachHandler, pos)
xPos+=button.GetSize().widthdef buildOneButton(self, parent, label, handler, pos=(0,0)):
button= wx.Button(parent, -1, label, pos)
self.Bind(wx.EVT_BUTTON, handler, button)returnbuttondeftextFieldData(self):return (("First Name", (10, 50)),
("Last Name", (10, 80)))defcreateTextFields(self, panel):for eachLabel, eachPos inself.textFieldData():
self.createCaptionedText(panel, eachLabel, eachPos)defcreateCaptionedText(self, panel, label, pos):
static=wx.StaticText(panel, wx.NewId(), label, pos)
static.SetBackgroundColour("White")
textPos= (pos[0] + 75, pos[1])
wx.TextCtrl(panel, wx.NewId(),"", size=(100, -1), pos=textPos)#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
defOnCloseWindow(self, event):
self.Destroy()if __name__ == ‘__main__‘:
app=wx.PySimpleApp()
frame= RefactorExample(parent=None, id=-1)
frame.Show()
app.MainLoop()
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)