GUI programming in python


  • Plenty of so-called “GUI toolkits” are available for Python, but none of them is recognized as the standard GUI toolkit.
  • This has its advantages (greater freedom of choice) and drawbacks (others can’t use your programs unless they have the same GUI toolkit installed).
  • Fortunately, there is no conflict between the various GUI toolkits available for Python, so you can install as many different GUI toolkits as you want.
  • Before writing a GUI program in Python, you need to decide which GUI platform you want to use. Simply put, a platform is one specific set of graphical components, accessible through a given Python module, called a GUI toolkit.
  • As noted earlier, many such toolkits are available for Python.

Building a Sample GUI Application

To demonstrate using wxPython, I will show you how to build a simple GUI application. Your task is to write a basic program that enables you to edit text files. We aren’t going to write a fullfledged text editor, but instead stick to the essentials. After all, the goal is to demonstrate the basic mechanisms of GUI programming in Python.

The requirements for this minimal text editor are as follows:

  • It must allow you to open text files, given their file names.
  • It must allow you to edit the text files.
  • It must allow you to save the text files.
  • It must allow you to quit.