David S has asked for the wisdom of the Perl Monks concerning the following question:
When I run the script and click in the entry widget, I get text = 'abc' printed, which is what I expect. When I then type '1' in the entry widget, I still get text = 'abc' printed, but I expected to get text = 'abc1'. When I then type '2', I get text = 'abc1', but I expected to see text = 'abc12'. When I click outside of the widget, the correct string is then printed. Is there a way to have the validatecommand get the current value of the textvariable? I've tried changing the -validate value from "all" to other values, but that doesn't help. I've tried adding a call to Tkx::update() (see commented out code), but that doesn't seem to have any affect. Any help would be appreciated.use strict; use Tkx; Tkx::package_require("tile"); Tkx::package_require("style"); my $mw = Tkx::widget->new("."); my $text = "abc"; my $entry = $mw->new_ttk__entry(-width => 20, -textvariable => \$text) +; $entry->configure(-font => "helvetica 14 bold"); $entry->g_grid(-column => 0, -row => 0, -sticky => 'w'); $entry->configure(-validate => 'all', -validatecommand => \&Entry); Tkx::MainLoop(); sub Entry { ### Tkx::update(); print "text = '$text'\n"; return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tkx Entry widget problem
by jethro (Monsignor) on Jan 10, 2011 at 17:05 UTC | |
by David S (Sexton) on Jan 10, 2011 at 21:25 UTC |