New paste Repaste Download
#!/usr/bin/env wish
array set Var {}
foreach x {a b c} {
    ttk::entry .$x \
        -textvariable Var($x) \
        -validate key \
        -validatecommand {regexp {^\d*$} %P}
}
grid .a [label .ab -text *] .b [label .bc -text +] .c \
    [label .e -text =] [label .r -textvariable Result]
trace add variable Var write {apply {args {
    global Var Result
    set expr {expr {$Var(a) * $Var(b) + $Var(c)}}
    if {[catch $expr Result]} \
        { set Result NaN }
}}}
Filename: None. Size: 495b. View raw, , hex, or download this file.

This paste expires on 2026-09-13 13:36:33.453222+00:00. Pasted through web.