1 =================================
 
   2  Example Programs Using wxPython
 
   3 =================================
 
   5 --------------------------------------------------
 
   6  A survival guide for the post-wx-prefixed world.
 
   7 --------------------------------------------------
 
   9 :Author: Patrick K. O'Brien
 
  10 :Contact: pobrien@orbtech.com
 
  11 :Organization: Orbtech_
 
  15 .. _Orbtech: http://www.orbtech.com/
 
  23 This document illustrates example programs using wxPython.  All the
 
  24 examples make use of the new wx package syntax introduced in wxPython
 
  25 2.4.1, which is a bit different than older examples you might come
 
  29 Background (with tongue firmly in cheek)
 
  30 ========================================
 
  32 If something hits you on the head, don't run around screaming that the
 
  33 sky is falling.  Instead, take a close look and see if it wasn't a
 
  34 "wx" prefix that hit you.  Apparently, they're dropping off wxPython
 
  35 class names like flies dropping dead in the scorching heat of a
 
  38 Yes, the world is changing, and even our little wxPython world must
 
  39 change with it.  Then again, I'm not fond of pesky summertime flies,
 
  40 and I'm not too upset that the "wx" prefixes are going to bite the
 
  41 dust.  I think it's for the best.  But, being the kind, considerate
 
  42 person that I am, I decided to write this guide to make the wx
 
  43 namespace transition easier for everyone, even Chicken Little.
 
  47    If you have no idea what I mean by the "wx namespace transition,"
 
  48    consider yourself lucky.  You can simply use these examples to
 
  49    learn wxPython in its current state (beginning with wxPython
 
  50    version 2.4.1).  All you need to know is that previous wxPython
 
  51    code used a slightly different syntax that some folks (including
 
  52    me) considered ugly.  So we changed it.  And that's when the sky
 
  55    If you want more of the technical details, read the `wx package
 
  58    .. _wx package documentation: wxPackage.html
 
  61 Rather than simply **tell** you that everything will be okay, I
 
  62 decided to **show** you that everything will be okay.  To do that,
 
  63 I've created a bunch of example programs using the new wx package.  I
 
  70 It doesn't get much simpler than this.  Every wxPython program needs
 
  71 an application and a frame.  To encourage good coding habits, I've
 
  72 split them into separate modules.  They don't do much, but they're a
 
  75 I include a simple App class in the frame module because the PyWrap
 
  76 "wrapper" utility (``pywrap``) only works with modules that contain an
 
  77 application class.  So including a simple one in each of your frame
 
  78 modules allows you to use the PyWrap runtime wrapper and debug your
 
  79 frames independent of your full application.
 
  81 Here is the module (``frame.py``) that defines the frame class:
 
  83 .. include:: ../samples/wx_examples/basic/frame.py
 
  86 And here is the module (``app.py``) that defines the application class
 
  87 and imports the frame from ``frame.py``:
 
  89 .. include:: ../samples/wx_examples/basic/app.py
 
  93 Hello wxPython Example
 
  94 ======================
 
  96 This program displays an image file (``wxPython.jpg``) inside a frame
 
  97 sized to match the graphic.
 
  99 .. figure:: screenshots/hello-win98.png
 
 102    Running ``hello.py`` on Windows.
 
 104 .. figure:: screenshots/hello-linux.png
 
 107    Running ``hello.py`` on Linux.
 
 109 .. figure:: screenshots/hello-mac.png
 
 112    Running ``hello.py`` on Mac OS X.
 
 114 Here is the source code for ``hello.py``:
 
 116 .. include:: ../samples/wx_examples/hello/hello.py