For Programmers: Free Programming Magazines  


Home > Archive > Tcl > November 2006 > why I can't input chars in the entryfield ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author why I can't input chars in the entryfield ?
Harry

2006-11-25, 7:02 pm

Here is the code:

package require Iwidgets



proc TcldateToSqldate date {
upvar $date localDate
regexp {(\d+)/(\d+)/(\d+)} $localDate match month day year
return "$year-$month-$day"
}

wm title . DataMiner
frame .getDate -borderwidth 10

pack .getDate -side top -fill x

proc returnCmdStart {} {
puts [.getDate.deStart get]
}

proc returnCmdEnd {} {
puts [.getDate.deEnd get]
}


iwidgets::dateentry .getDate.deStart -labeltext "Start Date:" -command
returnCmdStart
iwidgets::dateentry .getDate.deEnd -labeltext "End Date:" -command
returnCmdEnd

iwidgets::entryfield .getDate.efCode -labeltext "Stock Code:" -validate
{check_code %W "%c"}

pack .getDate.deStart .getDate.deEnd .getDate.efCode -expand yes -padx
10 -pady 10 -side left

proc check_code {entry char} {
set current [$entry get]
set len [string length $current]

if {$len == 8} {
$entry delete 0 end
$entry insert 0 "$current"
}

if {$len == 8 && [regexp {s[z|h][\d]{6}?} $current]} {
return 1
}
return 0
}



Here my proc check_code is to insure the input is like "sz000063",
Do you guys have any better solutions?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com