Archive for the ‘Python’ Category


Creating Select form fields with currencies and countries using Babel and WTForms

By on August 4th, 2010 in Python Comments (1)

A quick tutorial on how to create some nifty currency and country select fields using WTForms. This was sort of a headache to figure out, which is why I’m sharing it. If you have a cleaner way to do this (particularly the country list), please comment, because I’m highly dissatisfied with hardcoding the countries and…

Read more…


Sort a Python list by dictionary key

By on May 5th, 2010 in Python Comments (4)

I probably should have known how to do this innately, it’s that simple, but I didn’t. So for the benefit of fellow feckless Pythonistas, here is how to sort a list of dictionaries based on a key in the dictionary. Say I have a list of dictionaries where each dictionary represents data for a person…

Read more…


Displaying fieldsets with Jinja2 and Django forms, the quick way

By on April 30th, 2010 in Python Leave a Comment

We had two problems to solve: we wanted to use fieldsets with Django forms, and the follow-up issue, making that custom rendering Jinja2-compatible. There are plenty of awesome libraries/snippets to display forms as fieldsets, including django-form-utils. I wanted a quick and dirty and method of doing this. So here it is: step 1, add a…

Read more…


Jinja2 and Django 4ever

By on March 15th, 2010 in Python Comments (4)

My goal is to stop hating Django. Our team has been bouncing back and forth between using Django and Pylons for the creation of the web front end for ChompStack, a restaurant-oriented iPhone app site with an admin panel for easy data management. In the beginning, there was Django, and it was good. But gradually…

Read more…


Adding extra fields to a model form in Django’s admin

By on February 11th, 2010 in Python Comments (23)

I ran into this problem recently and found that the Django documentation wasn’t exactly clear on how to solve it, so I’ve provided an example in case anyone else needs to do the same thing. My goal was to add an extra form field to one of my model objects that represented a property which…

Read more…


PyClutter video tutorial

By on February 9th, 2010 in Python Comments (3)

As usual, we’re learning together: today I decided that I would like to be able to play video in our Bazooka (PyClutter-based) framework, so I set out to write a Bazooka video class. The source code for Bazooka, including this video class, is in our git repository here. First, make sure you have PyClutter 0.9.2…

Read more…


Clutter links

By on February 8th, 2010 in Python Leave a Comment

Bazooka is built on top of the Python bindings for the 0.9.2 version of the Clutter Toolkit, or whatever version the latest stable Python bindings are at. Occasionally I go trolling for additional Clutter links, and I thought I’d post a few of my finds here for easy access. Latest stable clutter docs Latest stable…

Read more…


And on the 7th day there were PyGTK custom icons…

By on January 18th, 2010 in Python Leave a Comment

It’s been a few days since our first bumbling foray into custom PyGTK icons using PyCairo, and now it’s time to reap the benefits. We’re concocting a few simple classes which will make drawing and icon creation a breeze. Your final, glorious product should look like this: Unimpressive, you say? Well maybe so, but take…

Read more…


F**** YEAH I DREW ANOTHER RECTANGLE! Icons in PyGTK continued…

By on January 13th, 2010 in Python Leave a Comment

Welcome to Part II of learning to draw custom icons in PyGTK with PyCairo. In the previous post we learned how to draw on a gtk.DrawingArea the hard way. Now let’s simplify things; after all, who has time to wait for “expose-event”s before drawing?? In a recession??? Another suggested method for drawing in a Cairo/Drawable…

Read more…


F*** YEAH I DREW A SQUARE! PyGTK and PyCairo in harmony.

By on January 10th, 2010 in Python Comments (3)

Never in my life have I received so much gratification from one simple act: the act of drawing of a square. My current goal is to create very basic, custom icons such as a circles and squares for my PyGTK toolbar buttons in Screwdriver (a Python framework which is our answer to the question of…

Read more…