Friday, November 21, 2008

pygtk Recent File Chooser

I have started working on a new opensource project, using pygtk and Python (details on the project at a later stage). I wanted to add the ability to select recent files from the main menu. While pygtk provides classes to enable this (RecentManager, RecentChooserMenu), I couldn't find any code examples. So here is an example that adds a Recent Files submenu to a menu item.
The code assumes there is an existing menu item 'self.mnuRecent' that the recent files sub menu will be attached to.


#Add a recent projects menu item
manager = gtk.recent_manager_get_default()
#define a RecentChooserMenu object
recent_menu_chooser = gtk.RecentChooserMenu(manager)
#define a file filter, otherwise all file types will show up
filter = gtk.RecentFilter()
filter.add_pattern("*.avi") #set this to whatever file type you want
#add the filter to the RecentChooserMenu object
recent_menu_chooser.add_filter(filter)
#add a signal to open the selected file
recent_menu_chooser.connect('item-activated', self.recent_item_activated)
#Attach the RecentChooserMenu to the main menu item
mnurecent = self.mnuRecent
mnurecent.set_submenu(recent_menu_chooser)

##

def recent_item_activated(self, widget):
"""Activated when an item from the recent projects menu is clicked"""
uri = widget.get_current_item().get_uri()
# Strip 'file://' from the beginning of the uri
file_to_open = uri[7:]
#code here to open the selected file

## In your code where you open a file, you need to add the file to the recent items manager

manager = gtk.recent_manager_get_default()
manager.add_item('file://' + file_uri)


Hopefully someone will find this example useful.

phoNIX Beta

In my previous post I mentioned the educational software I have been developing, phoNIX. This has now reached beta release status, and is available for download at the project website.

Tuesday, July 15, 2008

Developing software for Ubuntu

By day, I am a software developer. OK, software developer is a bit grand, but I work in the development department for a fund manager, developing reports, applications, SQL etc., all on Windows.

After running Ubuntu for some time now on my home machines (desktop, laptop & file server), I have been keen to try developing for Ubuntu/Linux. Python is a popular language for developing Linux applications so I decided to try and learn python by creating some applications.

The trouble is trying to think of something worthwhile to develop. My first attempt, a media cataloguing application, started off quite well and taught me quite a lot about developing in Python & GTK. However it became obvious that there was already a very good solution out there, so not wishing to reinvent the wheel, I stopped working on that.

My next idea for an application came about while looking for some software for my young children. At school, they use the Phonics system of learning to read and write. I was looking for some phonics software that ran on Linux but couldn't find any - so I thought I would create my own.

So that is what I have been doing for the last month or two. The application is nearly finished, the only thing remaining is to record the sound samples it will use. I have setup a website dedicated to this (free, open source project) at http://phonix.org.uk.

Thursday, May 08, 2008

Upgrading Ubuntu 6.06 LTS to 8.04 LTS

My Music/File server has been running 6.06 for some time. Now that Ubuntu 8.04 LTS is out, it would soon mean an end for security updates for 6.06, so it seemed like the right time to upgrade to the most recent LTS version.

The upgrade itself ran smoothly, although a bit slowly (the server runs on a VIA 1.2 Ghz processor, so no surprise there).

What did fool me though, was that during the upgrade Slimserver was uninstalled. I didn't notice any messages about this during the upgrade. After trying to connect to Slimserver via a browser, it was apparent that it wasn't running. Trying to start the Slimserver service resulted in a load of errors. The confusing thing was that although it had been uninstalled, there were plenty of Slimserver files left behind, which made it look as if everything was still there.

After about an hour and a half of messing around I found a post on the Slimserver forums which stated that Slimserver was uninstalled after upgrading to 8.04. Once I knew this, it was easy to download the Slimserver deb and install it again. Fortunately all my previous plugins and settings had been left untouched, so I didn't have to set it up all over again.

That leaves me with two other machines to upgrade (desktop and laptop), although there is no hurry for them as they both run 7.10 so are still getting updates.

Tuesday, January 22, 2008

Do the BBC make it up?

Compare the squad published by the BBC in their preview of tonights Semi-Final against Tottenham:

As published by the BBC:

Arsenal (from): Fabianski, J Hoyte, Gallas, Senderos, Traore, Diaby, Denilson, Gilberto, Eduardo, Walcott, Bendtner, Mannone, Sagna, Rosicky, Randall, Gibbs, Lansbury, G Hoyte.


As published by Arsenal:

DIABY, SAGNA,
FABREGAS, EDUARDO, GALLAS, HLEB, DENILSON, FLAMINI, GILBERTO, FABIANSKI (GK), ADEBAYOR, BENDTNER, TRAORE, HOYTE, WALCOTT, MANNONE (GK)

Friday, January 11, 2008

What's happened to Usmanov?

Usmanov hasn't bought any shares for a whileHas Usmanov given up in his pursuit of Arsenal shares? There have been no trades in Arsenal shares since 17th December, where previously trading had been taking place on most days.

He may have reached the limit on who was prepared to sell, as there are still plenty of hard core supporters who have small shareholdings. The Arsenal Supporters Trust has also recently backed the Board's lockdown agreement, meaning there aren't that many potential sellers left.

Or maybe he has just lost all his wealth in the recent credit crunch ;->