in reply to OO circularity
I tend to put the Tk object itself, and widgets that I know I'm going to have to twiddle, in a hash called something like %tkObjects, and pass that to any piece of code that requires GUI update functionality. If you're coding from an OO perspective, you can make that hash an attribute of an object, and consider that the object 'has a gui'. You then end up with code that looks like:
sub update_button { my $self = shift; my $buttonobj = $self->{tkobjects}->{submitbutton}; $buttonobj->#do something with the button }
From a non OO point of view, you might consider that your subroutines are doing two things: doing the necessary processing, and updating the GUI.
That technique is on dodgy ground for the principle of narrowest scope for variables & objects, but conforms with laziness and impatience nicely :)
Alternatively (and I hate myself for saying this), you could make certain very carefully chosen objects global.
I'm certain there are better ways, but those are the two I've used.
Update: You could also put all the GUI construction and update in one place, and update the UI according to the return values of subroutine calls. That way is perhaps neater from a design point of view, but can rapidly end up with a really huge main gui function that's difficult to maintain. So thats a third, equally vile, approach that I've tried.
--------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".
|
|---|