tamaguchi has asked for the wisdom of the Perl Monks concerning the following question:
The program open a window with a entry box in which it is possible to put in values. The value in the box is printed in the console when the button "print" is clicked. Now I wonder if it is possible to preset a default value in the entry box so that there alredy is a value in the window when the program is started. (Which could could then be changed to something else.) Thank you for any help.#!/usr/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; $mw->Label(-text => 'Number')->pack; my $nmbr = $mw->Entry(-width => 10); $nmbr->pack; $mw->Button( -text => 'Print', -command => sub{do_print($nmbr);} )->pack; MainLoop; sub do_print { (my $nmbr) = @_; my $nmbr_val = $nmbr->get; print "Printing number $nmbr_val\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I preset values in an entry-box?
by bobf (Monsignor) on Jul 23, 2006 at 20:28 UTC | |
|
Re: How do I preset values in an entry-box?
by GrandFather (Saint) on Jul 23, 2006 at 21:30 UTC | |
|
Re: How do I preset values in an entry-box?
by CountZero (Bishop) on Jul 23, 2006 at 20:36 UTC |