Archive for November, 2011

This blog ran an article about wxPython, SQLAlchemy, CRUD and MVC earlier this month. The program that we created in that post was dubbed “MediaLocker”, whether or not it was explicitly stated as such. Anyway, since then, I have received a couple comments about improving the program. One came from Michael Bayer, one of the creative minds behind SQLAlchemy itself and the other comments came from Werner Bruhin, a nice guy who haunts the wxPython mailing list, helping new users. So I went about creating an improved version of the code following their advice. Werner then improved it a bit more. So in this article, we will be looking at improving the code, first with my example and then with his. Enough talk though; let’s get to the meat of story! (more…)

This week, I discovered a new book on Python titled Treading on Python Vol. 1 by Matt Harrison. The book is only in draft form, so it’s still pretty rough, but the author was kind enough to send me a free copy in epub and mobi formats. I read part of it using EPUBReader, an add-on to Firefox so I could read it in my browser. Then I switched to the PC Kindle software to finish the book.

The book is your typical introductory text to Python. I felt like it was a tad shorter than some of the intro books I’ve read though, but that may be because it was an eBook. He covers what you would expect, but here’s a short list of topics:

  • Installation of Python
  • The Interpreter
  • Numbers and Strings
  • dir and help (introspection, although he never uses that word)
  • comments
  • Sequences (lists, tuples and dicts)
  • Functions, Classes, and Methods
  • File I/O
  • Exceptions – very brief, doesn’t show how to make your own

He uses a few odd terms that I’ve never heard, like calling the double-underscore methods of Python “dunder methods” (like __init__ or __seq__). The only name I’ve ever heard for those are “magic methods”. He also says the following: It is common to hear in Python parlance of “truthy” or “falsey” (Kindle location 700) regarding bools and bool-like objects. I’ve read a lot of books on Python and never come across that before either. It’s no big deal, they just kind of jumped out at me and left me scratching my head.

Anyway, I can’t be too hard on it because it’s still only a draft. I did notice that some of the first sections in the book seem to get repeated later on. I’m not sure if that was intentional or not. Maybe it was a way of emphasizing the material. Regardless, the information in the book is pretty good for someone who is just coming to the language. I should mention that it’s more of an overview book though. Every topic has only 1-4 pages of information on it on average, so this book will give you enough information to get going, but you’ll still need to read the docs if you hit a wall. For example, he mentions comprehensions, but never says what they are. You don’t need those when you program, but they sure can be nice. On the other hand, he does talk about the “with” statement quite a bit.

Overall, I would say this is a pretty good introductory text on Python. The reader will get a nice overview of the language without the confusion of 3rd party packages or even very much of the included modules. They get a little introduction to Python introspection tools, which is pretty nice. When the book is finished, this is one you may want to keep in mind for your budding Pythonista. You can actually purchase the book from his website now for $4.99 and I think you get the final version when it’s done, kind of like Manning’s Early Access Program (MEAP).

Python is pretty easy to install on Windows, but sometimes you need to do a few extra tweaks to really get the most our your development environment. In this article, we will try to cover all the common things you might want to do or install to get an ideal Python Windows development workspace set up. Some of you might think that all you need to do is install Python and you’re done, but if you’re going to do Windows development, then you’ll need a few other packages to make it nicer. (more…)

Recently, I was linked to the Python Forum because one of my friends on the wxPython IRC channel said that Packt was trying to find reviewers for their new book, Numpy 1.5 Beginner’s Guide by Ivan Idris. I doubt they’re going to find many people on that website though. I’ve certainly never heard of it. Anyway, Packt was kind enough to give me a copy of it as an ebook, so I’ll be reading it over the next couple of weeks so I can review it for this website. (more…)

In this article, we will be creating a program to store our personal books or perhaps just the books you’ve read. It will demonstrate how to combine wxPython and SqlAlchemy, a SQL Object Relational Mapper (ORM). This program will also give you an introduction to the model-view-controller (MVC) and “create, read, update and destroy” (CRUD) methodologies. The aim is to show you how to create an application that can do the following:

  • Create a database (create)
  • Add records to that database (sort of create)
  • Display the records (read and view)
  • Modify records (update)
  • Delete records (destroy)

The order of this tutorial will follow MVC, so we will start with the model. The model is the basis for the GUI (the View) anyway, so it’s a good place to start. (more…)

Last night, Andrea Gavana released his new Namespace Diff Tool (NDT) to the world. I got his permission to reprint his announcement here for all those people who don’t follow the wxPython mailing list. I think it sounds like a really cool tool. You should check it out and see what you think. Here is the announcement: (more…)

One day at work last month, I was told that we had a feature request for one of my programs. They wanted a “dark mode” for when they used my application at night as the normal colors were kind of glaring. My program is used in laptops in police cars, so I could understand their frustration. I spent some time looking into the matter and got a mostly working script put together which I’m going to share with my readers. Of course, if you’re a long time reader, you probably know I’m talking about a wxPython program. I write almost all my GUIs using wxPython. Anyway, let’s get on with the story! (more…)

One of the new agw widgets to be included in wxPython is one called the UltimateListCtrl. It’s a pure Python widget that can have pretty much any other widget stuck into any of the cells, which makes it really flexible. It also allows the skilled programmer the ability to add custom renderers to make the interface different. In this article, we will take a quick look at this fascinating widget. (more…)