[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Multiple files/windows with Tk

DBH

4/1/2007 12:53:00 AM

I'm currently trying to write a Ruby program using Tk that requires the
use of multiple files and windows. For instance, I have a main screen,
and when I click on one of the buttons, I want the main window to close
and a new window to open. The code for these windows is located in
different files (but if possible I could put them all in one). So far
all I've been able to do is get the second window to attach itself onto
the first, resulting in a very ugly looking GUI. How can I get the Tk
interface to let me close one window and open another with a button
click or similar event?

Thanks in advance to any help anyone can offer.

--
Posted via http://www.ruby-....

2 Answers

Andrew Thompson

4/1/2007 4:59:00 PM

0

DBH wrote:
> I'm currently trying to write a Ruby program using Tk that requires the
> use of multiple files and windows. For instance, I have a main screen,
> and when I click on one of the buttons, I want the main window to close
> and a new window to open. The code for these windows is located in
> different files (but if possible I could put them all in one). So far
> all I've been able to do is get the second window to attach itself onto
> the first, resulting in a very ugly looking GUI. How can I get the Tk
> interface to let me close one window and open another with a button
> click or similar event?
>
> Thanks in advance to any help anyone can offer.

There's a couple approaches you can take. You can #withdraw the current
window and create a new TkToplevel and display it, or you can again
#withdraw the current window, unpack it's contents, pack in some new
contents and redisplay the window (I don't recall the method to
redisplay the window off-hand). I prefer the second approach in general,
but either should work fine. You should be able to do whatever you want
by passing a block to TkButton#command.

Hope that helps,

Andrew


--
Posted via http://www.ruby-....

Hidetoshi NAGAI

4/3/2007 10:14:00 AM

0