Exit dialog box after clicking

147 Views Asked by At

I am using fxruby to create a dialog box which has few options. Here is the part where I display one option and what happens after clicking that one.

# Download file
dwd_file= FXButton.new(contents,
  "&Download\tDownload file",
  :opts => FRAME_RAISED|FRAME_THICK|LAYOUT_BOTTOM |LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
  :width => 150, :height => 50)
  dwd_file.connect(SEL_COMMAND, method(:download))


def download(sender, sel, ptr)
  # Doing something which will take time. 
end

The dwd_file.connect will execute the download method which does somthing which takes time.

Question: The dialog box hangs around till that method is executed, how do we close it on clicking and later the method gets executed?

Thanks for any tip?

2

There are 2 best solutions below

0
On BEST ANSWER
def download(sender, sel, ptr)
  self.close
  # Do that which will take time. 
end

In fxruby you will create your own class and inherit FXMainWindow clss or any other class from the fxruby lib for example.

self will point to your class which actually creates the dialog box according to your example thus self.close will close the dialog box first and then you can continue the heavy work.

0
On

Dont have the rep to post a comment, so assume this is one. Have you tried to passed dwd_file as an argument to the download method, having the download method close the dialog box first, and then continue with whatever logic you intended it to execute? That should get rid of the dialog box without a problem unless your download method is relying on some element of dwd_file