如何绑定TkToplevel窗口的Destroy事件?

时间:2016-03-13 18:05:10

标签: ruby events tk

我试过这个,点击鼠标关闭了窗口,但从未得到过这个事件:

top = TkToplevel.new(root)
top.bind('<Destroy>', proc {
    ...
})

出了什么问题?

1 个答案:

答案 0 :(得分:1)

top = TkToplevel.new(root)
top.protocol "WM_DELETE_WINDOW", proc { puts "It's time to say goodbye.";
                                        top.destroy }

https://www.ruby-forum.com/topic/51509