Thanks that's worked out well, I've been changing around my implementation a bit. One last question. I setup the msgboxes in the MainLoop and I intialize their message values in a subroutine. When I run the program I get two blank msgboxes at startup (supposedly from the setup statements for them in the MainLoop). How can I avoid this? Code below:
#!/usr/bin/perl
$VERSION = 1.00;
use strict;
use Tk;
use Tk::FileSelect;
use Tk::MsgBox;
my (%deck);
#main window
my $mw = MainWindow->new();
$mw->geometry("400x200");
#file selector button
my $file_dialog = $mw->Button(
-text => 'Load Cards',
-command => \&load_deck
) ->grid(-row=>6,-column=>0);
#start quiz button
$mw->Button(
-text => 'Quiz Me!',
-command => \&quiz_me
) ->grid(-row=>6,-column=>2);
#quit button
$mw->Button( -text => 'Quit', -command => sub { exit } )
->grid(-row=>6,-column=>4);
#front & back popups
# Here is where I believe those 2 blank ones at startup are coming fro
+m...
my $front = $mw->MsgBox(-title=>'FRONT',-default=>'ok',-icon=>'questio
+n');
my $back = $mw->MsgBox(-title=>'BACK',-default=>'ok',-icon=>'info');
MainLoop;
sub load_deck {
my $start_dir = "/home/$ENV{'USER'}/TkPerl";
my $FSref = $mw->FileSelect(-directory => $start_dir);
my $file = $FSref->Show;
dbmopen(%deck, $file, 0644);
}
sub quiz_me {
while ( my ($key, $value) = each (%deck) ) {
#Configure the message value and then show the msgboxes
$front->configure(-message=>$key);
$front->Show;
$back->configure(-message=>$value);
$back->Show;
}
}
|