[pygtk] passing data to actions invoked by popup

N. Volbers mithrandir42 at web.de
Fri Mar 31 03:06:15 WST 2006


Hello everyone,

in my applications I have different tool widgets, very similar to the 
dockable tools in gimp, and they all have a button at the top-right that 
opens up a popup menu when pressed. This popup allows to add other 
tools, so for this reason, the popup is always the same.

Unfortunately, this means that since every popup is the same, the 
corresponding actions are always the same as well. There seems to be no 
way to know from which tool instance the popup was called. So my 
question is: Is there any way to add certain extra information when 
popping up a menu, so that when an action is triggered, this extra 
information is passed on to the callback ?

My current solution is rather ugly: Before calling menu.popup, I set a 
global variable to hold this extra information, so that the callback can 
retrieve it.

Niklas Volbers.





More information about the pygtk mailing list