Example of Prerferences usage?

Asked by estiedi on 2010-07-12


First of all thanks for this great product! I'm sure this will help a lot of developers to develop for Ubuntu.

I'm actually helping a non-profit organisation to make the move to Ubuntu and one problem is the MS Access applications.
I've started to rewrite one Access application using Python, but I'm new to Python (coming from Java & C/C++) and still need to find my marks. The idea is that re-development must be quick (i.e. inexpensive). Quickly is a great booster for that, but I'm kind of stuck with the Preferences dialog. Is there an example how to use this somewhere? Or could someone explain me in a couple of words how to do it?

1. Make the Glade interface of PreferencesMyAppDialog
2. Declare the preferences data in _load_preferences(self)
3. Bind the preferences to the UI?

Question information

English Edit question
Quickly Edit question
No assignee Edit question
Last query:
Last reply:


First, I am really really sorry that working with the preferences is so hard. This is totally my fault, and I'd really like to make it actually easy at some point when I have time.

There is code that uses preferences in the Bug Hugger project. This is probably a good starting place, because they are simple.

You can get the project here:

I think the boiler plate code for preferences has changed somewhat, but if you don't want to pull it from lp, you can just look at it here: http://bazaar.launchpad.net/~bughuggers/bughugger/main/annotate/head:/bughugger/PreferencesBughuggerDialog.py

Basically, what you do is:

1. set some default preferences in __load_preferences by using a dictionary. This function will either use the defaults, or it will use what is stored in desktopcouch for the preferences.
2. in finish_initializing you set the GUI based on what is the in the preferences dictionary.
3. in the ok function, you update the values in the preferences dictionary based on what is in the GUI, and then the ok function sames them for you.

So Bughugger preferences have two preferences, "use_production" and "auto_connect". Due to my extreme laziness, I just create checkboxes on the fly for them. For more complex preferences you would probably read them a do a bit more fancy pants stuff setting text boxes and such.


And btw, thanks a million for giving Quickly a try, I really hope it work out well for you and your non-profit. If you have any other questions, you can often get help in irc using #quickly, or #ubuntu-app-devel. Depending on who's online, you can sometimes get quick responses that way.

Cheers, Rick

Can you help with this problem?

Provide an answer of your own, or ask estiedi for more information if necessary.

To post a message you must log in.