The following example illustrates the use of radiobuttons in a Tk toplevel window. The choice of radiobutton is mapped to a Tcl variable called rbValue, which is initialized to "oranges", which is the value of the second radio button (i.e. initially, the second radio button will be selected). The onOK() function triggered by the OK button captures the value of the Tcl variable mapped to the radiobuttons (rbValue) before destroying the window. Then it displays an appropriate message box depending on the choice.
Click OK without changing the selection…
Now, rerun the code and select Apples:
Click OK