# cPy qt_intro : huiswerk opgave, switch 2 fotos m.b.v. buttons
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2026-03-11  initial release

from    PySide6.QtWidgets   import  QApplication, QWidget, QLabel, QPushButton
from    PySide6.QtGui       import  QPixmap

# ======================= foto switcher ===========================

class Gui(QWidget):

    # setup GUI for photo switcher
    def __init__(self):
        app = QApplication()            # Qt framework
        super().__init__()              # instantiate QWidget = GUI
        self.resize(1200, 800)
        self.foto = QLabel(self)
        self.foto.setGeometry(50, 50, 1100, 650)
        self.pxm0 = QPixmap('perth_tay_view.jpg').scaled(self.foto.size())
        self.pxm1 = QPixmap('perth_kinnoull-hill.jpg').scaled(self.foto.size())
        self.foto.setPixmap(self.pxm0)
        btn = QPushButton('Foto 1', self)
        btn.setGeometry(50, 730, 150, 40)
        btn.clicked.connect(self.onBtnClick)
        btn = QPushButton('Foto 2', self)
        btn.setGeometry(1000, 730, 150, 40)
        btn.clicked.connect(self.onBtnClick)
        self.show()
        app.exec()


    # button onClick handler
    def onBtnClick(self, sts):
        capt = self.sender().text()
        print(capt)
        if capt == 'Foto 1': self.foto.setPixmap(self.pxm0)
        else               : self.foto.setPixmap(self.pxm1)

        
Gui()

# ============================== end ================================
