Python vs. Tcl implimention question/comparison.

Richard Chamberlain richard_chamberlain at ntlworld.com
Wed Aug 23 02:44:51 EDT 2000


Hi Chuck,

If you bind an event, instead of having the callback in the options, you
get information back in an object.

for instance (psuedo-code):

def myEvent(event):
	print event.widget
	print event.widget.master

button.bind('<Button>',myEvent)

If you look for the message unanswered questions in python.faqts.com
I've given a short script which demonstrates this.

Richard

Chuck Meyers wrote:
> 
> I prefer Python to Tcl, it has many advantages I'm sure you are aware
> of.
> But I have come across a case where it seems that Tcl has a much cleaner
> 
> solution. I want to add a context sensative HELP to my GUIs. One way to
> do
> this is to generate a binding to all widgets that calls a HELP procedure
> 
> passing the calling widget name. In Tcl you have the %W variable to pass
> 
> as a parameter, thus you only need to add a few lines of code and all
> widgets have HELP. You need to maintain the HELP procedure that gets
> called,
> but when making widgets you can ignore the fact that HELP exists. In
> Python it seems the best solution is to have a global variable that
> contains the calling widget name, but setting it would mean you would
> have
> to explicitly add code to each widget binding.
> 
> Another Tcl advantage is the naming convention. The %W name tells you
> the
> parents name, so if help is not available for the widget, you could
> search
> for help for the parent widget.
> 
> Is there a clean way to get the widget name and parents names in Python
> without having to add code to each widget?



More information about the Python-list mailing list