[Tutor] passing widgets

alan.gauld@bt.com alan.gauld@bt.com
Mon Mar 10 12:40:19 2003


> If I want a textbox to display the input and output
> from several other functions, must I pass it around as
> a parameter or is it better to make it global? 

Thats the advantage of iusing an OPOP approach. If the 
text box is a member of the same class as the callback 
functions(or more correctly callback methods) then the 
methods can see the widget as self.textbox...

Kind of like a controlled global variable.

Indeed you could even instantiate several such 
classes and each would write to its own textbox.

> always been taught to minimize the amount of global
> objects, but when is it warranted? 

If its only ever going to be a single textbox then global is probably ok.

In general the class approach is better IMHO.

Alan G.