Note: This article was first published the April 2008 issue of Python Magazine
By: Mark Mruss
GUI programming, like many other types of programming, can sometimes prove exhausting because you must repeat yourself over and over again. AVC is one tool available to Python GUI programmers that attempts to simplify things by synchronizing application data and GUI widgets.
Every once in a while I find myself browsing the Internet trying to find out what’s new and exciting in the Python world. Sometimes I browse to find topics for this article; other times mere curiosity draws me across the web. While I was browsing the other day, I stumbled across AVC: the Application View Controller . I was immediately intrigued by it because itsÃ¢Â€Â™ name is so similar to the Model View Controller (MVC) pattern. Being familiar with the Model View Controller pattern, and admittedly having struggles with it in the past, I decided to check out AVC to determine if it might be a viable alternative.
After reading about AVC I was intrigued for several reasons. The main reason was the promise of “a multiplatform, fully automatic, live connection among graphical interface widgets and application variables.”  This means that graphical widgets can be connected to variables and automatically synchronized. One of the (many?) problems with Graphical User Interface (GUI) programming is that you often find yourself doing the same thing over and over again. One of the things that you end of doing over and over again is setting the contents of a widget based on the value of a variable, and then subsequently, setting that variable’s value based on the current state of the widget. Whenever someone promises me an automatic connection between GUI widgets and my variables, I’m interested.
Continue reading AVC: Simplifying your GUI Code
By: Mark Mruss
Note: This article was first published the December 2007 issue of Python Magazine
While the command line will never cease to be useful, nothing will impress your friends more than your latest python masterpiece wrapped up in a slick cross-platform Graphical User Interface (GUI). This tutorial will show you how to create a simple GUI in Python using PyQt4.
- Installing PyQt4
- Your First PyQt4 Application
- The Main Window
- Adding Some Widgets
- Signal Handling
- Displaying a Message
Continue reading An Introduction to PyQt: creating GUIs with Python’s QT bindings
After working with PyGTK and Glade for my first tutorial, I decided to write another more complex tutorial but I couldn’t think of a topic (Note: If you have any suggestions for any tutorials or posts I’d love to hear them) so I decided to work on creating a simple application and hopefully useful topics would arise from there.
The idea I came up with (which will hopefully be simple) is to create a program that will allow me to keep track of the different types of wine that I drink and how much I like them. It’s something I’ve wanted to write for a while so I thought it would be good to combine learning PyGTK and doing it.
I’m going to call the project PyWine. The full source and Glade file for this tutorial can be found here
The first thing to do is start a new Glade project in the projects directory called PyWine. Create a new Window, call it “mainWindow,” and set the title to be “PyWine”. Then add a handler to the destroy signal just like in the first tutorial.
Next I add a Vertical Box to the Window with 4 rows, (from top to bottom) one row for a Menu bar, one row for a Toolbar, one row for a Tree or List View, and the final row for a Status Bar. Name the Tree View “wineView”
Continue reading Building an Application with PyGTK and Glade