#!/usr/bin/python import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk dirty = False class Handler: def onDestroy(self, *args): Gtk.main_quit() def onQuit(self, *args): if dirty: """ show warning """ self.onDestroy(self, args) builder = Gtk.Builder() builder.add_from_file("lensdatabase.ui") builder.connect_signals(Handler()) window = builder.get_object("main_window") window.show_all() Gtk.main()