How do you set custom data to a wx.MenuItem similar to TreeCtrl's
SetPydata command.
When you are building a complex hierarchical menu using a directory
structure, it would be great to associate custom data to a menuitem
that can be fetched in popup event.
How do you set custom data to a wx.MenuItem similar to TreeCtrl's
SetPydata command.
When you are building a complex hierarchical menu using a directory
structure, it would be great to associate custom data to a menuitem
that can be fetched in popup event.
Thanks
Prashant
Python 2.6.2
wxPython 2.8.10.1
XP 32
I'm not sure if wx supports this, but you could maintain a dictionary, like so:
On Jan 9, 11:29 am, King <animator...@gmail.com> wrote:
Thanks,
Yes, I am using dictionary method but "SetPyData" is more
pythonic.
Prashant
Python 2.6.2
wxPython 2.8.10.1
XP 32
Well, you can subclass the menu and add that method to your menu (I
think). The method could then use the dict code that you and Steven
are talking about.
Menu items don't support attaching extra data values to the item. Although they may be able to be made to do so, it would be *lots* more complex than just maintaining your own ID --> data object map.
···
On 1/9/10 1:19 AM, King wrote:
Hi,
How do you set custom data to a wx.MenuItem similar to TreeCtrl's
SetPydata command.
When you are building a complex hierarchical menu using a directory
structure, it would be great to associate custom data to a menuitem
that can be fetched in popup event.