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.

First of all, if you are new to Python, and especially if you are new to programming in general, it makes the most sense to learn Python itself first, without any GUI stuff. This can be frustrating if your goal is to write GUI programs, and particularly if you have experience with an environment like Visual Basic in which GUI programming is integrated into the environment. It is worth it, however, to take some time to learn about Python. Python is a very powerful language capable of doing many things both with and without GUIs.

Using wxPython requires a pretty good understanding of Object Oriented (OO) programming in Python, and all of the tutorials and references that I will refer to later assume this knowledge.

To learn Python, go to the Python for Beginners page at the main Python web site:

http://www.python.org/doc/Newbies.html

Follow the links on that page, and you should find something to your liking.

Once you have a fundamental understanding of programming in Python, you can start to learn wxPython for GUI programming.

I would suggest starting with the Tutorial. It is brief, and not complete, but it is a good start. You can find it here:

http://wxpython.org/tutorial.php

Once you have gone through that, you might want to go through the wxpython wiki getting started section:

http://wiki.wxpython.org/index.cgi/Getting_20Started

Between these two, you should have a basic grasp of how wxPython works, and be ready to make you own application. To so this, you will want two things: examples and a reference.

The wxPython demo is your best source of examples. It is distributed with wxPython, and demonstrates virtually all the features of wxPython. When you run it, you can see how different features work, and see the source code that made it happen. Many of us look for something in the demo that is close to what we want to do, copy it, and then alter it to fit our needs.

Another source of examples is the wxPython cookbook:

http://wiki.wxpython.org/index.cgi/wxPython_20Cookbook

The reference manual for wxPython is the same as the reference for the C++ version of wxWindows, and can be found here:

http://www.wxpython.org/onlinedocs.php

It is written in C++ syntax, with notes inserted for when the Python implementation differs from the C++. The fact that the docs are written for C++ is unfortunate, not because they aren't useful to Python programmers, but because is can be very intimidating to new users who don't know C++. In fact, many Python programmers who don't know a bit of C++ find that the docs can be very useful. It only takes a little while to learn to translate form the C++ in the docs to the equivalent Python. One of the best way to learn to do this is to compare code form the examples n the wxPython demo to what is in the reference manual.

[NOTE: it would be great if someone would add a section here with examples of how to translate from C++ to Python.]

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.