🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Pass the command while closing Hw.Tk GUI

User: "Hypermesh User"
Altair Community Member
Updated by Hypermesh User

Hi,

  I want to pass the command while closing the GUI that will unregister the proc and Unset the variables.

 

FYI:  I no need to add a separate close button, I want to add it in that window closing button. 

 

image

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "tinh"
    Altair Community Member
    Accepted Answer
    Updated by tinh

    Hi,

    That close button is not belonged to Tk but Windows

    So, must use window manager (wm)...

    Example:

    proc onClosing {window} {    puts -nonewline "Closing window... "    set ans [tk_messageBox -title "Confirm" -message "Are you sure closing me?" -type yesno]    if {$ans == "yes"} {       #unset your variables here...       #unregister your procs here...              #finally, must explicit destroy the window:       destroy $window       puts "Done!"    } else {       puts "but not!"    } }  set w .sampleWindow destroy $w toplevel $w wm title $w "Sample closing window" pack [label $w.l -text "Close me by clicking on [X] upper left"] wm protocol $w WM_DELETE_WINDOW [list onClosing $w]