Hi David, On 2011-01-07, at 9:42 PM, David Swingle wrote: > I have a simple Perl/Tkx script: > > 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 > { > print "Entry: '$text'\n"; > return 1; > } > > When I run the script, the GUI is displayed and I have "abc" in the entry > widget. I then click in the widget at the end of the text, and then type > '1', '2', '3'. I get the following output: > > Entry: 'abc' > Entry: 'abc' > Entry: 'abc1' > Entry: 'abc12' > > The first line prints as soon as I click in the entry widget, and the 2nd > line prints when I type '1', and so on. What do I need to do so that my > output is "abc1" after I type the '1', and "abc12" after I type the '2', and > so on?
You are getting this effect because the validation occurs _before_ the actual change occurs. You want to create a Tkx::Ev bound event, e.g.: -validatecommand => [\&Entry, Tkx::Ev('%P')], Check the docs in ttk::entry for all the right %-subs that would give you what you want for best validation. http://www.tcl.tk/man/tcl/TkCmd/ttk_entry.htm#M40 Jeff