wxPython


A few months ago, I wrote about creating a simple MP3 Player using wxPython’s MediaCtrl widget. Since then, a fellow released the MplayerCtrl, a wxPython widget that wraps mplayer, a popular cross-platform media player. I actually ended up switching my MP3 Player’s backend to use this new control, but that’s a story for another post. This article will just focus on creating a really simple Media Player that you can play movies with. And you can do it all with Python! If you’re like me, you’ll think this rocks! (more…)

For the second half of this series, I discovered that there are even more dialogs than I originally thought. While it would have probably been a good idea to have split this into three parts, we’re going to stick with just two. In this article, we’re going to cover the following dialogs:

  • GenericMessageDialog (AGW)
  • ImageDialog
  • wx.MultiChoiceDialog
  • wx.PageSetupDialog
  • wx.PrintDialog
  • wx.ProgressDialog
  • PyBusyInfo (AGW)
  • PyProgress (AGW)
  • ScrolledMessageDialog
  • wx.SingleChoiceDialog
  • wx.TextEntryDialog

For the uninitiated, there’s also an AboutBox dialog that’s not here for the very simple reason that it’s already been covered in this blog outside of this series. Check that out for yourself. Just to clear up any confusion about why wx.Dialog isn’t here: this series ONLY covers pre-built dialogs. The wx.Dialog widget is great for creating your own custom dialogs. The last note that should be covered is that the example code here has been yanked from the wxPython demo and re-purposed for this article. (more…)

I see a number of questions on the wxPython mailing list or its IRC channel about communicating between frames and most of the time what the developer needs is the PubSub module. The Publisher / Subscriber model is a way to send messages to one or more listeners. You can read about it here. The Observer pattern is said to be based on the Publish / Subscribe pattern. In wxPython land, we have the pubsub module which can be accessed from wx.lib.pubsub. It’s actually included in wxPython, but you can also download it as a standalone module from its Source Forge. An alternative to pubsub is the PyDispatcher module.

Anyway, in this article we won’t be studying the theory behind either of these modules. Instead, we’ll use a semi-practical example in wxPython to show how to use the built-in version of pubsub to communicate between two frames. If you’re still with me at this point, then I encourage you to read on! (more…)

Dialogs are an integral part of user interface design. We use them all the time. We find dialogs everywhere, in many shapes and sizes. In this article we will cover the following dialog types:

  • wx.BusyInfo
  • wx.ColourDialog
  • CubeColourDialog (AGW)
  • wx.DirDialog and MultiDirDialog (AGW)
  • wx.FileDialog
  • wx.FontDialog
  • wx.MessageDialog

That’s a lot of dialogs, but there’s still eight more in the wxPython demo. We’ll look at those next time. For now, let’s take a look at this list! (more…)

Every couple of months, I’ll see someone asking how to switch between two views or panels in a wxPython application that they’re working on. Since this is such a common question and because I had it asked last week on the wxPython channel on IRC, I wrote up a quick script that shows how it’s done. Note that in most cases, the user will probably find one of the many notebook widgets to be more than sufficient for their needs. Anyway, let’s take a look at how to do this thing! (more…)

In the last article, we covered a wide variety of buttons that come with the standard wxPython package. Now we’re going to look at a whole bunch more! In case you haven’t figured it out yet, wxPython takes Python’s “batteries included” philosophy very seriously! In this post we’ll look at the following buttons:

  • wx.RadioButton
  • wx.SpinButton
  • AquaButton (AGW)
  • GradientButton (AGW)
  • ShapedButton (AGW)

Let’s get cracking! (more…)

Most people don’t really think about the widgets they use every day. Instead, they just take them for granted. The button is one of the most commonly used widgets that we use. From the keys on our keyboards to the buttons on door locks, we find them everywhere. They are even more prevalent in software where buttons can be practically any shape or size. Some buttons don’t even look like buttons! In this article, we’ll look at several buttons that wxPython provides for you and how to use them. (more…)

Last year I needed to figure out a way to get the following information with Python: get the route table, capture the data from pinging a series of IPs, run tracert and get information about the NIC(s) installed. This all needed to be done on a Windows machine as it was part of a diagnostics script to try to figure out why the machine (usually a laptop) wouldn’t connect to our VPN. I ended up creating a wxPython GUI to make it easy for the user to run, but these scripts will work just fine without wx. Let’s see what they look like! (more…)

If you use GUIs in Python much, then you know that sometimes you need to execute some long running process every now and then. Of course, if you do that as you would with a command line program, then you’ll be in for a surprise. In most cases, you’ll end up blocking your GUI’s event loop and the user will see your program freeze. What can you do to get around just mishaps? Start the task in another thread or process of course! In this article, we’ll look at how to do this with wxPython and Python’s threading module. (more…)

There’s a handy 3rd party module called pyPdf out there that you can use to merge PDFs documents together, rotate pages, split and crop pages, and decrypt/encrypt PDF documents. In this article, we’ll take a look at a few of these functions and then create a simple GUI with wxPython that will allow us to merge a couple of PDFs. (more…)

Next Page »