wxpython收费吗_wxPython 使用总结
圖形化編寫:
class MyFrame(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self, parent, id=-1, title="Jira bug統計工具", size=(410, 335))
bkg = wx.Panel(self)
wx.StaticText(bkg, id=-1, label='用戶名', pos=(50, 30), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='密碼', pos=(220, 30), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='項目名稱', pos=(30, 150), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='測試輪次', pos=(30, 190), size=wx.DefaultSize, style=0, name="staticText")
execButton = wx.Button(parent = bkg, id=-1, label='執行', pos=(300, 160))
self.username = wx.TextCtrl(bkg, id=-1, pos=(40, 50), size=(150, -1), name='TC01') # 用戶名輸入框
self.password = wx.TextCtrl(bkg, id=-1, pos=(200, 50), size=(150, -1), style = wx.TE_PASSWORD) # 密碼輸入框
projectList = ['項目1', '項目2', '項目3', '項目4']
self.projectname = wx.ComboBox(bkg, pos=(85, 150), size=(185, -1), choices=projectList) # 項目名稱下拉框
timeList = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
self.times = wx.ComboBox(bkg, id=-1, pos=(85, 190), size=(185, -1), choices=timeList) # 測試輪次下拉框
事件綁定:
1.定義事件函數
def Exec(self,evt):
username = self.username.GetValue()
password = self.password.GetValue()
projectname = self.projectname.GetValue()
times = self.times.GetValue()
with open('txt.txt','w+') as f:
f.write('username={},password={},projectname={},times={}'.format(username, password, projectname, times))
2.綁定觸發事件的條件
self.Bind(wx.EVT_BUTTON, self.Exec, execButton)
完整代碼:
import wx
class MyFrame(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self, parent, id=-1, title="Jira bug統計工具", size=(410, 335))
bkg = wx.Panel(self)
wx.StaticText(bkg, id=-1, label='用戶名', pos=(50, 30), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='密碼', pos=(220, 30), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='項目名稱', pos=(30, 150), size=wx.DefaultSize, style=0, name="staticText")
wx.StaticText(bkg, id=-1, label='測試輪次', pos=(30, 190), size=wx.DefaultSize, style=0, name="staticText")
execButton = wx.Button(parent = bkg, id=-1, label='執行', pos=(300, 160))
self.username = wx.TextCtrl(bkg, id=-1, pos=(40, 50), size=(150, -1), name='TC01') # 用戶名輸入框
self.password = wx.TextCtrl(bkg, id=-1, pos=(200, 50), size=(150, -1), style = wx.TE_PASSWORD) # 密碼輸入框
projectList = ['項目1', '項目2', '項目3', '項目4']
self.projectname = wx.ComboBox(bkg, pos=(85, 150), size=(185, -1), choices=projectList) # 項目名稱下拉框
timeList = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
self.times = wx.ComboBox(bkg, id=-1, pos=(85, 190), size=(185, -1), choices=timeList) # 測試輪次下拉框
self.Bind(wx.EVT_BUTTON, self.Exec, execButton)
def Exec(self,evt):
username = self.username.GetValue()
password = self.password.GetValue()
projectname = self.projectname.GetValue()
times = self.times.GetValue()
with open('txt.txt','w+') as f:
f.write('username={},password={},projectname={},times={}'.format(username, password, projectname, times))
class MyApp(wx.App):
def OnInit(self):
self.frame=MyFrame(parent=None)
self.SetTopWindow(self.frame)
self.frame.Show(True)
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()
總結
以上是生活随笔為你收集整理的wxpython收费吗_wxPython 使用总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux的du使用方法
- 下一篇: 南海发展大数据产业 建设新型智慧城市