views:

35

answers:

1

Hi, I'm learning PyGTK and I have a parent window and a child window. Inside of a parent window's method, i create the child window and then I refresh a treeview... something like that:

def add_user(self, widget, data = None):
    save_user.SaveUser(self.window)
    self.load_tree_view()

But, when it's running, the child window appears and the load_tree_view() method is executed. I want that parent window wait until the child window is opened/showed. After that, load_tree_view runs ...

How can I do that? Thank you.

A: 

gtk.Dialog solves my problem but i don't know if is right use that ... When should I use a dialog?

#! /usr/bin/python

import pygtk
import gtk

class Window:
    def __init__(self):
        self.window = gtk.Window()
        self.window.connect('delete-event', self.close_window)
        self.window.show()
        self.dialog = gtk.Dialog()
        self.dialog.connect('delete-event', self.close_dialog)
        self.dialog.run()
        print 'after dialog...'
        gtk.main()

    def close_window(self, widget, data = None):
        gtk.main_quit()

    def close_dialog(self, widget, data = None):
        self.dialog.hide()

if __name__ == '__main__':
    Window()

"print 'after dialog...'" code only appears after when the dialog is closed. That is what I want.

Thank you.

dimy