I've run into a situation that I can't explain and was wondering if anyone else has run across this. When I use an entry to allow user keyboard input, and restrict the key strokes to be numbers (0-9), I encounter a problem trying to enter some numbers after the initial number entered is a 0. Here are some cases: 1) If the first number entered is a 0 and is then followed by a 7, an 8 or 9 can't be entered next, though all other numbers can be entered. 2) If the first number is a 0, and then the next one entered is an 8 or 9, they aren't shown in the entry window, but all other numbers can be entered. 3) And, if I enter a series of 0's followed by an 8 or 9, the same result occurs - the 8 or 9 is not shown in the entry window. My test code is below. Any ideas? If I change the "string is int" to "string is digit" the problem goes away.
#!/bin/sh
exec wish "$0" "$@"
#----------------
frame .fMain -relief raised -borderwidth 4
frame .flat -relief groove -borderwidth 4
label .lnum -text "Enter a number:" -width 15
entry .enum -validate key -vcmd {expr {[string is int %P] \
&& [string length %P] < 14 }} -width 15 -bg white
label .lOK -text "\nHit OK when finished.\n"
pack .fMain
pack .flat .lOK -in .fMain
pack .lnum .enum -in .flat -side left
button .butOK -text "OK" -bg cyan -borderwidth 3 \
-command "desThisWindow"
pack .butOK -in .fMain
#----
# destroy the window
#----
proc desThisWindow { } {
destroy .
}
#!/bin/sh
exec wish "$0" "$@"
#----------------
frame .fMain -relief raised -borderwidth 4
frame .flat -relief groove -borderwidth 4
label .lnum -text "Enter a number:" -width 15
entry .enum -validate key -vcmd {expr {[string is int %P] \
&& [string length %P] < 14 }} -width 15 -bg white
label .lOK -text "\nHit OK when finished.\n"
pack .fMain
pack .flat .lOK -in .fMain
pack .lnum .enum -in .flat -side left
button .butOK -text "OK" -bg cyan -borderwidth 3 \
-command "desThisWindow"
pack .butOK -in .fMain
#----
# destroy the window
#----
proc desThisWindow { } {
destroy .
}