您的位置:首页 > 编程语言 > Python开发

wxPython笔记(Getting started with wxPython 3)

2015-11-11 10:10 399 查看
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 window
myapp = 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...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: