<?xml version="1.0" encoding="windows-1252"?>
<node id="1018965" title="Re^5: Entry widget with explicit submit button" created="2013-02-15 15:15:10" updated="2013-02-15 15:15:10">
<type id="11">
note</type>
<author id="805072">
7stud</author>
<data>
<field name="doctext">
Why are you using a textvariable at all?

&lt;code&gt;
use strict;
use warnings;
use 5.012;

use Tk;

my $entry_text;


my $mw = MainWindow-&gt;new;

my $entry = $mw-&gt;Entry(
    -text =&gt; 'Enter answer here',
)-&gt;pack;

$entry-&gt;focus;
$entry-&gt;selectionRange(0, 'end');

sub my_validator {
    my $input = $entry-&gt;get();

    if ($input eq 'hello') {
        $entry-&gt;delete(0, 'end');
        $entry-&gt;insert(0, 'Try again!');
        $entry-&gt;selectionRange(0, 'end');
        $entry-&gt;icursor(0);
    }
    else {
        say "Thanks for the great input!";
        $entry_text = $input;
        say $entry_text;
    }
}

$mw-&gt;Button(
    -text       =&gt; 'Submit',
    -command    =&gt; \&amp;my_validator,
)-&gt;pack;

MainLoop;

&lt;/code&gt;</field>
<field name="root_node">
1018903</field>
<field name="parent_node">
1018934</field>
</data>
</node>
