Hello,

I am creating a dialog in a callback function. Is there a way to make
the dialog window disappear before the callback function returns?

I do not care if the main window keeps unresponsive, I just want the
dialog to disappear.

Here is a small sample script to demonstrate what I mean:
#!/usr/bin/env python

import pygtk
import gtk
import time

class View(gtk.Window):

    def __init__(self):
        super(View, self).__init__(gtk.WINDOW_TOPLEVEL)

        self.connect("delete_event", lambda *a: False)
        self.connect("destroy", gtk.main_quit)
        self.set_border_width(10)
        self.set_title('Look at this')

        button = gtk.Button("Do stuff")
        button.connect('clicked', self.do_stuff)

        self.add(button)
        self.show_all()

    def do_stuff(self, *a):
        if not self.yes_or_cancel_dialog('Question', 'Really do stuff? (may take a while)'):
            return

        # TODO: Call mysterious function that makes the dialog disappear

        # Do something
        time.sleep(5)

    def yes_or_cancel_dialog(self, title, text):
        dialog = gtk.Dialog(title, self, gtk.DIALOG_MODAL,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        label = gtk.Label(text)
        label.show()
        dialog.vbox.pack_start(label)
        response = dialog.run()
        dialog.destroy()

        return response == gtk.RESPONSE_ACCEPT


if __name__ ==  '__main__':
    view = View()
    gtk.main()
I would like to have the dialog window disappear *before* the
time.sleep() in do_stuff() finishes. Is that possible?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to