wxPython


Have you ever wondered if you could create a wxPython program using XML? Well, I never did either, but there is a way and its name is XRC. In fact, wxPython comes with an editor called XRCed that you can use to layout your GUI and generate the XML code with. In this article, we’ll give you a quick walk-through of XRC and how to use it to create a couple GUI skeletons. We will look at two examples that use only XRC controls and then a third that mixes in some additional non-XRC widgets. (more…)

Last month, I started a series of articles on creating simple applications with wxPython. The first couple of articles were on an Image Viewer program. While I won’t abandon that project, I thought it was time for us to delve into something new. In this article we will start a journey into the wild and woolly world of playing MP3s. We will create a very simple interface that we can use to play, pause and stop a song with. We will also learn how to seek within a track and change the volume of the music. In future articles, we will add a display with music information (like title, artist, genre, etc), track lists, a random function, and more. Let’s get started! (more…)

Have you ever thought that it would be cool to have your wxPython code take a screenshot of itself? Well, Andrea Gavana figured out a cool way to do just that and between what he told us on the wxPython mailing list and what I learned from other sources, you will soon learn how to not only take the screenshot, but how to send it to your printer! (more…)

The other day, we created a simple image viewer. Today we will create a secondary dialog to display the image’s EXIF data, if it has any. We will make it in such a way that this window will update as we change pictures using the cool pubsub module. We will use the version that is included in wxPython for this application, but feel free to use the stand-alone version as well. (more…)

Last month I mentioned that we would go on a journey to learn some tips and tricks for wxPython’s Grid widget. Well, the coding is done and I thought it was time to actually do this thing. In the following article you will learn how to:

  • Create a right-click pop-up menu in a cell
  • Put tooltips on the Row and Column labels and on the cells
  • How to use your keyboards arrow keys to move out of a cell that’s being edited
  • Hide Row/Column labels/headers
  • Show a pop-up when clicking a row label
  • Change row/column labels

Well, what are you waiting for? Click the “more” link and start reading! (more…)

Have you ever wanted to restart your Windows PC with out pressing Start, Shutdown or CTRL+ALT+DEL? What about restarting your annoying co-worker’s PC…the one who just doesn’t know when to shut up? Well, Python has the answer and this blog will tell you how to do it! (more…)

The other day, I was chatting with some wxPython newbies on the wxPython IRC channel and one of them wanted to know how to display images in wx. There are lots of different ways to do this, but I had a pre-made solution that I’d cobbled together a couple of years ago for work. Since this is a fairly popular topic, I thought it would be wise to let you, dear reader, in on the secret. (more…)

Yesterday, I received a request to create a GUI with Tkinter or wxPython that had an image for the background with buttons on top. After looking at Tkinter, I discovered that it’s PhotoImage widget only supported two formats: gif and pgm (unless I installed the Python Imaging Library). Because of this, I decided to give wxPython a whirl. Here’s what I found out. (more…)

The grid widget in wxPython is one of the most complex GUI elements that you’ll work with in this toolkit. In this article you will learn the basics of grid creation and usage. One of the major uses for a grid is to display tabular data. Another use is to create some kind of spreadsheet. If you need something where you need a lot of cells that can be edited easily, then the grid widget is probably what you want. The ListCtrl in Report Mode is similar in appearance to the grid and can be used as a replacement for the grid depending on your needs. (more…)

A few days ago, I wrote an article about using ConfigObj with wxPython. The first question I was asked about the article regarded using a configuration file to generate the dialog. I thought this was an interesting idea, so I took a stab at implementing that functionality. Personally I think it would be probably be better to just create the dialog using XRC and use ConfigObj to help manage which dialog file is loaded that way. However, this was an intriguing exercise to me and I think you’ll find it enlightening too. (more…)

« Previous PageNext Page »