[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

TkToplevel problem

sujeet kumar

6/22/2005 6:23:00 AM

Hi
I want to make a GUI program which takes some input from user in
its method. I used TkToplevel to create a new window. In TkToplevel I
created two TkEntry widget to take the required data from user. Now
there is two problems.
How to take value from TkEntry of TopLevel to the method calling it ?

After taking the value I want TkToplevel to exit. I made a Button in
TkToplevel by pressing TkToplevel should exits.I used "command {exit}"
But by pressing that button whole program exit. I want only Toplevel
to exit

what command should i give in Button to exit only TkToplevel?

Thanks
sujeet


1 Answer

Markus Weihs

6/22/2005 12:43:00 PM

0

Hi!

> what command should i give in Button to exit only TkToplevel?
Use "destroy" instead of "exit". Here's a little example snippet:


require 'tk'

def new_one(l)
top = TkToplevel.new(root)
e1 = TkEntry.new(top).pack
TkButton.new(top) {
text "Ok"
command proc{
l.configure('text'=>e1.get)
top.destroy
}
pack
}
end

root = TkRoot.new
l = TkLabel.new(root, 'text'=>'Some Text').pack
TkButton.new(root) {
text "Change Text"
command proc{new_one(l)}
pack
}
Tk.mainloop()


Regards, Markus