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 ...
随机推荐
- VM实例的生命周期管理
有的操作功能比较类似,也有各自的适用场景,简单介绍下上述几个重要的操作: 常规操作: 常规操作中,Launch.Start.Reboot.Shut Off 和 Terminate 都很好理解. 下面几 ...
- Floatingip
浮动IP相关功能点: 模块 功能 描述 备注 FloatingIP 创建浮动IP 指定带宽大小创建单个/多个浮动IP 指定子网.指定IP创建浮动IP 绑定浮动IP,修改带宽 绑定浮动IP到指定 ...
- 在阿里云上遇见更好的Oracle(三)
鬼扯完“去IOE”,继续回来说说这个系列文章的主角Oracle. 在DB-Engine的数据库排行榜中,Oracle已经占据了多年的第一(最新排名可以点击“阅读原文”).当然因为互联网行业的兴起,My ...
- 时间动态协同过滤(TimeSVD++)
原作者 原论文地址 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.379.1951&rep=rep1&type=pd ...
- 官方文档 恢复备份指南七 Using Flashback Database and Restore Points
本章内容: Understanding Flashback Database, Restore Points and Guaranteed Restore Points Logging for Fla ...
- BZOJ 1923 SDOI2010 外星千足虫 异或方程组+bitset
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1923 懒得贴题目了......这就是解一个异或方程组的裸题...... YY了一下异或方程 ...
- POJ 1015 Jury Compromise (动态规划)
dp[i][j]代表选了i个人,D(J)-P(J)的值为j的状态下,D(J)+P(J)的最大和. #include <cstdio> #include <cstring> #i ...
- 团队项目-第十次scrum 会议
时间:11.6 时长:20分钟 地点:主235教室走廊 工作情况 团队成员 已完成任务 待完成任务 解小锐 完成多种招聘方式的逻辑编写 陈鑫 实现游戏的存档功能 李金奇 添加多种招聘方式等功能 王辰昱 ...
- vim字符编码
今天我在用vim新建中文文件的时候遇到保存好出现乱码的问题,经过一波百度, :set encoding=utf-8 :set fileencodings=ucs-bom,utf-8,cp936 :se ...
- Qscintilla2编译使用
Qscintilla2的下载地址: https://github.com/josephwilk/qscintilla https://riverbankcomputing.com/software/q ...