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...
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...
相关文章推荐
- python开发之thread实现布朗运动的方法
- python3.4安装pydelicious
- python开发之基于thread线程搜索本地文件的方法
- python os os.path模块学习笔记
- wxPython笔记(Getting started with wxPython 2)
- python开发之tkinter实现图形随鼠标移动的方法
- Python知识小点(备注)
- 每天一点python——python数据类型
- Python 一篇学会多线程
- python开发之tkinter实现图形随鼠标移动的方法
- python开发之基于thread线程搜索本地文件的方法
- python开发之thread实现布朗运动的方法
- python开发之thread线程基础实例入门
- Python基于pygame实现图片代替鼠标移动效果
- Python中pygame安装方法图文详解
- Python基于pygame实现的弹力球效果(附源码)
- python基于pygame实现响应游戏中事件的方法(附源码)
- python中pygame针对游戏窗口的显示方法实例分析(附源码)
- Python基于pygame实现的font游戏字体(附源码)
- Python中pygame的mouse鼠标事件用法实例