wxPython

wxPython 2.9 and the Newer Pubsub API: A Simple Tutorial

NOTE: This article is for wxPython 2.9-3.0. If you are using wxPython 4, you should go to my newer article Several years ago, I wrote a tutorial about wxPython 2.8 and its built-in pubsub module which you can read here. Back then, a new API for pubsub was added in wxPython 2.8.11.0 that could be

wxPython 2.9 and the Newer Pubsub API: A Simple Tutorial Read More »

wxPython: How to Update a Progress Bar from a Thread

Every now and then, I see someone wondering how to create a progress bar and update it. So I decided to whip up an example application that updates a progress bar (technically a wx.Gauge widget) from a thread. In this tutorial, we will create a frame with a button. When the button is pushed, it

wxPython: How to Update a Progress Bar from a Thread Read More »

wxPython: How to Redirect Python’s Logging Module to a TextCtrl

Today I was reading the wxPython Google group / mailing list and there was someone asking about how to make Python’s logging module write its output to file and to a TextCtrl. It turns out that you need to create a custom logging handler to do it. At first, I tried just using a normal

wxPython: How to Redirect Python’s Logging Module to a TextCtrl Read More »

wxPython: How to Edit Your GUI Interactively Using reload()

Today, I came across an interesting question on StackOverflow where the author was asking how he could write a wxPython program dynamically. In other words, he wanted to be able to edit the code and basically refresh the application without closing and re-running his code. The simplest way would be to use Python’s built-in reload

wxPython: How to Edit Your GUI Interactively Using reload() Read More »

wxPython: Creating a Grid with XRC

I recently tried to help someone (on the wxPython mailing list) figure out how to use a Grid widget (wx.grid.Grid) via XRC. It should be simple, but if you run the code below, you’ll discover a weird issue: import wx from wx import xrc ######################################################################## class MyApp(wx.App): def OnInit(self): self.res = xrc.XmlResource(“grid.xrc”) frame = self.res.LoadFrame(None,

wxPython: Creating a Grid with XRC Read More »

Using Python to Teach About Finding the Digital Root

My wife teaches 3rd grade math and she recently learned about the process of obtaining the digital root of numbers. The digital root is a single digit number found by summing the individual digits. So for 15, you would add 1+5 to get 6. Thus 6 is the digital root of 15. The trainer that

Using Python to Teach About Finding the Digital Root Read More »

wxPython: Updating Your Application with Esky

Today we’re going to learn about one of wxPython’s newer features: wx.lib.softwareupdate. It was actually added a couple of years ago. What this allows you to do is add update abilities to your software. As far as I can tell, this mixin only allows prompted updates, not silent updates. Getting Started It’s built into wxPython

wxPython: Updating Your Application with Esky Read More »

wxPython: How to Double-click an Item in an ObjectListView Widget

This week, I needed to figure out how to attach an event handler that would fire when I double-clicked an item (i.e. row) in an ObjectListView widget that was in LC_REPORT mode. For some reason, there isn’t an obvious mouse event for that. There is an EVT_LIST_ITEM_RIGHT_CLICK and an EVT_LIST_ITEM_MIDDLE_CLICK, but nothing for LEFT clicks

wxPython: How to Double-click an Item in an ObjectListView Widget Read More »

wxPython: How to Get Children Widgets from a Sizer

The other day, I stumbled across a question on StackOverflow asking how to get the children widgets of a BoxSizer. In wxPython, you would expect to call the sizer’s GetChildren() method. However, this returns a list of SizerItems objects rather than a list of the actual widgets themselves. You can see the difference if you

wxPython: How to Get Children Widgets from a Sizer Read More »