On Sep 24, 2007, at 7:34 AM, SpringFlowers AutumnMoon wrote:

> Alex Fenton wrote:
>> SpringFlowers AutumnMoon wrote:
>>> how can we pop up a Tk window to display the temporary results of a
>>> program?
>
>> When you call "mainloop", you're telling Tk (and other GUIs, too) to
>> wait for the user to do something (eg click a button). This is  
>> sometimes
>> called an "event loop". As the "loop" name suggests, the program  
>> stops
>> at this point and nothing further will be run until the GUI is ended.
>>
>> To run other tasks (such as your calculation) concurrently with the
>> event loop, start those other tasks in a ruby Thread alongside the  
>> GUI
>> code. Then, if you want to display intermediate results from that  
>> task
>> in the GUI, pass messages between the task thread to the main GUI
>> thread. Again, there's numerous different ways to do this.
>
> what about not calling the MainLoop but just keep on painting on  
> the GUI
> window?  For example, like in Win 32, I had a program that just popped
> out a window and then I just keep on using DrawText to paint the  
> result.
> The whole program doesn't need to have any event driven handling.   
> just
> drawing text to a window.

Since you propose an alternative solution, why did you not try it out  
for yourself, rather than just throwing the question out on the  
mailing list? You would have had the answer much quicker hat way.  
Ruby is a very easy language to experiment with. That is one of its  
greatest strengths. You should take advantage of it -- it is the best  
way to learn.

If you had tried your idea, you would have found that it doesn't  
work. Unless Tk.mainloop is called, Tk will never paint any windows  
on the screen. The advice you received from Alex Fenton was good  
advice. If handling threads is too difficult for you at the current  
stage of your Ruby development, I suggest you print intermediate  
results to stdout.

Regards, Morton