2014-12-30 75 views
0

我是Ruby的新手。我能夠創建一個簡單確定一個簡單的窗口/取消按鈕用下面的代碼和它的作品:使用Ruby關閉TK窗口

require 'tk' 

root = TkRoot.new 
root.title = "Window" 

msgBox = Tk.messageBox(
    'type' => "okcancel", 
    'icon' => "info", 
    'title' => "Framework", 
    'message' => "This is message" 
) 
Tk.mainloop #No operation is performed until closing the TK window 
Tk.destroy() 
Tk.exit() 

雖然我可以手動關閉該窗口,我不能讓窗口關閉程序。有任何想法嗎?

回答

0

嘗試Window.destroyWindow.iconify

0

TK是圖書館,你不應該讓TK.destroy,因爲根是TkRoot的對象,應該是如下:

root.destroy() 

希望這個答案幫助他人。