[pygtk] Reloading menus dynamically

Nemesis nemesis2001 at gmx.it
Sun Aug 27 17:46:36 WST 2006


Hi all,
I'd like to dynamically update the menus of my application, the only
thing that really changes are the shortcuts cause I'm implementing a
system that let you customize the shortcuts.

I use this code to connect the action to the ui description


        self.ui = gtk.UIManager()
        self.accelgroup = self.ui.get_accel_group()
        self.actiongroup= gtk.ActionGroup("MainWindowActions")
        self.window.add_accel_group(self.accelgroup)
        mscuts=load_shortcuts("main")
	...
        self.actiongroup.add_actions([action])
        self.ui.insert_action_group(self.actiongroup,0)
        self.merge_id = self.ui.add_ui_from_string(ui_string)
        self.ui.ensure_update()  


the shortcuts are loaded with the function load_shortcuts.

I tried to simply recall this function after having updated the
shortcuts but it doesn't work very well.
It adds new shortcuts, but the shortcuts that were already assigned
(and I changed) doesn't change.

I thought that maybe I'm only adding and mergin new actions so the old
ones are still active so I tried with various things like
ui.remove_action_group
self.actiongroup.remove_actions
ui.remove_ui

but without success.

Which is the correct way to update shortcuts dynamically?
-- 
 
 |\ |       |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org


More information about the pygtk mailing list