Hello monks,

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

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.