TGI has asked for the wisdom of the Perl Monks concerning the following question:
I have a fairly big application with a pTk interface. While writing this app, I began to wonder if I was doing the "right thing" when I designed the way different bits communicate.
The application is broken into several distinct interfaces, each has a "Manager" object that handles a specific set of related UIs, for example I have a DisplayManager that handles the details of creating and controlling various screens that display data, I also have a ConfigurationManager that handles the presentation of configuration screens. Each manager collects input from its children and then operates on the back-end objects, mostly through registered callbacks or eval-ing standard methods on child objects.
sub UpdatePanels { my $self = shift; my $net = $self->network; my @sensors = $net->sensors; my @display_objects = ( @{$self->display_objects} ); foreach my $display ( @display_objects ) { eval { $display->UpdatePanel( $self->session_state, @sensors ); }; warn $@ if $@; } } # END UpdatePanels
After further reading and experimentation, it seems to me that a better design might be to use Tk's event system to pass information.
sub UpdatePanels { my $self = shift; $self->eventGenerate('<<UpdatePanels>>'); }
Of course, I would need to create the UpdatePanel virtual event and bind a callback for each display object for this to work.
What I would like to know is:
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Tk - propagating events
by renodino (Curate) on Jun 15, 2006 at 04:12 UTC | |
by vkon (Curate) on Jun 15, 2006 at 08:39 UTC | |
by renodino (Curate) on Jun 15, 2006 at 15:05 UTC | |
by vkon (Curate) on Jun 15, 2006 at 15:55 UTC | |
by TGI (Parson) on Jun 15, 2006 at 18:11 UTC | |
|
Re: Perl Tk - propagating events
by zentara (Cardinal) on Jun 15, 2006 at 10:31 UTC |