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:

  1. What are the reasons to keep the design the way I have it?
  2. What are the reasons to switch to pTk managed events?
  3. Should I be considering an entirely different approach that I did not outline above?
  4. Can you recommend any good resources on GUI and/or event driven style of programming?


TGI says moo


In reply to Perl Tk - propagating events by TGI

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.