Thanks for the tips. I looked all around the Internet but couldn't find too
much on using Tk within Ruby. Today I was trying to add the TkToplevel class
and utilize the withdraw and deiconify methods. I think I have a decent
start, as I have the new window created and am now trying to tackle hiding
the original window. What do you folks recommend in terms of a Ruby/Tk
reference guide? Should I just pick up an available Perl/Tk guide and adapt
it for Ruby myself?
···
-----Original Message-----
From: Hidetoshi NAGAI [mailto:nagai@ai.kyutech.ac.jp]
Sent: Thursday, November 04, 2004 7:24 PM
To: ruby-talk@ruby-lang.org
Subject: Re: Ruby/TK Question
Hi,
From: "Kujawa, Greg" <Greg.Kujawa@DiamondCellar.com>
Subject: Ruby/TK Question
Date: Fri, 5 Nov 2004 02:09:08 +0900
Message-ID: <B058578D93B5D41193840090276AA76769F967@DIAMOND_EX>
The application is for a survey. I have created an initial window
where the survey taker signs in. They select their name from a
TkListbox object. When they click on a TkButton object the sign in
window exits and I record the appropriate current selection of the
listbox object.
I recommend you to define a binding to the listbox for more comfortable UI.
For example,
----------------------------------------------------------
$empListbox..bind('Double-Button-1', proc{button.invoke})
----------------------------------------------------------
My question is how would I go about creating a new window for taking
survey itself and still keep the saved selection of the listbox
object?
Please use the TkToplevel class. It creates a new window object.
Because the window depends on the root (or its parent) widget,
when the root widget is destroyed, the window is destroyed too.
If you want to hide the root widget, use {TkRoot/TkToplevel}#withdraw
and deiconify method.
# Add the sign in button
button = TkButton.new(@root) { text "Sign me in!"
command proc {
indexstr = $empListbox.curselection.to_s;
indexnum = indexstr.to_i;
$taker=$employee[indexnum].to_s;
p $taker;
exit
Probably, this 'exit' exits the application.
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)