Many thanks for that. It is so obvious when you see it! ..but not before!!! The code below uses this latest input with the Perl suggested by an annonymous monk on 24th February to do what I want.
The user has to either use the mouse or tab to get into an Entry box, enter a number and then use either the mouse or tab to leave the Entry box. At this point the value in the Entry box is checked against defined min and max. Messages are then printed to the MSDOS screen to give the state of the value.
#!/usr/bin/perl -w use strict; use Tk; my (@entries, @entry_value); # max and min values for Entry boxes my (%maxev, %minev); $maxev{0} = 100; $maxev{1} = 150; $maxev{2} = 200; $minev{0} = 10; $minev{1} = 15; $minev{2} = 20; my $mw = MainWindow->new; my $frame = $mw->Frame()->pack(-padx => 50,-pady => 50); foreach my $i (0..2) { $entry_value[$i] = "$i"; $entries[$i] = $frame->Entry(-relief => 'raised', -textvariable => +\$entry_value[$i], )->pack(-side => 'left', -padx => 50,-pady + => 50); # $entries[$i]->bind('<Enter>' => [\&sayHello,$i]); $entries[$i]->bind('<Leave>' => [\&sayGoodbye,$i]); $entries[$i]->bind('<FocusIn>' => [\&sayFocusIn,$i]); + $entries[$i]->bind('<FocusOut>' => [\&sayFocusOut,$i]); } MainLoop; sub sayHello { my $w = shift; my $id = shift; $w->focus; $frame->grab; print "Hi, I am entry $id!\n"; } sub sayGoodbye { my $w = shift; my $id = shift; $frame->grab; $mw->focus; print "Goodbye, I was entry $id!\n"; } sub sayFocusIn { my $w = shift; my $id = shift; $frame->grab; print "Hi, FocusIn said I am entry $id - value $entry_value[$id]\n" +; } sub sayFocusOut { my $w = shift; my $id = shift; my $val_ok; $frame->grab; $val_ok = 'yes'; # check that current valaue is within the min max values if($entry_value[$id] < $minev{$id}) { print "\nEntry $id - value is less than allowed minimum of $minev{ +$id}\n"; $val_ok = 'no'; } if($entry_value[$id] > $maxev{$id}) { print "\nEntry $id - value is greater than allowed maxmum of $maxe +v{$id}\n"; $val_ok = 'no'; } if($val_ok eq 'yes') { print "\nEntry $id - value is acceptable\n"; } }

In reply to Re^4: Tk - Focus & Mouse - On & Off by merrymonk
in thread Tk - Focus & Mouse - On & Off by merrymonk

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.