http://www.perlmonks.org?node_id=11111021


in reply to Tk (Tcl::Tk) programmatically monitor change in Listbox

You will need to subclass Tk::Listbox and override the relevant methods.

Trapping programmatic changes to the UI is probably a bad idea, however, and you should arrange for a notification to be processed by some other means. Tk works very well as the "V" in "MVC", so you will probably get much cleaner code if you have a method in another object that represents whatever the listbox choices are. Preserve that separation and your code will be easier to maintain. Right now, your code seems to be headed towards "tissue of hacks" and Big Ball of Mud.

Sadly, Tk does not appear to have a mechanism for passing generic program-generated events to callbacks.