From: Daniel Carrera Date: 2003-03-11T10:26:14+09:00 Subject: [Q] How to destroy a TkToplevel window Hello, I want to make a dialog using Tk (and I don't want to use TkDialog because it would be more difficult to explain). I'm having trouble destroying a TkToplevel window. My entire code is included below. I have a main window with a button called 'Callback'. If you click on it you get the dialog, which has a 'Cancel' button, which simply calls the 'destroy' method on the TkToplevel window. When you click on it though, I get an error pop-up saying: Error: invalid command name ".w0005.w0006" Does anyoone know what I'm doing wrong? Or is there an easier way to do what I want? Here is my code: require 'tk' def callback dialog = TkToplevel.new() { title "Add Contact" } button_quit = TkButton.new(dialog) { text "Cancel" } button_quit.bind("ButtonRelease-1") { dialog.destroy } button_quit.pack("side" => "bottom") end root = TkRoot.new() {title "Hello World"} # Callback button_add = TkButton.new(root) { text "Callback" } button_add.bind("ButtonRelease-1") { callback } button_add.pack("side" => "left") # Quit button. button_quit = TkButton.new(root) { text "Quit" } button_quit.bind("ButtonRelease-1") { exit } button_quit.pack("side" => "left" ) Tk.mainloop