The following example illustrates the use of a checkbox in a Tk toplevel window. The value of the checkbox is mapped to a Tcl variable called
cbValue, which is initialized to zero (i.e. the checkbox will be initially unchecked). The
onOK() function triggered by the
OK button captures the value of the Tcl variable mapped to the checkbox (
cbValue) before destroying the window. Then it displays an appropriate message box depending on the value of the checkbox.
You should get a window similar to this one:
OK without checking the box…
Now, rerun the code and check the box: