If we run the code below, a window with a button inside will be created, which whenever clicked will open another window (Window2). How can I make a second instance of Window2 not be allowed? I want to do this without using modal ().
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from gi.repository import Gtk
class Main(Gtk.Window):
def __init__(self):
button = Gtk.Button('Click')
Gtk.Window.__init__(self, title = 'Main Window')
button.connect('clicked', Window2)
self.connect('delete-event', Gtk.main_quit)
self.set_default_size(300, 200)
self.add(button)
self.show_all()
class Window2(Gtk.Window):
def __init__(self, widget):
button = Gtk.Button('Exit')
Gtk.Window.__init__(self, title = 'Window2')
button.connect('clicked', Gtk.main_quit)
self.set_default_size(300, 200)
self.add(button)
self.show_all()
if __name__ == '__main__':
Main()
Gtk.main()