From: Hidetoshi NAGAI Date: 2011-07-19T09:53:54+09:00 Subject: [ruby-core:38177] Re: [Ruby 1.8 - Bug #5049][Open] [ext/tk] Tk creating double MessageBox's Hi, From: Jon Forums Subject: [ruby-core:38173] [Ruby 1.8 - Bug #5049][Open] [ext/tk] Tk creating double MessageBox's Date: Tue, 19 Jul 2011 04:38:15 +0900 Message-ID: > When running the following simple test on 1.8.7-p352 built with TDM-1 GCC 4.5.2 and the RubyInstaller recipes, I get two MessageBox's. One empty, one with the message. > > ruby -rtk -e "Tk.messageBox :message => 'Hello Ruby Tk'" It is not a bug. The empty window is a root window of Tk. If you want to show a message box only, please call "Tk.root.withdraw" at first. Then, a root window will be hidden. $ ruby -rtk -e "Tk.root.withdraw; Tk.messageBox :message => 'Hello Ruby Tk'" > This does not occur when using MinGW versions of ruby 1.9.2p290 (2011-07-09 revision 32478) [i386-mingw32] or ruby 1.9.4dev (2011-07-18 trunk 32578) [i386-mingw32]. It depends on the difference between ruby-1.8 and 1.9. Although I omit the detail of the reason, Ruby/Tk on recent ruby-1.9 hides a root widget before calling Tk.mainloop. Usually, it has no problem. Because, Tk requires an eventloop to treat widnow events. But Dialog methods (e.g. Tk.messageBox) makes its own eventloop. So, ruby-1.8 shows a root widget too, but ruby-1.9 doesn't. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) Department of Artificial Intelligence, Kyushu Institute of Technology