in reply to MessageBox before mainloop problem

Just put a 0 or 1 as a commandline arg to start the script. It defaults to 0.
#!/usr/bin/perl use warnings; use strict; use Tk; my $test = shift || 0; my $mw = MainWindow->new; $mw->withdraw; $mw->Button(-text => "hello", -command => sub {print "hello!\n";})->pack; if ($test == 0) { my $answer = $mw->messageBox(-icon => 'question', -message => 'Hello World!', -title => 'My title', -type => 'Ok'); $mw->deiconify; }else{ $mw->deiconify; } MainLoop;

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: MessageBox before mainloop problem
by vikee (Sexton) on Sep 02, 2005 at 09:59 UTC
    Hi,
    Can you click the hello button after closing the messagebox?
    me not (perl 5.6). I sent a shortened code to show you what
    i was talking about. It doesn't matter what it defaults to!
    It is zero to show the messagebox, otherwise it works.
    
    Vikee
    
      It works in 5.8, althougth the Tk version is probably more important. I can't see why the button wouldn't work for you. I changed the code to count up with each click.
      #!/usr/bin/perl use warnings; use strict; use Tk; my $test = shift || 0; my $mw = MainWindow->new; $mw->withdraw; my $count = 0; $mw->Button( -text => "hello", -command => sub { print $count++,"\n"; } )->pack; if ( $test == 0 ) { my $answer = $mw->messageBox( -icon => 'question', -message => 'Hello World!', -title => 'My title', -type => 'Ok' ); $mw->deiconify; } else { $mw->deiconify; } MainLoop;

      I'm not really a human, but I play one on earth. flash japh