Ruby/Tk: Problem creating modal dialogue using "grab"

R

Ronny

I would like to have a modal dialogue window appear, when I press a
button. This window
should contain (in its first version) just an entry field and an OK
button, and when OK
is pressed, the value of the entry field should be returned.

I have found out that I have to use the "grab" method to make a window
modal, so here
is the function which is supposed to handle the complete modal
dialogue:

def get_new_dir
dialogue=TkToplevel.new() {title "change directory"}
dialogue.grab("set") # make modal
frame=TkFrame.new(dialogue).pack('fill'=>'both')
entry=TkEntry.new(frame).pack()
entry.value='../'
button=TkButton.new(frame,
:text => "Yeah",
:command => dialogue.grab("release")
)
button.pack()
entry.value # return value of entry field
end

This works *nearly* well, except that I get an incomprehensibel error
message
(incomprehensible to me at least), which you can see in the screenshot
at
http://img135.imageshack.us/img135/4464/rubytkerror7we.jpg

It claims "wrong number of arguments", but I can not recognize from the
message which function is called with the wrong number of arguments.

Anyone out there who can spot the error?

Ronald
 
T

ts

Not sure, but try it with

R> button=TkButton.new(frame,
R> :text => "Yeah",
R> :command => dialogue.grab("release")

:command => proc { dialogue.grab("release") }

R> )
R> button.pack()
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top