On Thu, Oct 14, 2004 at 04:24:17PM -0500, Skip Montanaro wrote:
> I have an option menu full of radio menu items defined via Glade.  At
> runtime I'd like to get a string value out of the menu which
> corresponds to the selected item.  The displayed label would be fine
> (I'll force it to be unique) but I can't figure out how to get at it.
> I'm trying to avoid enumerating all the menu item objects in my code
> (e.g. wtree.get_widget("menu-item-N")), preferring instead to leave
> all those definitions to the glade user.

Johan's suggested the FAQ, and that's full of warnings that should be
heeded. One alternative which I use daily is, instead of relying on the
label, doing a set_data() on the menuitems as you put them into the
menu, and then using get_data() to grab it back. I can get example code
if that's not clear enough.

There's one catch -- you can't use None given get_data() returns None by
default; just use a ValueUnset dummy class to work around that, though.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to