Lhamo_rin has asked for the wisdom of the Perl Monks concerning the following question:

Is there a widget in Tk that will display the value of a variable but allow the user to type in a new value, if desired, over the original value in the widget and have the new value saved to the variable?

Lhamo_rin

Replies are listed 'Best First'.
Re: Widget Type
by Tanalis (Curate) on Jun 26, 2003 at 16:28 UTC
    You can associate widgets with variables, and they'll take on the value of that variable.

    You probably need something like a LabEntry or an Entry widget (depending on what you're doing with it) - and you'd use it something like this:

    my $mw = new MainWindow(); my $text = "This is an entry box"; $entry = $mw->Entry(-textvariable => \$text)->pack();
    That'll give you a text entry box, containing the text in $text, and allow you to change the text. Anything the user enters will automatically be stored in the $text variable.

    Hope that helps.
    -- Foxcub
    #include www.liquidfusion.org.uk

    Edit: Corrections/clarifications.