HJG 2016-01-28: This is a fork of A little value dialog by Richard Suchenwirth, a small edit-value-dialog.
The immediate upcoming intended use is in MINISS - Mini Spread Sheet, together with that nice and short m+-menu routine.
This is a custom dialog - a toplevel that prompts for a value.
I have some ideas on how to modify the original value_dialog - routine, so I made a separate page here:
...
package require Tk # # Input-Dialog: (from https://wiki.tcl-lang.org/8692 "A little value dialog" by R.Suchenwirth) # proc edit_val {string } { set w [toplevel .edit] wm resizable $w 0 0 wm title $w "Edit cell" label $w.l -text $string entry $w.e -textvar ::val -width 20 set old $::val button $w.ok -text " OK " -command {set ::done 0} button $w.clear -text "Clear " -command "set ::val {}" button $w.cancel -text "Cancel" -command "set ::val $old; set ::done 1" bind $w.e <Return> {set done 1} bind $w.e <Escape> "$w.cancel invoke" grid $w.l - - -sticky news grid $w.e - - -sticky news grid $w.cancel $w.clear $w.ok raise $w . focus $w.e vwait ::done destroy $w return $::done } # Demo: wm withdraw . update wm deiconify .; # window-manager needs to update size and position set zz [wm geometry .]; # get size and position wm title . $zz set val 123; # global var, for use with `-textvar` set done -1 set res [edit_val "Enter value:"] #puts val:$val pack [ label .l -text "Result: $res --> '$val' " -pady 30 -padx 30 ] focus -f .
Features: