Developing GUIs with wxPython (Part 1)

Overview of Graphical User Interfaces

GUIs (graphic user interfaces) are very popular for computers nowadays. Very rarely will you find a program that doesn’t have some sort of graphical interface to use it. Most non-graphical programs will be found on Unix-like operating systems; even then, those programs are usually older ones where the programmer didn’t want (or see the need) for a graphical interface.

Unless you are a power-user or feel very comfortable using command-line tools, you will interact with your computer via a graphical interface. A graphical interface entails the program creating what is commonly called a “window”. This window is populated by “widgets”, the basic building blocks of a GUI. Widgets are the pieces of a GUI that make it usable, e.g. the close button, menu items, sliders, scrollbars, etc. Basically, anything the user can see is a widget.

Because most people are used to using windows to manipulate their computer, it’s worthwhile to know how to create a GUI. Though it’s easier and often faster to make a command-line program, very few people will use it. Humans are visual creatures and people like “flashy” things. Hence, putting a nice graphical interface on your program makes it easier for people to use. (Even if it’s faster/easier to use the command line).

There are many GUI development tools available. Some of the most popular are Qt, GTK, wxWidgets, and .Net. All but MFC are cross-platform, meaning you can develop your program in any operating system and know that it will work in any other operating system. However, if you create a program in Microsoft’s Visual Studio, it will only run on Microsoft Windows.

Though this tutorial will focus on wxPython, a GUI library based on wxWidgets, I will give a brief rundown of several other graphical libraries. As a disclaimer, the only GUI libraries I am familiar with are wxPython and Tkinter; some information below may be incorrect or outdated but is correct to the best of my knowledge.

  • Qt– Based upon technology from Trolltech, it is one of the more popular libraries for cross-platform development. It is the main graphical library for the KDE desktop.
    • Qt has a dual-license: if your application will be commercial, you have to pay for a license from Trolltech. If your application will be open-sourced, then you can use the GPL license from Trolltech; however, you will be unable to commercialize your program without “upgrading” the license.
    • Qt includes a graphical layout utility, allowing the user to drag & drop graphical widgets for quick design of the interface. Alternatively, the developer can hand-code the interface layout.
    • Qt is written in C++.
  • GTK– Originally created for development of the GIMP image software (GTK stands for GIMP Tool Kit), GTK evolved into the graphical library that powers the GNOME desktop. Many of the applications written for KDE will run on GNOME and vice versa.
    • GTK is open-sourced under the GPL license. This was intentional by the creators. When Qt was chosen to power the KDE desktop, Trolltech had a proprietary license for it. Because this goes against the Free Software philosophy, GTK was created to allow people to use the GNOME desktop and GTK applications as open-source software.
    • GTK doesn’t necessarily have a built-in drag & drop interface, though the wxGlade utility provides this functionality.
    • GTK is written in C while GTK+ is written in C++.
  • wxWidgets– A general purpose GUI library, wxWidgets was originally developed for use with C/C++ programs. wxPython is a Python-implementation of wxWidgets, meaning Python programs interact with Python wrappers of the underlying C/C++ code.
    • wxWidgets is Free/Open Source Software (FOSS), licensed under the GPL.
    • Programs written with wxWidgets use the native widgets of an operating system, so the programs don’t look out of place.
  • Tkinter– A graphical library created for the Tcl/Tk language. It is the default GUI library for Python development due to it’s inclusion in the core Python language.
    • Tkinter does not use native OS widgets, so Tkinter programs don’t necessarily “blend in” with other applications.
    • The Tkinter toolset is fairly limited but easy to learn, making it easy to make simple GUI programs in Python.
  • MFC/.Net– These two libraries were created by Microsoft for Windows development. MFC is the GUI library used with C++ programs while .Net is used with .Net languages, such as C# and VB.Net.
    • Unlike the previous libraries mentioned, MFC is not cross-platform. Some open-source projects, like Mono, have been started to use the .Net framework on non-Windows computers but some additional effort is required to ensure true cross-platform compatibility.
    • MFC is considered a legacy framework; .Net is the new way of creating Windows programs.
    • The Visual Studio development suites include the GUI libraries required for widget layout.
This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to Developing GUIs with wxPython (Part 1)

  1. Bryan Oakley says:

    Your statement that “Tkinter does not use native OS widgets” is several years out of date. Tk has been using native widgets on the mac and windows for years. The latest version of Tk (and thus, the most up-to-date versions of Tkinter) improve on that with the themed widgets. For more information you might want to check out

  2. I wrote the original tutorial a while ago and posted it here last year. At that time, Tkinter (as used in Python) didn’t provide native widgets.

    I don’t know if Python 3 has remedied this problem; none of the documentation I have read so far mentions it. Stand-alone Tkinter may have improved upon itself but, for the purposes of this tutorial, it is still “stone age”.

    Python included Tkinter as a built-in, easy way to create simple GUIs. I have not used Tkinter outside of the Python environment so I simply haven’t kept up to date on its status.

    Thank you for letting me know. When I get a chance to rewrite this tutorial, I will make mention of it.

  3. Pingback: Is it worthwhile to write a programming tutorial book? | The Largest Forum Archive

  4. Pingback: Free Resources | Wholesale Retail & Marketing

  5. Melissa says:

    Discover the secret seduction techniques
    used by sneaky, manipulative men
    to effortlessly attract women.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s