I have just delved into using Tk to design a simple flash card study program to help me review for mid-term exams. It uses a hash tied to a dbm file. I want to display the back of the card (i.e. the answer) in a popup message dialog when the "Flip" button is pressed. As so far I can get the message box to appear, but not the answer that should go inside of it (stored in $value).
Any help appreciated. Here is the code:#!/usr/bin/perl $VERSION = 1.00; use strict; use Tk; use Tk::FileSelect; use Tk::MsgBox; my ($value, %deck); #main window my $mw = MainWindow->new(); $mw->geometry("400x200"); #file selector my $file_dialog = $mw->Button( -text => 'Load Cards', -command => \&load_deck ) ->grid(-row=>6,-column=>0); #flip button my $flip = $mw->Button( -text => 'Flip', -command => \&flip_card ) ->grid(-row=>6,-column=>2); #next button my $next = $mw->Button( -text => 'Next =>', -command => \&next_card ) ->grid(-row=>6,-column=>4); #front label & display $mw->Label( -text => 'Front: ' )->grid(-row=>0); my $front = $mw->Label()->grid(-row=>0,-column=>2); #back display my $back = $mw->MsgBox(-title=>'Back of card',-default=>'ok',-message= +>$value); $mw->Button( -text => 'Quit', -command => sub { exit } ) ->grid(-row=>7,-column=>2); 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); next_card(); } sub next_card { my ($key, $loc_val) = each (%deck); $value = $loc_val; $front->configure(-text=>$key); } sub flip_card { my $pop = $back->Show; }
use strict; use CGI;
In reply to Tk::MsgBox and my -message string by davidov0009
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |