The R code below illustrates some of the basic R TclTk functions required to create a non-modal dialog box. Non-modal means that the user is not forced to respond to this dialog box immediately. Instead the user can change the focus to another window and do something else before responding to this dialog box.
A Tcl variable done is used to keep track of the state of the dialog box (active, closed with OK, or closed with Cancel/Destroyed). The tkgrid() function is used to layout the buttons on the window. The tkbind() function is used to capture the event of the window being destroyed, e.g. with the cross in the upper right-hand corner or with Alt-F4 (in Windows) and to bind this event to a function which sets the state variable (done) appropriately. In order to demonstrate how to determine whether OK or Cancel was pressed, a message box is used in each case to announce the result of the dialog box.
Running the R code above results in the following window:
The dialog is resizable by default, so you can easily make it big enough to see the title by dragging any of the edges or corners with the mouse. If you want the buttons to lay out nicely when de dialog is resized, you will need a little bit more work, or you should use tkpack() instead.