Sorry can't think of a better title!

I have the simple code below. When I pass a value to &check_card the $mw->label doesn't appear until the &check_in_SQLStore completes. This defeats the purpose!

I have even tried putting the label in it own function and calling that first (once card length >0) but it still waits for the next function to complete!

Autoflush to positive doesn't help and WaitBox seems a little ropy/difficult/OTT for what I need.

Could anyone suggest how I could make the "Please wait..." text appear while/before the check_in_SQLStore function executes?

#!/usr/bin/perl use strict; use warnings; use Tk; use DBI; my $mw = MainWindow->new; $mw->geometry("500x300+600+200"); my $text; $mw->title("Account Details"); $mw->Label( -text => "Card Number:" )->pack(-side => 'top'); my $card = $mw->Entry(-textvariable => '', -background => 'white', -width => 24)->pack(-side => 'top'); $mw->Button( -text => "Check Account", -command => \&check_card, )->pack(-side => 'top'); $mw->Button( -text => "Done", -command => sub {exit} )->pack(-side => 'top'); MainLoop; sub check_card { my $cardno = $card->get(); if(length $cardno =="0"){ error_no_card(); } elsif(length $cardno > "0") { $mw->Label(-text => "\nChecking Account Details for '$cardno'.\n Pleas +e Wait......\n", -width => 54)->pack(); } if(length $cardno > "0"){ my $exists = check_in_SQLStore($cardno); if($exists =="0"){ print "We got nothing\n"; } } } sub error_no_card { $mw->messageBox(-title => "Error!", -type=>'ok', -message => "Please e +nter an Account Card number!",); }

In reply to Tk won't output until finished by packetstormer

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.