wxPython笔记(Getting started with wxPython 3)

来源:互联网 发布:数据库 id冗余名称 编辑:程序博客网 时间:2024/05/28 17:07

Getting started with wxPython 3:http://wiki.wxpython.org/Getting%20Started


1. wx.Validator:用于输入数据的验证;首先要创建自己的验证器(从wx.Validator派生),然后与需要验证的控件关联(myInputField.SetValidator(myValidator))。


2. wx.Notebook:通过Tab管理多个页面,这里通过AddPage添加了三个页面,nb是ExamplePanel的父窗口。

app = wx.App(False)frame = wx.Frame(None, title="Demo with Notebook")nb = wx.Notebook(frame)nb.AddPage(ExamplePanel(nb), "Absolute Positioning")nb.AddPage(ExamplePanel(nb), "Page Two")nb.AddPage(ExamplePanel(nb), "Page Three")frame.Show()app.MainLoop()

3.获取调试信息:在创建App时,可传入参数控制调试信息的显示方式。如果程序运行错误,调试信息将会在独立的窗口中显示;也可将这些信息重定向输出到文件中。

class MyApp (wx.App):#...#...#...myapp = MyApp() # functions normally. Stdio is redirected to its own windowmyapp = MyApp(0) #does not redirect stdout. Tracebacks will show up at the console.myapp = MyApp(1, 'filespec') #redirects stdout to the file 'filespec'# NOTE: These are named parameters, so you can do this for improved readability:myapp = MyApp(redirect = 1, filename = 'filespec') # will redirect stdout to 'filespec'myapp = MyApp(redirect = 0) #stdio will stay at the console...


0 0
原创粉丝点击