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.

Thanks Steve

Posted in Just another day on the web on April 2nd, 2007 by admin – Comments Off on Thanks Steve

Many of us doubted him back when he said he truly wanted to get rid of DRM. I was especially harsh when I told people his essay was just a load of crap designed to make the Apple customers feel like they are not doing harm to this world by supporting DRM. Another criticism was that he didn’t let independent labels put DRM-free MP3s on the iTunes Music Store. But now he has put his money where his mouth is. Thank you Steve, and congratulations to everyone who has been fighting for this.

BarCamp in Ottawa

Posted in Event, FOSS on March 29th, 2007 by admin – Comments Off on BarCamp in Ottawa

There’s not a lot of these tech or open-source conferences in my area. The only ones I can list off the top of my head are the Ottawa Linux Symposium (but that’s only hard core kernel stuff) and the Desktop Developers Summit, and both of those cost quite a bit of money.

So I get really excited when some cool, free (as in beer) and collaborative conference happens. This Saturday there will be a BarCamp at my university. In fact it will be in the same room I had linear algebra in only two hours ago. Usually I wouldn’t look forward to going to school at 8:30 (!) on a Saturday morning, but this is a special occasion. I don’t think any one in Ottawa will read this, but if you are from Ottawa put a comment on my blog so I at least know you exist. The details and schedule are on the BarCamp wiki.

Laszlo's Law of Urban Transportation

Posted in Uncategorized on March 22nd, 2007 by admin – 1 Comment

Behind programming and linguistics/syntax, planning urban transportation is my third favourite intellectual activity. This is of course why a spend a few days last year researching and designing a subway system for Ottawa. In no way is there sufficient population density in this field of urban sprawl they call the nation’s capital to make a subway cost effective, but it is still an exercise I enjoy. Trying to find the optimal routes for a number of subway lines it kind of like solving the travelling salesman problem. There are many close-to-perfect answers that are easy to find and only one perfect answer that is impossible to find, but the challenge of trying to get as close as possible is fun.

This week I have been researching flights and train voyages to get to LugRadio Live in Wolverhampton this summer. The trick is finding the fastest and cheapest route from Ottawa to Wolverhampton. Even though Ottawa is the capital, it is quite small and so the only direct flights to the UK from here go to London Heathrow. That would mean I would have to get off the plane after a 7 hour flight and get on the train for another 2.5 hours. If I want to get a plane to Birmingham or Manchester I will have to transfer in Toronto, Montreal or London Heathrow.

For $50 I could take the bus to Toronto, but the bus terminal is downtown, and the airport is 30 minutes west of the city with no rail links. Also for $20 I could take the bus to Montreal – at least there they have rail access to the airport. If I decide to transfer in London I would be able to easily take the tube to any train station which would lead me to Wolverhampton. I love the Tube. Travelling to London scores high on my list because of it as you’ll see below.

Okay finally on to the real reason for this article. I present Laszlo’s Law of Urban Transportation:

“The quality of urban transportation planning in any given city is directly proportional to the time it takes to get from the main passenger airport, to the main passenger train station, and from there to the city centre and back to the airport.”

In the paragraph above, train station can be replaced by bus/coach terminal and the law will still hold. You should notice that I didn’t specify the distance but instead it should be measured by time. This is because for big cities there is no option. The new Hong Kong airport is really far away from the city because with mountains on one side and the ocean on another, there isn’t much room. However there is a high speed train which will still get you to the airport in 24 minutes. This is about the same or maybe even less than Ottawa who’s airport is quite close to the city.

You should also notice that I didn’t exclude taxis or even specify that it must be public transportation. You could probably increase the ranking of a particular city by taking a taxi and shortening the time it takes to complete the airport-train-downtown loop. This is only because in some cities this is the only way. In Prague there are three subway lines that go north, south-west and south-east. Unfortunately the airport is a 20-30 minute taxi ride due east.

From what I have seen and guestimated so far, the cities that have the shortest airport-train-downtown loop are Geneva, Switzerland and Sydney, Australia. I have been to Geneva and I remember that the train station is a short walk from downtown and for a few Euros you can take a 5 minute train ride to the airport. Of course they had to put the airport close because of all the damn mountains. I suspect the same is true with Sydney but I have never been there. Based on looking at Google Maps, it seems that the airport is 4km from the train station and the train is only 1 km downtown. Way to go Sydney.

My Year In Review

Posted in FOSS, Jokosher on December 23rd, 2006 by admin – Comments Off on My Year In Review

At the beginning of this year I was sitting in my dorm room listening to LugRadio, thinking about how awesome the open source community was and how much I wished to be a part of it. Up until that time my entire open source contribution amounted to a few patches and bug fixes with Amarok. I imagined what it would be like to help out the community, get kudos from everyone online, and piss my pants laughing with the dudes from LugRadio.

It’s not that I couldn’t contribute. I had two years of Java experience from high school, but I had no idea how to do C++ so I struggled when trying to make a difference hacking on Amarok. I also went the Ubuntu Breezy Summit in Montreal and tried to join the Ubuntu Documentation Team, but I didn’t have the initiative to start writing something on my own. It seemed much too difficult to start contributing even though I had novice programming skills.

In March 2006, Jono mentioned on LugRadio that someone had started the code for his JonoEdit idea. He also mentioned that they desperately needed contributors to write code in Python, and that everyone should come on board now while the code was small and easy to learn. I already knew Python and it was my favourite language, so I took his advice.

I only mention this now because back then I never would have thought that in less than a year I could go from writing useless Python scripts on a Saturday morning, to being hated and envied by the massively hilarious dude I hear every second Monday morning. In my book, that’s quite an accomplishment.

I guess my point is that no matter how hard you have tried to contribute and integrate yourself into a new community, and no matter how many times you feel like you have been rejected, all you have to do is keep moving until you find your passion and it will be smooth sailing after that. It turns out my passion is programming in Python, and now I’m responsible for a large part of Jokosher.

Find Out Your Free Software Index

Posted in FOSS on November 26th, 2006 by admin – Comments Off on Find Out Your Free Software Index

There has been a lot of talk lately about Ubuntu Feisty including non-free components by default. While I believe that non-free is bad, the Ubuntu guys have the chance to make the situation a lot better for new users. Currently new Linux users who depend on hardware that only has proprietary drivers will blame Linux for not working with their system. There is no way to tell the user that if they bought hardware with open drivers it would work. Instead they are just left in the dark and the new user comes away with a bad impression of Linux.

I’ve heard a lot of people say that if we educate people about free software then they will understand the difficulties we are having and can make the right choice next time they buy hardware. They may still use binary drivers, but at least they will be using Linux, and a few small steps in education can go a long way.

If you have been following Windows Vista, you may know that it will include a feature called “Windows Performance Index”. This is supposed to give the user a single number that represents the capability of their system. This is especially important now that Intel has decided to stop putting megahertz numbers in their chip names. If it can be boiled down to a single number, it will be a lot easier for the average user to understand. Here is a screenshot of this feature in action.

My idea is to do the same thing except for free software:

As you can see, at the top of the window there are links to help pages that discuss various issues about free software. Then there is a list of all the known software packages installed on your system that have restrictions of any kind. Beside that is a gigantic number which is your Free Software Index. Right now its just the number of packages you having installed, but there could be different values for packages with patent vs. non-free issues and drivers vs. regular software. At the bottom there is a refresh button, which would search for more non-free software and a close button.

You could also have a button next to the package names which describes what it does, and what (if any) free equivalents are available, as well as an uninstall button for each package. This would be awesome to see in the next Ubuntu so that if it comes with non-free software by default, you could quickly know which packages they are, decide if you absolutely need them, and quickly uninstall them if you don’t.

Jokosher 0.2 Released

Posted in Jokosher on November 20th, 2006 by admin – Comments Off on Jokosher 0.2 Released

After the gigantic Jokosher pimpfest that was the Ubuntu Developer’s Summit, Jokosher v0.2 has been released, and #jokosher on irc.freenode.net is swarming with Ubuntu folk trying to jump on the bandwagon and compile gstreamer CVS as fast as possible. Thankfully for the Ubuntu users, this is rather simple because of Aq’s wonderful script which will download, and compile Jokosher and Gstreamer CVS all in one step. You can download Aq’s script, or the source tarball from the download page.

There are lots of new features and improvements over v0.1, the most important of which is that it doesn’t suck anymore, and you can actually accomplish useful things. Also we have support for third party extensions a la Firefox, so if anyone wants to write one (there are examples included with the release), or help improve our cool API, give us a shout.

Finally, I have managed to get all the Jokosher dependencies for w32 with the exception of one — Gstreamer — which also happens to be the most important dependency. I am definitely not looking forward to intalling all the Gstreamer build dependencies on Windows. If Gstreamer people knows a better way, or if this is at all feasible, please let me know.

Is it not the case that one person could build Gstreamer for w32 and then just copy the folder to any other windows computer? I mean it’s all binary compatible right? If I do ever get it built, then we could just tar-up the entire directory with Gstreamer and Jokosher and make that the w32 version. It would be about 100 times the size of the Linux tarball, but it would be worth it.

Beautiful i18n Graphics Part 2

Posted in GTK, Jokosher on October 20th, 2006 by admin – 2 Comments

Last week I discussed how nice it would be to have graphics in your application use gettext to translate all the strings in the image, and render a localized version on screen. I showed how this would help usability, and improve the overall look and feel of the desktop. I also discussed several ways to accomplish this, many of which would require cooperation from various libraries.

I decided that if I wanted to get it done, I a) had to do it myself, and b) would have to do it programmatically on a case by case basis to ensure that things like text wrap or overflow are handled uniquely for each image. Here is the original image that Jono made using the Gimp:


Now here is a rendering of my GTK widget which uses Cairo to try and accomplish the same thing:


As you can see the images are identical with the exception of the font. Currently I am using cairo.show_text() in Python. However in the cairo reference manual it says:

NOTE: The cairo_show_text() function call is part of what the cairo designers call the “toy” text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for the most serious of text-using applications. See cairo_show_glyphs() for the “real” text display API in cairo.

However Cairo does not provide a way to get font glyphs, and documentation says that you must get the glyph yourself. Being a person who doesn’t know anything about how glyphs are stored, or how to get them in C (let alone Python), I’m kinda stuck.

If anyone has an example of how to make text beautiful with cairo_show_glyphs(), or any idea how to do glyphs in Python, please let me know!

Beautiful i18n Graphics

Posted in GTK, Jokosher on October 13th, 2006 by admin – Comments Off on Beautiful i18n Graphics

A while back I submitted a bug to Tango, because the word processor icons for bold, italic and underline were a bold, italic and underline ‘A’ respectively:

I wrote in the bug that, like almost everyother word processing application I had ever used, the icons should be a bold ‘B’, an italic ‘I’ and an underlined ‘U’. The response to my bug was that to be fair to every language that the application supports, and to avoid making a new icon set for every language, they decided to use ‘A’ for all three icons. In reality however, I would imaging that a Japanese or Russian user might be confused by the latin character in the icon. So in every case, this is suboptimal.

One of our primary goals for Jokosher v0.2 is internationalization support. Like everyone else, we now use gettext. Another one of our goals is LADSPA effects support. In fact, Jono was so excited about implementing audio effects, he made this beatiful banner which sits at the top of the instrument effects dialog:


It goes without saying that images like this one make Jokosher a much prettier application, and benefits the overall user experience. We could also use different colours for the images at the top of different dialogs so people could easily remember which part of the application they are in. This would be more useable than the current state of all the buttons and dialogs looking identical. In fact this is one of the demos that was given when Cairo came out; many buttons on the screen each with their own random variation generated at runtime. Now computers are fast enought that we can use SVG and Cairo to do fancy vector graphics on the fly. Jokosher uses both, and we really like the results.

As soon I saw the intrument effects image Jono did, I told him two things: “That looks awesome!” and “It’s not going to work, and you’ll have to get rid of it.” The second of course refers to the fact that i18n is now a priority for Jokosher, and that image has English text in it. Now we have a problem.

Luckily this problem can be easily solved by using gettext and rendering the image at runtime. In other words, librsvg + gettext = awesomeness. One very hackish way I thought of to do this was loading the SVG as text, doing a quick find of all fields, replacing them using gettext, and then feeding the altered XML into librsvg. I’m not sure if this would work. Nor am I sure if the SVG specification has a translatable=”yes” tag like in glade XML. If not, there could at least be a switch somewhere which would make librsvg treat every string as translatable and call gettext, in exactly the same way glade does!

This would unleash awesome new possibilities to make GTK apps the most beautiful ones known to man. And it would help usability too, by allowing the bold, italic and underline Tango icons to use the user’s native alphabet and character set. If anyone has any other ideas for how to accomplish this, please let me know. I really don’t want to have to take the instrument effects image out of Jokosher 0.2.