Hi,

From: Jon Forums <redmine / ruby-lang.org>
Subject: [ruby-core:38198] [Ruby 1.8 - Bug #5049] [ext/tk] Tk creating double MessageBox's
Date: Wed, 20 Jul 2011 00:26:29 +0900
Message-ID: <redmine.journal-19330.20110720002629 / ruby-lang.org>
> Your answer makes technical sense, but from a user perspective requiring this extra code to display a message box seems both (arguably) unintuitive and an unnecessary implementation detail. 

I said that you didn't get two messagebox windows but got a root window
and a messagebox window.
Maybe, you are misunderstanding about a root window. On Tk, a root
window is automatically created without calling a constructer method
(without TkRoot.new) when initializing a Tcl/Tk interpreter and is
shown as default. If you want to hide a root window, it is a matter of
course that you must do a method call to hide it.
I thought that you wanted to show a messagebox window only without a
root window. So, I wrote a solution to hide a root window.

> Are there any technical limitations in 1.8 that prevent Tk from behaving consistently with 1.9 with respect to Dialog methods and event loops?
> 
> Why should 1.8 and 1.9 Dialog methods behave differently from a Ruby code perspective?

If changing behavior on 1.8, a compatibility is lost.
The difference between 1.8 and 1.9 depends on nativethreads.
1.8 runs on only one nativethread, but each of threads on 1.9 runs on
each nativethread.
Tk widgets will work on the only nativethread on which Tk interpreter
was initialized. So, on 1.9, Tk library must make a ruby's thread in
which Tk interpreter is initialized and an eventloop is running.
Otherwise,  Tk.mainloop works on a main thread only (on some
environments, there is the limitation). Then, "Thread.new{Tk.mainloop}"
doesn't work.
Well, when starting an eventloop at "require 'tk'", an empty root
window is shown at same time. And users will see the steps creating GUI.
I think that is bad. It is NOT compatible between 1.8 and 1.9 as behavior.
I did a hack to hide a root window before calling Tk.mainloop.
Almost all cases, it works properly. However, as you see, it looses
compatibility on some minor cases.
I think the incompatibility will be acceptable, because, without
Tk.mainloop, it is natural to call withdraw method before calling a
dialog method (it makes sub-eventloop for it self). 1.8 users will do
that. And it works properly on 1.9 too.

Can it be an answer for your question?
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology