GUI Toolkits


kivy_poster_1

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 http://kivy.org/#contest

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 2.9.3.1, 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: http://www.blog.pythonlibrary.org/feed/. 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.

(more…)

This week I saw a question on StackOverflow about putting two grids into a SplitterWindow which itself was in a Notebook page. Personally I think that’s a little convoluted, but I thought it was an interesting challenge and I came up with a solution. Then the fellow wanted to know how to sync the scrolling of the two grids. Well, I found an answer and modified my code and decided it was worth writing an article about. (more…)

The other day I was working on a project where I was using the fabulous ObjectListView widget (a wrapper around wx.ListCtrl) and I wanted to add the ability to double-click an item in the control to make it open a PDF. I knew I had read somewhere on the internet about how do this sort of thing, but it was once again a drag to find that information. So now that I know, I decided to share it this time. I’ll also show you how to open a PDF file on Windows as a bonus! (more…)

wxOLVTooltips

Recently I was trying to figure out how to add tooltips to each item in an ObjectListView widget in wxPython on Windows. The wxPython wiki has an example that uses PyWin32, but I didn’t want to go that route. So I asked on the wxPython Google Group and got an interesting answer. They had actually used one of my old articles to build their solution for me. I have cleaned it up a little bit and decided it was worth sharing with my readers: (more…)

Next Page »