I have a similar program created. The main.pl creates a window with shortcuts to different "reports" that may connect to a web server and download information or create a file from information on the local disk. Each report is it's own object - and may be of their own classes, but they all have a new and a create method and whatever else they need to do their assigned work.

Here is an example of what this looks like (not my actual code, and probably doesn't run, but it should give you and idea). The progress bar is created in the main script, and then a reference to it passed to the report objects that want to update it.
use warnings; use strict; use Report; my $window = Gtk2::Window->new; $window->set_title('Main Window'); $window->signal_connect('delete-event' => sub {Gtk2->main_quit}); my $vbox = Gtk2::VBox->new; my $bbox = Gtk2::VButtonBox->new; my $b1 = Gtk2::Button->new_with_mnemonic('_Report'); $b1->signal_connect(clicked => \&create_report); my $b2 = Gtk2::Button->new_with_mnemonic('E_xit'); $b2->signal_connect(clicked => sub {Gtk2->main_quit}); my $progress = Gtk2::ProgressBar->new; $bbox->add($b1); $bbox->add($b2); $vbox->add($bbox); $vbox->add($progress); $window->add($vbox); $window->show_all; Gtk2->main; sub create_report { my $dialog = Gtk2::Dialog->new; $dialog->set_title('Report Parameters'); # create the buttons and the content fields my $entry = Gtk2::Entry->new; $dialog->vbox->add($entry); # create the dialog action-area # run the dialog, get the response my $response = $dialog->run; $dialog->destroy; # return if user canceled return undef unless $response eq 'ok'; # create the report my $report = Report->new(parameter => $entry->get_text, progress_b +ar => $progress); $report->create; } package Report; use Gtk2; sub new { my ($class, %args) = @_; my $self = bless \%args, $class; return $self; } sub create { my $self = shift; # do stuff # update the progress bar $self->{progress_bar}->pulse; # required to see the change in the progress bar Gtk2->main_iteration while Gtk2->events_pending; # do stuff # update the progress bar $self->{progress_bar}->pulse; # required to see the change in the progress bar Gtk2->main_iteration while Gtk2->events_pending; }

In reply to Re: Structure of a large Perl GUI application by boblawblah
in thread Structure of a large Perl GUI application by DarrenM

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.