wxPython 进行GUI 设计解决PyNoAppError: The wx.App object must be created first!
来源:互联网 发布:阿里云平台介绍 编辑:程序博客网 时间:2024/05/20 05:46
安装wxPython
下载网址:https://sourceforge.net/projects/wxpython/files/wxPython,选择和自己电脑操作系统以及python版本对应的安装即可
例子:
# -*- coding: utf-8 -*-import wx class Application(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, -1, 'My GUI', size=(400, 300)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) panel.SetSizer(sizer) txt = wx.StaticText(panel, -1, 'Hello World!') sizer.Add(txt, 0, wx.TOP|wx.LEFT, 20) self.Centre() self.Show(True) app = wx.App(0) Application(None) app.MainLoop()运行第一次没毛病,
运行第二次出错,PyNoAppError: The wx.App object must be created first!
查资料解决:
这段代码只能在CMD窗口输入python test.py运行(当然还有其它方法),因为IDLE是用Tkinker开发的,它会和wxWidget的mainloop()冲突。
或者你拷贝到wxPython自带的pyCrust中也行,因为它也是用wxWidget开发的,不会有以上的冲突。
0 0
- wxPython 进行GUI 设计解决PyNoAppError: The wx.App object must be created first!
- Ora-26678 Streams capture process must be created first
- 解决Failed to execute request because the App-Domain could not be created问题
- Java异常解决:Constructor call must be the first statement in a constructor
- Android解决:View.setTag(key,object)异常:The key must be an application-specific resource id.
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- wxPython.wx
- TypeError: the JSON object must be str, not 'bytes'
- TypeError: the JSON object must be str, not 'TextIOWrapper'
- The First Pro with wxpython
- 如何使用wxPython设计gui
- First argument must be a string, Buffer, ArrayBuffer, Array, or array -like object.
- 解决which must be escaped when used within the value
- BUG? must be escaped when used within the value 解决
- Django:ExtendsNode: extends 'base/base.html'> must be the first tag in the template.
- python使用汇总
- 腾讯云服务器linux系统下apache php mysql安装
- 协议号大全
- seitch中的default
- 表(List)的实现——算数学习(二)
- wxPython 进行GUI 设计解决PyNoAppError: The wx.App object must be created first!
- C++很简单的一种判断文件是否存在的办法
- XML学习
- git命令(非常实用)
- webstorm安装,激活,汉化
- 【Codeforces 599A】Patrick and Shopping 最短路程
- OSGI实战(5)-实战OSGI-翻译助手项目03
- Spring学习笔记<五> IOC之依赖注入
- 【Hibernate】继承映射