Differences between revisions 1 and 48 (spanning 47 versions)
Revision 1 as of 2001-11-01 18:42:18
Size: 3175
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 48 as of 2008-07-25 21:18:59
Size: 624
Editor: cpc3-warw6-0-0-cust905
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
How to learn wxPython. = Learning wxPython by Example. =
Line 3: Line 3:
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.]


The following code shows an example of a wxPython application with a frame containing a menu bar, status bar and panel. The panel contains a label and a button that is bound to an OnExit function. The menu bar has a Help->About action that is bound to a dialog box. The dialog box shows how to display an HTML message and bring up a link in the user's default browser. You might find this example useful as a starting point that you can adapt. In a larger program it would be best to put the about box code into a separate file so that the main program file does not become too large.

Learning wxPython by Example.

The following code shows an example of a wxPython application with a frame containing a menu bar, status bar and panel. The panel contains a label and a button that is bound to an OnExit function. The menu bar has a Help->About action that is bound to a dialog box. The dialog box shows how to display an HTML message and bring up a link in the user's default browser. You might find this example useful as a starting point that you can adapt. In a larger program it would be best to put the about box code into a separate file so that the main program file does not become too large.

wxPython by Example (last edited 2012-06-28 08:10:48 by SWM-HIGH-SPEED2-22)

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