TkToplevel problem

S

sujeet kumar

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
 
M

Markus Weihs

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top