import sys
import random
from PySide6 import QtCore, QtWidgets, QtGui

class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        self.acceptDrops()

        self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
        self.imgs = ["assets/images/rick.png", "assets/images/ricky.gif"]

        self.button = QtWidgets.QPushButton("Click me!")
        self.text = QtWidgets.QLabel("Hello World",
                                     alignment=QtCore.Qt.AlignCenter)

        self.layout = QtWidgets.QVBoxLayout(self)
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)

        self.button.clicked.connect(self.magic)

        self.label = QtWidgets.QLabel(self)
        self.label.setGeometry(QtCore.QRect(25, 25, 200, 200))
        self.label.setMinimumSize(QtCore.QSize(500, 500))
        self.label.setMaximumSize(QtCore.QSize(500, 500))

        img = "images.rick.png"
        self.movie = QtGui.QMovie("images/ricky.gif")
        self.pixmap = QtGui.QPixmap(img)

    @QtCore.Slot()
    def magic(self):
        self.text.setText(random.choice(self.hello))
        ii = random.choice([1,2])
        if ii == 1:
            self.label.setPixmap(self.pixmap)
        else:
            self.label.setMovie(self.movie)
            self.movie.start()

        #self.label.resize(self.pixmap.width(),self.pixmap.height())


