目录

  1. How to learn wxPython
    1. Learn Python
    2. Choose a good editor
    3. Install wxPython
    4. Read the wxPython tutorials
    5. Read the wxPython Style Guide
    6. Read the demo files
    7. Use the wxWidgets documentation
    8. Use the wxPython reference (experimental)
    9. Study other people's code
    10. Ask questions!

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的更多相关文章

  1. wxpython绘制折线图

    environment:win10 + eclipse + pydev + python2.7.11 + wxpython3.0.2 code sample: #!/usr/bin/env pytho ...

  2. wxPython 自动提示文本框

    1.原版和例子都在这里 在浏览器的地址栏,或者在百度.google 输入文字的时候,输入框的下面会把有关的项目都提示出来. wxPython 没有提供类似的控件,google 了一下,发现了一个,很好 ...

  3. Atitit learn by need 需要的时候学与预先学习知识图谱路线图

    Atitit learn by need 需要的时候学与预先学习知识图谱路线图 1. 体系化是什么 架构 知识图谱路线图思维导图的重要性11.1. 体系就是架构21.2. 只见树木不见森林21.3. ...

  4. Python 爬取所有51VOA网站的Learn a words文本及mp3音频

    Python 爬取所有51VOA网站的Learn a words文本及mp3音频 #!/usr/bin/env python # -*- coding: utf-8 -*- #Python 爬取所有5 ...

  5. wxPython入门练习代码 二

    WxPython书籍[摘记] 1.任何wxPython应用程序都需要一个应用程序对象.这个应用程序对象必须是类wx.App或其定制的子类的一个实例.2.在OnInit()方法中将至少创建一个框架对象, ...

  6. wxPython入门练习代码 一

    Bare.py: #1.导入必须的wxPython包 import wx #2.子类化wx应用程序类 class App(wx.App): #3.定义应用程序初始化方法 def OnInit(self ...

  7. wxPYTHON图形化软件开发(一)---LOMO工具箱

    最近学了wxPYTHON,这次就做了一个工具箱软件练手,软件主要是包含各种小工具,目前想到的有密码管理器,日记本,记账本,今天还看到一个网页浏览器,也可能加进来.目前实现的是密码管理器 软件GUI部分 ...

  8. [转载]VIM 教程:Learn Vim Progressively

    文章来源:http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/   Learn Vim Progressively   TL ...

  9. 移动端自动化环境搭建-wxpython的安装

    安装wxpython A.安装依赖 wxPython 是 Python 非常有名的一个 GUI 库,因为 RIDE 是基于这个库开发的,所以这个必须安装. B.安装过程 下载地址:http://www ...

随机推荐

  1. Spring 整合 Shiro

    一.引入依赖 <!-- spring start --> <dependency> <groupId>org.springframework</groupId ...

  2. Laxcus大数据管理系统2.0(3)- 第一章 基础概述 1.2 产品特点

    1.2 产品特点 Laxcus大数据管理系统运行在计算机集群上,特别强调软件对分布资源可随机增减的适应性.这种运行过程中数据动态波动和需要瞬时感知的特点,完全不同与传统的集中处理模式.这个特性衍生出一 ...

  3. [C/C++] new/delete和malloc/free基本区别

    /**便于遗忘时复习**/ 区别一:本质 new/delete 在C++中是运算符不是函数,需要编译器支持.malloc/free是库函数,需要头文件支持,在C语言中使用. 区别二:开辟内存大小 用 ...

  4. errno -4058 and npm WARN enoent ENOENT 解决方案

    1.报错如下: npm WARN checkPermissions Missing write access to C:\Users\hejinrong\AppData\Roaming\npm\nod ...

  5. python安装Django

    现在有很多建站系统,很多都是基于php的,比如WordPress. 而Django 是老牌基于Python的CMS框架了,一直听说很强大,甚至曾经很红的Ruby On Rails都参考了它的很多概念, ...

  6. python中locals和globals函数

    参考:http://www.cnblogs.com/wanxsb/archive/2013/05/07/3064783.html Python有两个内置的函数,locals() 和globals(), ...

  7. 简单理解DES加密算法

    数据加密标准(Data Encryption Standard,DES)是当前使用最广泛的加密体制,对于任意的加密方案,总有两个输入:明文和密钥. 明文是64bits,密钥是56bits 加密过程就是 ...

  8. Hash表 算法的详细解析

    http://xingyunbaijunwei.blog.163.com/blog/static/76538067201111494524190/ 什么是HashHash,一般翻译做“散列”,也有直接 ...

  9. 【SSH】——spring的控制反转和依赖注入

    spring是一个轻量级的容器框架,主要是为了使企业的开发变得简单.高效.无论是从大小还是开销来讲,他都可以算是轻量级的,也是非侵入性的. 下图是spring的框架示意图,说到spring,就不得不提 ...

  10. struts2 下载文件

    作者:禅楼望月 当下载的文件名字中不含有汉字,或者下载的文件不需要考虑用户的权限问题时.直接让超链接的href属性为所要下载的文件名即可.否则最好使用struts2的文件下载机制. 以下载图片为例 完 ...