This is a hack, but seems to work on linux. I noted 2 needed (but weird) focus calls, that I found by experimenting. :-)
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Entry; my $mw = new MainWindow; my $warning = 'alphanumeric entered'; my $tl = $mw->Toplevel(); $tl->geometry('300x100+300+300'); + my $wlabel= $tl->Label(-textvariable => \$warning) ->pack(-expand=>1,-fill=>'both'); $tl->withdraw; my $new_label = $mw -> Label(-text=>"Enter any character", -foreground=>"red", )-> pack(-side=>"top"); my $ent=$mw->Entry()->pack(); my $press = $mw -> Button(-text=>"Show Me", -command =>\&PressMe, )-> pack(-side=>"left",-padx=>"5", -ipadx=>"5"); $mw->bind( '<FocusOut>' => sub{ $tl->withdraw; $mw->focus; #hack needed to prevent recursion } ); $mw->bind( '<FocusIn>' => \&PressMe ); MainLoop; sub PressMe{ my $val = $ent->get(); if ($val =~ m/[a-zA-Z0-9]/) { $tl->deiconify; $tl->raise; $ent->focus; #hack needed to prevent recursion } return; }
In reply to Re: Problem with MessageBox Widget in Perl/Tk
by zentara
in thread Problem with MessageBox Widget in Perl/Tk
by kapsule
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |