import sys

from gi.repository import Gio, Gtk

class App(Gtk.Application):

    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.gnome.example",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)

        self.window = None

        self.connect("activate", self.activateCb)

    def activateCb(self, app):
        if self.window:
            print self, 1
            self.window.present()
            return
        print self, 2
        self.window = Gtk.ApplicationWindow()
        app.add_window(self.window)
        self.window.show()

        window2 = Gtk.ApplicationWindow()
        window2.set_transient_for(self.window)
        window2.show()


if __name__ == '__main__':
    app = App()
    app.run(sys.argv)