[pygtk] Using a CheckButton on an applet Menu

Adolfo González Blázquez agblazquez at telefonica.net
Fri Apr 7 20:31:19 WST 2006


Ok, so adding the CheckButton to he menu was really easy... just needed
to add type="toggle" to the .xml menu definitions. Something like this:

<menuitem name="Alarm" verb="Alarm" _label="_Enable alarm?"
type="toggle"/>

Now, what I need is a way to get the events thrown by this menu entry,
'cause adding the callback to verbs list doesn't seem to work.

In C, people use something like:

component = panel_applet_get_popup_component (PANEL_APPLET (applet));
bonobo_ui_component_set_prop (component,
                                "/commands/Mute",
                                "state", mute ? "1" : "0", NULL);


get_popup_component seems to exist on python-desktop, but i can't find
any documentation about this... If anyone could explain or help a bit
with this, i will really appreciate it.

Thanks!

-- adolfo

El vie, 07-04-2006 a las 03:23 +0200, Adolfo González Blázquez escribió:
> Hello,
> 
> I'm writing a gnome applet using pygtk, and I need to add a CheckButton
> to the applet menu (something like the play item on rhythmbox tray icon
> context menu).
> 
> To create the applet menu, i use the method 'setup_menu' [1], which
> comes in the 'applet' module from python-desktop.
> 
> What I need is a way to change the menu item from check activated to
> deactivated when clicking on it.
> 
> The menu creating code is:
> -------------------------------------------
> self.verbs = [("Alarm", self.menu_alarm_toggled), 
> ("Log", self.menu_log_toggled), 
> ("Prefs", self.prefs.preferences_show), 
> ("About", self.about_info)]
> 
> self.applet.setup_menu_from_file (glob.resources_dir,
> "laptoptemp_menu.xml", "laptoptemp", self.verbs)
> -------------------------------------------
> 
> The .xml file for the menu is:
> -------------------------------------------
> <Root>
> 	<popups>
> 	<popup name="button3">
> 		<menuitem name="Alarm" verb="Alarm" _label="_Enable alarm?"
> pixtype="stock" pixname=""/>
> 		<menuitem name="Log" verb="Log" _label="_Enable logging?"
> pixtype="stock" pixname=""/>
> 		<separator/>
> 		<menuitem name="Prefs" verb="Prefs" _label="_Preferences"
> pixtype="stock" pixname="gtk-properties"/>
> 		<menuitem name="About" verb="About" _label="_About" pixtype="stock"
> pixname="gnome-stock-about"/>
> 	</popup>
> 	</popups>
> </Root>
> -------------------------------------------
> 
> 		
> Thanks in advance for any help!
> 
> -- adolfo		
> 
> [1]
> http://developer.gnome.org/doc/API/2.0/panel-applet/panelapplet.html#PANEL-APPLET-SETUP-MENU
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada
	digitalmente
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20060407/fad91807/attachment.pgp


More information about the pygtk mailing list