Python booleans in gconf with pygtk Message dialog

A small Python Script I use on my VM with GNOME-2 to prevent myself from deleting one of the Desktop Panels by accident. In GNOME 2 you can lock/unlock this panels by editing a GConf schema so you can avoid a wrong selection whenever you launch the right click menu to customize this widgets.

The script creates a Gtk Message Dialog with the options “Yes” or “No”. In my case, I made an executable icon (.desktop file) for this script and placed it into the bottom panel so it can be easily accessed.

You can also modify this script very easy if you want to try it with a different Gconf Setting by replacing the global variable for the schema and/or the string values.

#! /usr/bin/python

import gtk, gconf

KEY = "/apps/panel/global/locked_down"

class Switcher(gtk.MessageDialog):

    def __init__(self):
        client = gconf.client_get_default()
        value  = not ( client.get_bool(KEY) )
        state  = "lock down" if value else "unlock"

        gtk.MessageDialog.__init__(self, None, 0,
                                  "Gnome Panels Lock")
   "Are you sure you want to %s Gnome Panels?" % state)

        if == gtk.RESPONSE_YES:
            client.set_bool(KEY, value)
if __name__ == "__main__":


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s