'lo all...

I've only done a little programming with Perl/Tk, although I've been programming with perl for quite a while. Hence, I'm having a little trouble with the 'event-driven' thing.

The attached code does what it does... but instead of clicking the "Pop It!" button to bring up the popup window, I actually want the sequence of things to be more like:

- setup the main window

- click the "Pop It!" button and call 'AddItem'

- once in AddItem, I want the popup to be displayed, and to stay there whilst I do things in 'AddItem'. Once 'AddItem' is more-or-less done, the popup is removed (like when the button is pressed) and we're back in the main window.

The popup is like a 'status' window... but I'm not sure how to actually -do it-... It's simple enough to do things with a button action but this is where I get confused with the 'event-driven' thing.

I'd appreciate any pointers...

Thanks.

John

use strict; use Tk; my $mw = MainWindow->new; # Main window my $top = $mw->Frame( -background => '#239867', -borderwidth => 2, )->pack(-fill => 'both'); my $lbltxt = $top->Label( -text => 'Just some text', -background => 'white', )->pack(-side => 'right', -padx => 10); my $GoBtn = $top->Button( -text => ' Pop It! ', -command => \&AddItem )->pack(-side => 'left', -padx => 10, -pady => 5); my $DoneBtn = $top->Button( -text => ' Exit ', -command => \&Cleanup )->pack(-side => 'right', -padx => 10, -pady => 5); $mw->focus; # Ensure we're talking to the main window MainLoop; # Run the program, watching for events # ---- sub Cleanup { $mw->destroy; } # ---- sub AddItem { my $tp = $mw->Toplevel( -title => ' AddItem' ); # ->pack(-fill => 'both'); my $tpfrm = $tp->Frame( -background => '#22cc00', )->pack(-side => 'top', -fill => 'x'); my $tplbl = $tpfrm->Label( -text => 'Working...', -background => 'white', -foreground => 'black' )->pack(-side => 'top', -padx => 10); my $tpbtn = $tpfrm->Button( -text => 'Close', -command => [$tp => 'destroy'], )->pack(-side => 'top', -padx => 10, -pady => 5); }

In reply to How to PopUp a 'Status' window in Perl/Tk by ozboomer

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.