[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

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

Ronald Otto Valentin

5/19/2006 8:45:00 AM

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/rubytker...

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

1 Answer

ts

5/19/2006 8:57:00 AM

0

>>>>> "R" == Ronny <ro.naldfi.scher@gmail.com> writes:

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()


--

Guy Decoux