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 ...
随机推荐
- 「暑期训练」「基础DP」FATE(HDU-2159)
题意与分析 学习本题的时候遇到了一定的困难.看了题解才知道这是二重背包.本题的实质是二重完全背包.二维费用的背包问题是指:对于每件物品,具有两种不同的费用,选择这件物品必须同时付出这两种代价:对于每种 ...
- C#异步了解一下
如何让你的代码在“同一时间”干着两件件事呢?比如说,在初始化加载配置的同时,UI界面能够响应用户的各种点击事件.而不置于卡死,特别是出现如下面这种情况的时候,对于用户来说是很崩溃的.
- resetroot_169route_python2(用于ubuntu12.04和14.04,centos系列)
#!/usr/bin/python import os import json import subprocess from cloudinit.sources.DataSourceConfigDri ...
- Truffle基础篇-Truffle做什么的?怎么安装?
Truffle基础篇-Truffle做什么的?怎么安装? truffle资料汇总 http://truffle.tryblockchain.org/truffle3.0-integrate-nodej ...
- 启动 SQL Server 管理 Studio 在 SQL Server 2008R2 中的错误消息:"无法读取此系统上以前注册的服务器的列表" 解决方法
问题: 服务器被人直接停掉,重启后,发现sqlserver2008r2 启动管理器报错: "无法读取此系统上以前注册的服务器的列表" 如图: 点击继续,进入后: 解决方法: 点击上 ...
- HDU 4587 TWO NODES(割点)(2013 ACM-ICPC南京赛区全国邀请赛)
Description Suppose that G is an undirected graph, and the value of stab is defined as follows: Amon ...
- Spring 学习笔记(八)—— 注解使用整合
@Autowired —— 自动装配 需先在配置文件中,配置一个org.springframework.beans.factory.annotation. AutowiredAnnotationBe ...
- SDUST OJ Problem G 动态的字符串排序
Description 把字符串按照ASCII码序的从小到大排列出来. 串的ASCII码序遵循如下递归定义: 1 两串的前n-1个字符相同,第n个字符ASCII码序小的排在前面:2 只有两串的字符完全 ...
- To Chromium之VS调试追踪
启动的code: for(;;){...WaitForWork()}base.dll!base::MessagePumpForUI::DoRunLoop ...
- BZOJ 2005 2005: [Noi2010]能量采集 | 容斥原理
题目: http://www.lydsy.com/JudgeOnline/problem.php?id=2005 题解: http://blog.csdn.net/popoqqq/article/de ...