Wiki Markup |
---|
{alias:qcloseevent} |
Name
qcloseevent — catch close events
...
The qcloseevent command allows one to catch the closing of windows (qwidgets and qmainwindows). The programmer can assign Tcl commands to be executed during the closing of the window, useful for cleanup actions or for cancelling the close event.
Arguments
widget
The window for which we want to catch the close event. This has to be qwidget or qmainwindow.
cmds
Tcl statements to be executed when the window closes. This will often be the name of a Tcl procedure. If the procedure returns the string 'ignore' the event is cancelled, and the window will remain visible.
Examples
Ex.1: Catching a close event
...
No Format | ||||
---|---|---|---|---|
| ||||
# Callback procedure for closeevent
proc ce {} {
puts "Closing"
set button [qinformation "Closing Window" "Really close window?" OK Cancel]
if { $button == 1 } { ; # cancel
return ignore
}
}
set w [qwidget ]
# Call 'ce' when closing
qcloseevent $w ce
qshow $w
|
...