WxWindows
Cross-Platform GUI Development
Simon Myers
UKUUG Linux 2003 Conference • August 2003
This view lists all the slides from the talk in a continuous format. There is a PDF version available, suitable for printing on A4 paper.
The slides are also designed to be viewed as a slideshow from this file with Mozilla or a compatible browser. JavaScript is used to make pressing N progress to the next slide. The slides fit on a 1024 × 768 pixel display. To toggle full-screen mode in Mozilla press F11.
Switch to the slideshow view.
1 Intro
-
WxWindows is a cross-platform graphical toolkit library

- It’s a library for creating programs that have graphical user
interfaces and can be run on different platforms
- Free (LGPL but can distribute derived binaries however you want)
2 On Windows
- WxWindows programs run on Windows (95, NT, XP, …)

3 On Unix
- WxWindows programs run on Linux, using GTK+

- Other Unix platforms also supported
4 On Macs
- WxWindows programs run on MacOS 9 and OS X

5 Sticking Out
- The leading-brand multi-platform toolkits impose their own look on
programs using them
- Tk, Java Swing, XUL, GTK+
- A program looks the same on all platforms
- But it doesn’t fit in on any platform
- On Windows it doesn’t look like a Windows app ...
- Obvious aesthetic disruption
- Usability issues
-
Ctrl+A is ‘select all’ or ‘start of line’?
- Most baffling for users who run the app on a single OS
6 Blending in
- WxWindows is different
- Doesn’t have any widgets of its own
- Uses the actual native widgets of platform it’s running on
- Not just its own widgets painted to disguise themselves as
native
- WxWindows provides a consistent programming interface to the
different native platform toolkits
- A WxWindows program will look different on each platform
- But it will always look like other native apps
- Not obviously identifiable as a WxWindows program
7 Programing Languages
- WxWindows is a C++ library
- The website claims that it isn’t a problem for C developers to
switch to C++
- WxPython provides Python bindings
- Seems to be a popular toolkit in the Python community
- Python issues integretated in the WxWindows documentation
- WxPerl is the equivalent for … um, Perl
- Not so well established
- Docs are a little flaky
8 Using a Scripting Language
- Scripting languages such as Perl and Python lend themselves well to
developing GUI programs
- Not having compilation greatly aids making small tweaks
- And GUIs always need many small tweaks
- Generally speed isn’t an issue
- The slowest part of a GUI program is usually the user
- Using WxPerl or WxPython means that your program can be deployed
unchanged on multiple platforms
- No need to compile separate editions for each OS
- Even runs on platforms you don’t have
9 Sane Windows Development
- Developers allergic to Windows can share WxPerl or WxPython program
directories on the network
- Run on Windows directly from those directories
- Minimal interaction with a Windows computer

- For WxPerl using the
.plw extension and
associating it with wperl.exe quells Dos-prompt pop-up
irritation
10 Bargepole Avoidance
- Using VNC can prevent even having to touch a Windows computer

11 Comparison
- Can run the same file locally to compare appearances

12 Multiple Platforms
- Presumably this would also work the other way round
- Develop on Windows but also deploy on Linux
- Possible migration strategy
- If planning to switch desktops from Windows to Linux, helps for
application software to be familiar
- Custom tools can be implemented with WxWindows and deployed on
Windows now, knowing that they will work on Linux after switching
- Insurance policy
- Even if only using Windows at the moment, can avoid being tied to
it
13 Capabilities
- WxWindows includes the form controls you’d expect
- Textboxes, labels, checkboxes, radio buttons…
- Not lowest-common denominator of supported platforms
- Controls such as checklistboxes faked if necessary

- Also some non-graphical cross-platform classes
- Printing, forking, config files, clipboard
14 Programming
- The WxWindows docs are comprehensive, and available in many
formats
- But it isn’t something that can be picked up in an afternoon
- Complex library with lots of specific bits to get the hang of
- Some idiosyncrasies
- Learning process likely to involve frustration
- Putting controls on windows is a skill requiring practice
- And squared paper
- Widgets are different sizes on different platforms
- Designs specified with relative sizes and positions
15 Positioning with Sizers
- The concept of sizers will be familiar to anybody with experience of
nesting HTML tables
-
The practice of sizers will be familiar to anybody who’s tried to
find
out train times on the National Rail website

- Seem manageable once you’ve got used to them
16 Object Objections
- The WxWindows API is quite verbose
- Object-oriented
- Lots of method calls needed to do anything
- Separate object trees for controls and sizers
- Quite common tasks often result in more code repetition than is
strictly healthy
- Possible to roll your own sub-classes and helper functions to hide
the mess under the carpet
- Specifying related controls in nested data structures can work
well
- Other GUI toolkits appear to suffer from this too
17 XML Window Specifications
- Somebody had the idea that adding in an XML format for specifying
window layouts might help with designs
- Well, I suppose it was worth a try
- WRC files are parsed by programs at run-time
- Enforced separation can be awkward
- Using loops or sub-classes to set up similar controls
- Initializing controls based on external data
- Specifying event handlers to spring into action when
controls are changed
- Might be useful for apps with fixed interfaces which gather all data
before processing any of it
18 WxDesigner: a GUI GUI

19 WxDesigner
- Reasonable interface, once used to the icons
- Still need to think in terms of nested grids
- Can’t just drop things anywhere on a window
- Can’t wrap a further level of grid outside controls
- Still need the squared paper
- Tedious repetition for editing similar controls
- Generates C++, Python, Perl, and XML
- Commercial, with free trial version
- Other WxWindows form designers exist
20 Using WxDesigner
- WxDesigner is good for quickly realizing paper designs
- Try out variations in layout
- Use it to discover the various WxWindows options
- Teach yourself WxWindows from WxDesigner output
- Generate the code for ‘difficult’ controls
- Generate first drafts in WxDesigner then hack by hand
- Helper functions and loops for the repetitive bits
- Now I’ve learnt WxWindows it seems more efficient to code with it in a
text editor
- GUIs are vastly overrated
21 Cross-Platform Issues
- WxWindows programs look ‘right’ on different platforms
- Some aspects of usability dealt with
- Mozilla development has highlighted many platform differences,
such as dragging scroll-bar sliders
- But also ‘cultural’ differences between platforms:
- ‘Exit’ or ‘Quit’ on the ‘File’ menu?
- Expectation of built-in or external text editor
- User home directories
- Common file formats
- Can test for the OS adjust behaviour accordingly
- But then need different docs for each edition
22 Community
- WxWindows and the WxPython and WxPerl bindings are all actively being
developed
- Links and stuff on http://www.wxwindows.org/
- WxWindows has been around for 10 years
- Created at Edinburgh Uni AI dept
- Sundry mailing lists exist
23 Installation
- WxWindows installation is mostly unsurprising
- Linux:
- Source and RPMs are available on the website
- No Debian package currently
- WxPerl on CPAN, as the
Wx module
- Windows:
- Installer that works
- PPMs for ActiveState Perl
24 Summary
- I quite like WxWindows
- Well, the bits I don’t like have been encapsulated and are kept in
quarantine
- Used with a scripting language it seems like a reasonably neat way of
producing decent-looking GUI programs
- And they fit in well with their surroundings
- The cross-platform capability is nice to have
- Write programs that will run on other platforms even if there
doesn’t seem to be an immediate need
- One less thing tying you to a particular OS
© Copyright GBdirect Ltd 2003
This material may not be distributed without explicit permission.