# Introduction to Qt - demonstrating slot and signal
# by Anthony Vogelaar, Perth Scotland
# rev 0.10  2024-03-31  Initial release

import  os, sys;            os.system('clear')
from    PySide6.QtWidgets   import  QApplication
from    PySide6.QtCore      import  QObject
import  time

# ================================= Local ========================================

def printHello():
    print('Closing down')
    sys.exit()

# ================================== GUI =========================================

class GUI(QObject):

    def __init__(self):
        super().__init__()
        self.destroyed.connect(printHello)          # using signal destroid
        print('sleep for 2 seconds')
        time.sleep(2)
        self.deleteLater()                          # trigger slot deleteLater
        print('done')

# ================================ Main ==========================================

gui = GUI()
print('---')
app = QApplication([])                          # Instantiate Qt framework
print('...')
app.exec()                                      # start Qt thread

# ================================= End ==========================================
