toplevel
Tcl/Tk
#!/usr/local/bin/wish4.2
proc make_win {} {
catch {destroy .win}
toplevel .win
button .win.b -text "Window Dismiss" -command {destroy .win}
pack .win.b
}
button .b -text "make Window" -command {make_win}
pack .b -fill x
ruby/Tk
#!/usr/local/bin/ruby
require "tk"
def make_win
begin
$win.destroy
rescue
end
$win = TkToplevel.new
TkButton.new($win) {
text 'Window Dismiss'
command "$win.destroy"
pack
}
end
TkButton.new {
text 'make Window'
command 'make_win'
pack('fill' => 'x')
}
Tk.mainloop