How to learn wxPython
目录
We have had a lot of questions on the newsgroup asking how to go about learning wxPython. This page gives some pointers on how to do just that.
Learn Python
If you are new to Python, and especially if you are new to programming in general, it makes the most sense to learn Python first, without any GUI stuff. The wait can be frustrating, but it is worth it. Python is a very powerful language capable of doing many things both with and without GUIs.
At a minimum, you should understand topics such as functions, modules, and classes. Without those, learning wxPython will be a frustrating experience. The Python website has an excellent guide for beginners that takes you step-by-step through the process of learning the language. http://www.python.org/about/gettingstarted/
Choose a good editor
Features such as auto-completion, code highlighting, and an interactive window make for faster programming with less errors.
See http://wiki.python.org/moin/PythonEditors for a list of editors.
Install wxPython
If you don't already have wxPython installed, see the How to install wxPython page.
Read the wxPython tutorials
Wiki tutorials: A great place to start is the Getting Started page. Then you should look at the Obstacle Course and the Fully Functional Demo.
External tutorial: Another great resource is the Zetcode wxPython tutorial. It covers using a wide range of subjects, including: getting started, menus/toolbars, sizers, events, the drawing API, widgets, creating custom widgets and demonstrates several 'skeleton' applications.
Video tutorials: ShowMeDo.com hosts a set of wxPython tutorial videos - excellent for beginners. There is also a series of wxPython videos on YouTube.
Read the wxPython Style Guide
It will serve you well to use a nice, modern style for your wxPython code. Due to API changes over the years, and just plain experience, wxPython code style has changed quite a bit over the years, and gotten much more Pythonic.
Unfortunately, a lot of the examples you'll find have not been updated to reflect this style. As you will benefit from using good, modern, style, make sure to study wxPython Style Guide right when you get started, to establish good habits.
Read the demo files
wxPython comes with a comprehensive set of demos and examples. Go to the download page and scroll down to the wxPython-demo-x.x.x files. The demo demonstrates nearly all the features of wxPython. You can see how different features work and study the source code.
NOTE: If the demos don't work, make sure you have the latest wxPython version installed. Sometimes demos use features not found in older versions. To check your wxPython version, run:
1 import wx
2 print wx.version()
A popular way to work on wxPython is to find a demo that is close to what you want, copy it, and then alter it to fit your needs. Another source of examples is the wxPython Cookbook.
Use the wxWidgets documentation
A very important resource is the wxWidgets documentation.
It is written mainly in C++, but there are notes for wxPython and most of the time you can mentally convert from the C++ syntax to the wxPython syntax. You don't need to know C++ to benefit from this. A lot of wxPython programmers don't know any C++ at all, and they still find the wxWidgets documentation very useful.
If you need help reading the wxWidgets docs, the C++ Guide for Pythoneers might be of help. Or you can just ask for help on the mailing list.
Use the wxPython reference (experimental)
You can try the automatically generated API reference. This is an experimental feature. It is not as thorough or mature as the wxWidgets documentation, but it is written in wxPython syntax instead of C++ syntax.
Study other people's code
Charles Simonyi, the legendary Microsoft programmer, grew up in Hungary and had few books available to him from which to learn computer science. He was able to get the source code for a compiler and studied the printouts as musicians would study musical scores.
There are quite a few gems in the sample code that is distributed with wxPython but are not in the Demo program, e.g., FrogEdit and its underlying wx.lib.editor module. I had assumed that an editor would be a wx.TextCtrl on steroids. I was surprised to see that the text was drawn to the screen using a DC (device control) and learned some good techniques. I am also "reading" Transana and Task Coach, two sophisticated applications written in Python and wxPython, to learn how large applications are structured. There is a huge difference between the small examples on this wiki, and actual real-world code, so the process of analyzing large applications is integral to learning wxPython.
Ask questions!
The wxPython-users mailing list is famous for its helpful and friendly members. You can subscribe to it here: http://wxpython.org/maillist.php.
How to learn wxPython的更多相关文章
- wxpython绘制折线图
environment:win10 + eclipse + pydev + python2.7.11 + wxpython3.0.2 code sample: #!/usr/bin/env pytho ...
- wxPython 自动提示文本框
1.原版和例子都在这里 在浏览器的地址栏,或者在百度.google 输入文字的时候,输入框的下面会把有关的项目都提示出来. wxPython 没有提供类似的控件,google 了一下,发现了一个,很好 ...
- Atitit learn by need 需要的时候学与预先学习知识图谱路线图
Atitit learn by need 需要的时候学与预先学习知识图谱路线图 1. 体系化是什么 架构 知识图谱路线图思维导图的重要性11.1. 体系就是架构21.2. 只见树木不见森林21.3. ...
- Python 爬取所有51VOA网站的Learn a words文本及mp3音频
Python 爬取所有51VOA网站的Learn a words文本及mp3音频 #!/usr/bin/env python # -*- coding: utf-8 -*- #Python 爬取所有5 ...
- wxPython入门练习代码 二
WxPython书籍[摘记] 1.任何wxPython应用程序都需要一个应用程序对象.这个应用程序对象必须是类wx.App或其定制的子类的一个实例.2.在OnInit()方法中将至少创建一个框架对象, ...
- wxPython入门练习代码 一
Bare.py: #1.导入必须的wxPython包 import wx #2.子类化wx应用程序类 class App(wx.App): #3.定义应用程序初始化方法 def OnInit(self ...
- wxPYTHON图形化软件开发(一)---LOMO工具箱
最近学了wxPYTHON,这次就做了一个工具箱软件练手,软件主要是包含各种小工具,目前想到的有密码管理器,日记本,记账本,今天还看到一个网页浏览器,也可能加进来.目前实现的是密码管理器 软件GUI部分 ...
- [转载]VIM 教程:Learn Vim Progressively
文章来源:http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ Learn Vim Progressively TL ...
- 移动端自动化环境搭建-wxpython的安装
安装wxpython A.安装依赖 wxPython 是 Python 非常有名的一个 GUI 库,因为 RIDE 是基于这个库开发的,所以这个必须安装. B.安装过程 下载地址:http://www ...
随机推荐
- 步骤2:JMeter 分布式测试(性能测试大并发、远程启动解决方案)
转载(记录) http://www.cnblogs.com/fengpingfan/p/5583954.html http://www.cnblogs.com/puresoul/p/4844539.h ...
- 虚拟现实-VR-UE4-编辑自定义Character-上下左右移动-旋转
在上一片文章中,我创建了一个自定义的Character,但是只是有一行log显示,我使用了自己的Character,不能有任何操作,这里,我将记录我修改我的Character的过程 万事第一步,打开工 ...
- ZooKeeper的伪分布式集群搭建
ZooKeeper集群的一些基本概念 zookeeper集群搭建: zk集群,主从节点,心跳机制(选举模式) 配置数据文件 myid 1/2/3 对应 server.1/2/3 通过 zkCli.sh ...
- HTTP 知新
REST 先从 REST 的角度来看看 HTTP 协议规范, URL:需要操作的对象,也就是资源 HTTP method:我要对该对象做什么(POST 增.DELETE 删.GET 查.PUT 和 P ...
- 用vs调试项目页面无样式
ASP.NET Development Server 上的文件授权 在文件系统网站中,静态文件(例如图像和样式表)遵守 ASP.NET 授权.例如,如果禁用了对静态文件的匿名访问,匿名用户则不能使用文 ...
- STL Allocator
从上面这个程序可以看出,我们这里手动使用了分配器,分配器有很多种类,有std::,还有非std::,也就是上面的__gnu_cxx下面的,我们在使用容器的时候不关心我们使用什么分配器,也不关心我们如何 ...
- 【bzoj3813】奇数国 线段树
题目描述 给出一个长度为n的序列,每个数都可以由前60个质数的乘积表示,初始每个数都是3.支持两种操作:(1)修改一个数 (2)查询一段区间内所有数的乘积的欧拉函数值模19961993. 输入 第一行 ...
- 纯真IP数据库(qqwry.dat)转换成最新的IP数据库格式(ipwry.dat)
纯真IP数据库(qqwry.dat)转换成最新的IP数据库格式(ipwry.dat) 转载自:http://blog.cafeboy.org/2011/02/25/qqwry-to-ipwry/ ht ...
- BZOJ4550 小奇的博弈 【Nimk游戏 + dp + 组合数】
题目 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色.最左边是白色棋子,最右边 是黑色棋子,相邻的棋子颜色不同. 小奇可以移动白色棋子,提比可以移动黑色的棋子,它们每次 ...
- 活泼的CSS 3动态气泡按钮制作
这一次,我们正在创造一个有用的设置与对CSS3的多重背景和动画的力量动画按钮.通过此按钮包,您可以很容易地变成一个动画按钮,在您的网页上的任何链接只是指定一个类名.没有必要JavaScript.四色主 ...