GUI Toolkits

Redirecting stdout seems to be a pretty common request on the wxPython users group, so I decided to see how easy it would be to do it with Tkinter. The typical use case for redirecting stdout or stderr is that you are calling some other process (like ping or tracert) and you want to catch what it’s doing to put it into your UI. Usually you can just use Python’s subprocess module and call its communicate() method to access the data. Then you can just print it to stdout and it will magically appear in your UI’s widget of choice.

Our finished user interface will look something like the following:


Let’s find out how to do this with Tkinter: (more…)

I’ve been using wxPython for quite a while now and I see certain questions come up on a fairly frequent basis. One of the popular ones is how to ask the user for their credentials before loading up the rest of the application. There are several approaches to this, but I am going to focus on a simple solution as I believe this solution can be used as the basis for more complex solutions.

Basically what we want to happen is for the user to see a login dialog where they have to enter their username and password. If they enter it correctly, then the program will continue to load and they’ll see the main interface. You see this a lot on websites with a common use case being web email clients. Desktop applications don’t include this functionality as often, although you will see it for’s application and for law enforcement software. We will be creating a dialog that looks like this:

wxLogin.png (more…)

Kivy is a neat package that allows Python developers to create user interfaces on mobile devices. You can also deploy the applications to desktops too. This is the second book I’ve seen put out on the subject. The first book, Kivy – Interactive Applications in Python by Roberto Ulloa came out last year from Packt Publishing. This year, we have Dusty Phillips’ work, Creating Apps in Kivy from O’Reilly. I will be reviewing the PDF version of the book.

Quick Review

  • Why I picked it up:I picked this book up because I like the author’s previous work, Python 3 Object Oriented Programming
  • Why I finished it: The book is pretty short and it’s interesting
  • I’d give it to: Someone who already knows Python



Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. The Kivy organization is organizing its second application development contest.! This is a great chance for new and experienced users to show off their skills and compete for prizes. Entries will be judged on a range of criteria accessible to both new and experienced programmers, so don’t be afraid to dive in! For more information, visit

The other day someone was asking a lot of questions on StackOverflow about how to work with wizards in wxPython. You can read the two original questions here and here. The code we’ll be looking at in this example is what I used to answer the questions on Stack. The primary question was how to disable the Next in a wxPython wizard. (more…)

One of my friends on the wxPython Google Group asked how to catch any exception that happens in wxPython. The problem is complicated somewhat because wxPython is a wrapper on top of a C++ library (wxWidgets). You can read about the issue on the wxPython wiki. Several wxPython users mentioned using Python’s sys.excepthook to catch the errors. So I decided to write up an example showing how that worked based on something that Andrea Gavana posted on the aforementioned thread. We will also look at the solution that is in that wiki link. (more…)

The wxPython toolkit provides an alternative to using Sizers for layout that is known as “sized_controls”. These controls or widgets are basically top-level widgets (like frame, panel, dialog, etc) that have sizing logic built into them. This article will cover all four types of sized_controls. They are as follows:

  • SizedPanel
  • SizedScrolledPanel
  • SizedFrame
  • SizedDialog

The SizedScrolledPanel widget is new as of wxPython, but the other 3 types of controls are available in wxPython 2.8.8 and possibly older versions (see Trac for more info). Just keep that in mind if you are on wxPython 2.8. If you are ready, we can get started! (more…)

wxPython 2.9 introduced the world to a new type of sizer that can take widgets and automatically make them “wrap” around as you resize the frame. That sizer is known as wx.WrapSizer. For some reason, it is relatively unknown, so we’ll spend a few minutes going over how to use it in this article.

To follow along with this tutorial, you will need to have wxPython 2.9 or greater. Once you’ve got that, we can continue. (more…)

Really Simple Syndication (RSS) has been with us for a long time and allows us to see new articles on our favorite website easily. Python doesn’t have an RSS reader module in the standard library, so we’ll be using the Universal Feed Parser 5.1.3 to do our parsing. If you do not have it already, you should go download it from the Python Package Index now. We’ll use this blog’s RSS feed to make testing simpler. The url for the feed is: During my experiments, I noticed that my blog software will change a dash into the following unicode character: \u2013. This will cause feedparser to throw a UnicodeEncodeError, so I also recommend downloading the handy unidecode module to help with that. (more…)

I recently received a copy of Kivy: Interactive Applications in Python by Roberto Ulloa. This is currently the only book about Kivy. Kivy is a cross-platform GUI toolkit that will run on Linux, Windows, and OS X as well as Android and iOS. In fact, the people behind Kivy emphasize that this is aimed primarily at mobile programming. Kivy supports multitouch and has a very active group of programmers. You can read more about Kivy on their project’s home page. I will be reviewing the PDF version of the book.

Here’s my quick review for those of you without a lot of time:

Quick Review

  • Why I picked it up: I received this book as payment for helping with the reviewing of another Packt book, but I would have bought it myself because I am interested in learning Python for Android/iOS and I like learning about Python GUI toolkits.
  • Why I finished it: The book is short and I was optimistic that it would get better.
  • I’d give it to: Someone who already knows Python and the basics of Kivy, although I don’t think I would recommend it.


Next Page »