wxPython


There was a recent post on StackOverflow that I thought was interesting. It asked how to get the event name from the event object, such as EVT_BUTTON, rather than the event’s id number. So I did some investigation into the subject and there is nothing builtin to wxPython that does this task. Robin Dunn, creator of wxPython, recommended that I should create a dictionary of the events and their ids to accomplish this feat. So in this tutorial, we’ll take a look at how to go about that. (more…)

Have you ever wondered about how to change your font in wxPython? Well, now is your lucky day because that is exactly what this tutorial is going to cover. We will look at the following three items:

  • Built-in fonts of wxPython
  • The font dialog
  • The font enumerator demo from the wxPython demo

Fonts are an important part of your program and enhance your program’s readability. It’s always a good idea to make sure your fonts are the right size and place. Yes, that’s common sense, but sometimes common sense doesn’t happen in programming. Enough philosophizing. Let’s get to the meat of the article!

(more…)

The other day on the wxPython IRC channel on freenode, one of the members there asked if there was a way to make the wx.FileDialog display more than one file type at a time. In the back of mind, I thought I had seen a Microsoft product that could do it, but I’d never seen any wxPython examples. In this short tutorial, you will learn how to do this handy trick! (more…)

In this article, we will be looking at wxPython’s Wizard widget. No, it has nothing to do with Dumbledore or Gandalf. Instead, it is that dialog that you’ll see when you run an installer or set up a template. Sometimes you’ll even see them used for setting up mail merge. We will cover two examples in this tutorial: one that is fairly simple and another that is slightly more complex. Let’s get started!

Note: The code in this article was adapted from the wxPython Demo application

(more…)

Cody Precord, author of wxPython 2.8 Application Development Cookbook, recently started a thread on the wxPython-dev Google group where he described a WYSIWYG project he has been working on for creating wxPython GUIs. Originally, he programmed it as a plugin for his Editra project, but has decided to release it as a separate project.

He would like some help in continuing the development of this project. If you go to read the thread, you’ll see you can download the a screencast that shows the program in action as an avi file. I uploaded it to Youtube and embedded it below as well.

I think this project looks really cool and has lots of potential. I hope that there of many other developers out there that will jump on this project and help get it finished. It would be great to have a tool like this. You can join the conversation by joining the wxPython-dev Google Group.

Last year, we covered some tips and tricks for the Grid control.In this article, we will go over a few tips and tricks for the wx.ListCtrl widget when it’s in “report” mode. Take a look at the tips below:

  • How to create a simple ListCtrl
  • How to sort the rows of a ListCtrl
  • How to make the ListCtrl cells editable in place
  • Associating objects with ListCtrl rows
  • Alternate the row colors of a ListCtrl

(more…)

A lot of websites are doing year-end retrospectives this week, so I thought you might find it interesting to know which articles on this blog were the most popular this year. Below you will find links to each article along with the page view count I got from Google Analytics:

  1. A Simple Step-by-Step Reportlab Tutorial, 9,709 page views, posted 03/08/2010
  2. Another Step-by-Step SqlAlchemy Tutorial Part 1, 7,746 page views, posted 02/03/2010
  3. Another Step-by-Step SqlAlchemy Tutorial Part 2, 4,858 page views, posted 02/03/2010
  4. Manipulating PDFs with Python and pyPdf, 4,511 page views, posted 05/15/2010
  5. Python 101: Introspection, 4,473 page views, posted 10/14/2010
  6. wxPython: Grid Tips and Tricks, 3,476 page views, posted 04/04/2010
  7. wxPython: Creating a Simple MP3 Player, 3,401 page views, posted 04/20/2010
  8. Python and Microsoft Office – Using PyWin32, 3,323 page views, posted 07/16/2010
  9. wxPython and Threads, 3,183 page views, posted 05/22/2010

It would seem that SqlAlchemy and Reportlab are pretty popular topics. Are there any articles about either of these cool packages that you think I should write? As you can see, wxPython makes it into the top ten 3 times! What should I write about next regarding wxPython?

This upcoming year, I plan to write about some of the other GUI toolkits. Which one do you think I should do first? Tkinter, PySide, PyGUI or something else? What packages or standard libraries do you think I should cover? Feel free to let me know via the comments below or via my contact form (link at top). I’m looking forward to another year of Python tinkering and writing and I hope you are too! Thanks for your readership and encouragement this year!

Earlier this week, there was a discussion on the wxPython IRC channel about how to store objects in wx.ListBox. Then later on that day, there was a question on StackOverflow about the same thing, but in relation to the wx.ComboBox. Fortunately, both of these widgets inherit from wx.ItemContainer and contain the Append method, which allows you to associate an object with an item in these widgets. In this article, you will find out how this is done. (more…)

Back in 2006, Manning released the excellent wxPython in Action book by Noel Rappin and Robin Dunn (creator of wxPython). This is still a great book and I wholeheartedly recommend it to people that want to increase their understanding of wxPython. However, Packt Publishing has just released the first new wxPython book in over four years. It’s called wxPython 2.8 Application Development Cookbook by Cody Precord (creator of Editra). There’s an ebook version of each of these books at their respective publisher’s websites.

I plan to review Precord’s book once I’ve finished reading it. He’s been pretty active on the wxPython mailing list, helping people (including me) learn the ins and outs of wxPython. If you like wx as much as I do, I hope you’ll support him and the wxPython community by buying the book. Packt gives part of the purchase price of the book back to the project that it’s about, which is pretty cool. They’re also having a Python book sale on the Packt website (hat tip to Robin Dunn on that one).

When I originally started this blog, it was mostly a brain dump on my part so I wouldn’t forget how I did something cool with Python. Later on, I decided to use it to also document what I considered under-documented portions of wxPython. If my posts drew enough interest, I would also re-work the post into a wiki page on the wxPython wiki. (more…)

« Previous PageNext Page »