A Byte of Python

Chapter 16. What Next?

Table of Contents

Graphical Software
Summary of GUI Tools
Explore More

If you have read this book thoroughly till now and practiced writing a lot of programs, then you must have become comfortable and familiar with Python. You have probably created some Python programs to try out stuff and to exercise your Python skills as well. If you have not done it already, you should. The question now is 'What Next?'.

I would suggest that you tackle this problem: create your own command-line address-book program using which you can add, modify, delete or search for your contacts such as friends, family and colleagues and their information such as email address and/or phone number. Details must be stored for later retrieval.

This is fairly easy if you think about it in terms of all the various stuff that we have come across till now. If you still want directions on how to proceed, then here's a hint.

Hint. (You shouldn't be reading this).  Create a class to represent the person's information. Use a dictionary to store person objects with their name as the key. Use the cPickle module to store the objects persistently on your hard disk. Use the dictionary built-in methods to add, delete and modify the persons.

Once you are able to do this, you can claim to be a Python programmer. Now, immediately send me a mail thanking me for this great book ;-) . This step is optional but recommended.

Here are some ways to continue your journey with Python:

Graphical Software

GUI Libraries using Python - you need these to create your own graphical programs using Python. You can create your own IrfanView or Kuickshow or anything like that using the GUI libraries with their Python bindings. Bindings are what allow you to write programs in Python and use the libraries which are themselves written in C or C++ or other languages.

There are lots of choices for GUI using Python:

  • PyQt.  This is the Python binding for the Qt toolkit which is the foundation upon which the KDE is built. Qt is extremely easy to use and very powerful especially due to the Qt Designer and the amazing Qt documentation. You can use it for free on Linux but you will have to pay for it if you want to use it on Windows. PyQt is free if you want to create free (GPL'ed) software on Linux/Unix and paid if you want to create proprietary software. A good resource on PyQt is 'GUI Programming with Python: Qt Edition'. See the official homepage for more details.

  • PyGTK.  This is the Python binding for the GTK+ toolkit which is the foundation upon which GNOME is built. GTK+ has many quirks in usage but once you become comfortable, you can create GUI apps fast. The Glade graphical interface designer is indispensable. The documentation is yet to improve. GTK+ works well on Linux but its port to Windows is incomplete. You can create both free as well as proprietary software using GTK+. See the official homepage for more details.

  • wxPython.  This is the Python bindings for the wxWidgets toolkit. wxPython has a learning curve associated with it. However, it is very portable and runs on Linux, Windows, Mac and even embedded platforms. There are many IDEs available for wxPython which include GUI designers as well such as SPE (Stani's Python Editor) and the wxGlade GUI builder. You can create free as well as proprietary software using wxPython. See the official homepage for more details.

  • TkInter.  This is one of the oldest GUI toolkits in existence. If you have used IDLE, you have seen a TkInter program at work. The documentation for TkInter at PythonWare.org is comprehensive. TkInter is portable and works on both Linux/Unix as well as Windows. Importantly, TkInter is part of the standard Python distribution.

  • For more choices, see the GuiProgramming wiki page at Python.org

Summary of GUI Tools

Unfortunately, there is no one standard GUI tool for Python. I suggest that you choose one of the above tools depending on your situation. The first factor is whether you are willing to pay to use any of the GUI tools. The second factor is whether you want the program to run on Linux or Windows or both. The third factor is whether you are a KDE or GNOME user on Linux.

Future Chapters

I am contemplating writing 1 or 2 chapters for this book on GUI Programming. I will be probably be choosing wxPython as the choice of toolkit. If you would like to present your views on the subject, please join the byte-of-python mailing list where readers discuss with me on what improvements can be made to the book.