Re: [pygtk] Storing data in OptionMenu Menuitems



On Thu, 5 Jul 2001, Christian Robottom Reis wrote:


I've found out the hard way that Optionmenu stores Menuitems! Now I'm
wondering if there's a way to attach data to a menuitem in the fashion we
can attach data to a clist row?

If there is no way, it makes us keep a private data structure that is
indexed by the current optionmenu's index (which I can get through the
menu's history). This is doable, but a bit awkward. Has anyone a better
idea than this?

menu items are GtkObjects.  If you are using the 2.0 binding, you can just
set attributes on the object (menu_item.foo = bar).  For the 1.2 binding,
you should use the set_data method (menu_item.set_data('foo', bar)) and
use the get_data() method to retrieve it.

James.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]