PyGObject 2011 Hackfest

Posted in FOSS, GTK, Jokosher, Python, Travel on January 12th, 2011 by admin – Comments Off on PyGObject 2011 Hackfest

The GNOME Foundation has generously sporsored me to attend the GNOME Python2011 Hackfest in Prague. I will be working on porting Jokosher to the new PyGObject bindings which use GObject introspection, and Gtk 3.0. I will identify problems I have while porting, get a chance to talk to the developers and hopefully fix all the issues for other application developers before the new PyGObject is released.

I’ve already started porting Jokosher, but there is still a lot do to. I’m working on the easy stuff so far, and probably won’t get to the difficult bits until next week in Prague. But I’ve already found, and created patches for two simple bugs: one to identify the file that a dynamic module is loaded from, and another to list all the available attributes of the module. Both of these make it easier for me to use PyGObject in an interactive terminal; something I am doing a lot of while I am porting Jokosher and need to check the new method names.

I would like to thank the GNOME Foundation and the sponsors of this hackfest (especially Collabora) for funding the hackfest, and my attendance. I get a great opportunity to visit Prague and meet many really cool Python hackers. Thanks!

GNOME Foundation Sponsorship Logo

Opportunistic Developer Week

Posted in FOSS, Gstreamer, Jokosher, Python on March 3rd, 2010 by admin – Comments Off on Opportunistic Developer Week

Jono Bacon asked me to hold a session on GStreamer and a session on Cairo for the Ubuntu Opportunistic Developer Week.

My GStreamer session went well. The IRC log is available online. I went through my slides which explained how to do a few simple things in Python. I used playbin2 to implement audio/video playback with pausing, seeking and position queries to update the slider. I was impressed how simple the code is; only 120 lines of Python.

I was less impressed with my Cairo session. Unlike with GStreamer, I couldn’t think up a clear use case that I could explain the solution to in under one hour. Instead I went through the very simple cairo API and showed how to use it with GTK or with PDF, PNG and SVG file formats. The IRC log and the code as online for this session as well. I did not make any slides.


This week Michael and I also released a new version of Jokosher. It is available on the download page on Launchpad even though the Jokosher website has not been updated yet.

Little has changed in this release so when we get around to changing the website there won’t be an announcement or anything. The reason for making this release was to get a bug fix out for a blocker which prevented Jokosher from running at all with newer versions of GTK. We wanted to get this done soon so it could be in the Ubuntu Lucid release, and the packaged version wouldn’t be broken. We also threw in a few other bug fixes while we were at it.

Presenting Adventure Money

Posted in FOSS, Python on May 13th, 2007 by admin – 5 Comments

Since I am the person who manages the money for our house, I need an efficient way to keep track of our expenses and an easy way to calculate who owes what to whom at the end of the month. There are lots of good free software utilities for managing money like GnuCash, KMyMoney and the wonderful Gnumeric spreadsheet. I had been using Gnumeric to manage the money for the last 8 months, but now that we have some people staying at the house for just the summer, and other leaving and coming back in September, the spreadsheet was not able to adjust to these irregular circumstances.

The reason I decided to write my own application from scratch instead of using an already existing money management application was because my problem is multi-person orientation and most (if not all) of the money management programs I have tried are single-person oriented. For example GnuCash will let you setup accounts that show you all the money moving to and from a single person. But in my house things like food are paid by any person and shared by every other person. Thus to efficiently and easily calculate who owes how much, it must take into account the fact that one pizza may be paid for by one person, but it was eaten by 4 people. Also I don’t want to have to divide up the amounts myself and put it into GnuCash with multiple accounts, because then I might as well be doing it on paper.

I could have spent my time learning to make an already existing application do exactly what I want; and I probably would have found something pretty close. But I decided that it would be faster to just program it from scratch and then I would be sure I would get exactly what I wanted. I think I was right; it took less then 2 weeks to finished writing this program.

The program is currently called ‘Adventure Money’, but if anyone can think of a better name for it let me know and I’ll gladly change it.

When you first launch the program you will see it has five views, all of which can be seen in the screenshots below.

  • The ‘Money Owed’ view which shows you a list of all the people and how much money they owe this month.
  • The ‘Summary’ view which shows you a break down of the values in the ‘Money Owed’ view by each category and each item.
  • The ‘Payments’ view which shows you all the payments or bills in the account and lets you search them quickly.
  • The ‘Categories’ view which shows you all the categories of payments and lets you create new ones and edit older ones.
  • The ‘People’ view which lets you create, delete and change the name of people as well as set the manager of the account. The manager is the one that everyone will give money to (or take money away from) at the end of the month.

Now I will create an example account:

Here you can see that I have created an account with 3 people, and I am the manager. You can rename a person inline by clicking on the row.

In this screenshot we are creating a category. The category is rent, and is paid by me. Obviously everyone shares the rent, because they all live in the house. But this program does not have to be used by people who live together, only by people who shared money.

I have also created another category ‘Food’ which is paid by anyone. Since I have not specified here who will pay for it, it must be specified when a payment is created. Categories do not have to have a payee, but they do have to have a list of people that shared it.

Here you can see I am entering the rent as a new payment. The value is $900, the date is the 1st of the month, and the category is ‘Rent’. Since I have specified the category, I cannot change the ‘Paid By’ and ‘Shared By’ fields. If I select no category then I can specify the payee and the sharers.

Here is a little popup of the GTK+ Calendar widget to let you select the date. Unfortunately making the popup disappear if you click outside it is only possible with C code and not python. This means that you have to click the close button below to make it disappear.

Now you can see the payment in the list. If I had lots of payments here I could use the widgets above to narrow down my list or search for a specific payment.

Here in summary view you can see everything that a specific person paid for and shared in each month. Currently we have all years and all months selected, and we can see that Eric shared $300 of the rent ($900 split three ways).

Here we can see that I have also shared $300 of the rent and I have paid $900 for rent.

In the money owed view for May 2007 we can see that since we all shared the $900 rent, and there are three of us, we each pay $300. Since I paid for the rent out of my own pocket and $300 of it is my share, I am owed $600. Since I am the manager I so not get displayed in the list but you can see how much I am owed in the text at the bottom.

To show you how the program can handle any expense by any person lets create a payment that wouldn’t normally factor into the monthly costs of a house. Rody bought some pizza one day for $30 and Eric ate some too. Normally it would be easier for Eric to just give Rody $15 in cash, but if we just create a new payment of $30 that is paid by Rody and shared by Eric and Rody it will all get consolidated into their end of the month payments.

Now we go back to ‘Money Owed’ view and we can see that under ‘Paid This Month’ for Rody is says $30. Also notice that since I was not involved with the pizza transaction I am still owed a total of $600. The only difference is that $15 has been added to how much Eric owes and $15 has been subtracted from how much Rody owes. This is effectively a $15 payment from Eric to Rody. In a similar way this program works really well even for people who don’t live together but who visit a restaurant as a group and only one person picks up the bill.

You may also notice the error value in the bottom right corner. All math is performed using the Python decimal module so that there are no binary representation errors when storing the values as floats, but there will still be some error when you divide a $20 payment by 3 people. However the error should never be more than a cent.

The program is written in Python its dependencies are:

  • PyGObject (for event notification)
  • PyGTK (for the GUI)
  • Python Glade2 (for loading the GUI)
  • XML Minidom for Python (for loading and saving files)
  • Python decimal (for base-10 math)
  • Python datetime module (for date calculation)

That’s it for now folks. If you want to use this program or even improve it, just drop me a line, or leave a comment on this page. I would love to hear from you if anyone finds this as useful as I do. You can download the Python source to run or to change the program (please send me patches). As always the code is licensed under the GPL.

I just finished writing my money managing applicat…

Posted in FOSS, Python on May 9th, 2007 by admin – Comments Off on I just finished writing my money managing applicat…

I just finished writing my money managing application which I will post on my blog soon. This application has five separate views that can be switched in the main window like the “workspaces” in Jokosher. However I didn’t want to restrict myself to only looking at one of these views at a time, so I put in the option to create a new window that does not have any toolbars or menus, just the view switcher. This means that there could be any number of GUI instances looking at my program’s model at the same time. There could be two copies of the same view and when one is updated and other one has to reflect the changes.

I have implemented my listener code using Python’s GObject bindings so that all the views can know when a signal is emitted on the model. However if there are many views all running at the same time, sending a GObject signal takes a long time. If a signal is sent in response to a button being clicked, the button will stay pushed down for a few seconds while it waits for the signal emission to return. This makes the application look slow and unpolished. I decided that it doesn’t matter if not all the views are updated immediately; I’d rather have the button come back up and then have everything update. So I made this little class to do exactly that:

import gobjectclass AsyncGObject(gobject.GObject):       def __init__(self):               gobject.GObject.__init__(self)

       def emit(self, *args):               gobject.idle_add(gobject.GObject.emit, self, *args)

Just subclass this class instead of gobject.GObject and all your signals will be asynchronous.