Monthly Archives: July 2014

Python 101: An Intro to Pony ORM

The Pony ORM project is another object relational mapper package for Python. They allow you to query a database using generators. They also have an online ER Diagram Editor that is supposed to help you create a model. When I first started using PonyORM, they were one of the only Python packages I’ve seen with a multi-licensing scheme where you can develop using a GNU license or purchase a license for non-open source work. However, as of October 2016, the PonyORM package is under the Apache 2.0 license.

In this article, we will spend some time learning the basics of this package. Continue reading Python 101: An Intro to Pony ORM

An Intro to peewee – Another Python ORM

I thought it would be fun to try out a few different Python object relational mappers (ORMs) besides SQLAlchemy. I recently stumbled across a project known as peewee. For this article, we will take the examples from my SQLAlchemy tutorial and port it to peewee to see how it stands up. The peewee project supports sqlite, postgres and MySQL out of the box, which isn’t as flexible as SQLAlchemy, but it’s not bad either. You can also use peewee with the Flask web framework, via a handy Flask-peewee plugin.

Anyway, let’s start playing around with this fun little library!

Continue reading An Intro to peewee – Another Python ORM

Tkinter – Redirecting stdout / stderr

Redirecting stdout seems to be a pretty common request on the wxPython users group, so I decided to see how easy it would be to do it with Tkinter. The typical use case for redirecting stdout or stderr is that you are calling some other process (like ping or tracert) and you want to catch what it’s doing to put it into your UI. Usually you can just use Python’s subprocess module and call its communicate() method to access the data. Then you can just print it to stdout and it will magically appear in your UI’s widget of choice.

Our finished user interface will look something like the following:


Let’s find out how to do this with Tkinter: Continue reading Tkinter – Redirecting stdout / stderr

wxPython: How to Create a Login Dialog

I’ve been using wxPython for quite a while now and I see certain questions come up on a fairly frequent basis. One of the popular ones is how to ask the user for their credentials before loading up the rest of the application. There are several approaches to this, but I am going to focus on a simple solution as I believe this solution can be used as the basis for more complex solutions.

Basically what we want to happen is for the user to see a login dialog where they have to enter their username and password. If they enter it correctly, then the program will continue to load and they’ll see the main interface. You see this a lot on websites with a common use case being web email clients. Desktop applications don’t include this functionality as often, although you will see it for’s application and for law enforcement software. We will be creating a dialog that looks like this:

wxLogin.png Continue reading wxPython: How to Create a Login Dialog

Python Most Popular University Teaching Language?

Yesterday, Philip Guo made the claim that Python is now the most popular introductory teaching language at top U.S. universities on the Communications of the ACM blog. I came across this information via Planet Python’s redistribution of Vasudev Ram’s blog post on the subject.

If this is true, then I think this is really cool. Python is easy to learn and quite capable of most programming tasks. I’ve been using it for over 8 years now in all kinds of settings and Python has almost always come through for me. Anyway, check out the article and feel free to leave some feedback.