[Richard Suchenwirth] 2006-06-07 - Here is a [Tk] dialog that can be used with [another simple database] to edit a record (a list) by fields. Similar to [tk_getOpenFile] etc., "" is returned when the user clicked "Cancel", else the current field contents. It is up to the caller to do something useful with the result :^) [http://mini.net/files/editRecord.jpg] ---- package require Tk proc editRecord {title headers fields} { set oldfocus [focus] set w [toplevel .[clock clicks]] wm resizable $w 1 0 wm title $w $title set n 0 foreach h $headers f $fields { label $w.h$n -text $h -anchor e [entry $w.e$n -width [string length $f]] insert end $f grid $w.h$n $w.e$n -sticky news incr n } button $w.ok -text OK -width 5 -command [list set $w 1] button $w.cancel -text Cancel -command [list set $w 0] grid $w.ok $w.cancel -pady 5 grid columnconfigure $w 1 -weight 1 vwait ::$w if [set ::$w] { #-- collect the current entry contents set n 0 foreach f $fields { lappend res [$w.e$n get] incr n } } else {set res {}} destroy $w focus $oldfocus return $res } #-- Testing: wm withdraw . set db { {Author Title Year Category} {{Shakespeare, William} {Romeo and Juliet} 1767 Theatre} {{Puzo, Mario} {The Godfather} 1965 Drama} {{Verne, Jules} {Around the world in 80 days} 1862 Adventure} {{Sheldon, Sydney} {The other side of midnight} 1967 Mystery} {{Mc Cullough, Colleen} Thornbirds 1967 Saga} } set res [editRecord Edit: [lindex $db 0] [lindex $db 3]] if [llength $res] {lset db 3 $res} puts [join $db \n] exit ---- [Category Example] | [Arts and crafts of Tcl-Tk programming]