# cPy qt_intro : image
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2026-01-24  initial release

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

# ========================== demo 1 ==============================

# most simple image on QLabel
class Gui1(QWidget):

    def __init__(self):
        app = QApplication()            # Qt framework
        super().__init__()              # instantiate QWidget = GUI
        self.resize(500, 300)
        lbl = QLabel(self)
        lbl.setGeometry(50, 50, 300, 200)
        pxm = QPixmap('forth_bridge.jpg')
        lbl.setPixmap(pxm)
        self.show()
        app.exec()


Gui1()

# ========================== demo 2 ==============================

# QLabel image scaled to size of label
class Gui2(QWidget):

    def __init__(self):
        app = QApplication()            # Qt framework
        super().__init__()              # instantiate QWidget = GUI
        self.resize(500, 300)
        lbl = QLabel(self)
        lbl.setGeometry(50, 50, 400, 200)
        pxm = QPixmap('forth_bridge.jpg')
        lbl.setPixmap(pxm.scaled(lbl.size()))
        self.show()
        app.exec()


#Gui2()

# ========================== demo 3 ==============================

# multiple images
class Gui3(QWidget):

    def __init__(self):
        app = QApplication()            # Qt framework
        super().__init__()              # instantiate QWidget = GUI
        self.resize(550, 350)
        self.pxm = QPixmap('forth_bridge.jpg')
        for pos in ((50, 50), (300, 50), (50, 200), (300, 200)):
            self.showImg(*pos)
        self.show()
        app.exec()


    def showImg(self, x, y):
        lbl = QLabel(self)
        lbl.setGeometry(x, y, 200, 100)
        lbl.setPixmap(self.pxm.scaled(lbl.size()))


#Gui3()

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