import sys
import json
import random
import requests as rq
from Grzegorz import *
from PySide6 import QtCore, QtWidgets, QtGui

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

        self.acceptDrops() # what is this?

        self.georg = Georg()

        self.playButton = QtWidgets.QPushButton("pause" if self.georg.getCurrentlyPlaying() else "play")
        self.text = QtWidgets.QLabel("Hello World",
                                     alignment=QtCore.Qt.AlignCenter)

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

        self.playButton.clicked.connect(self.pausePlay)

        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))

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

    @QtCore.Slot()
    def pausePlay(self):
        self.georg.togglePlay()

        if self.georg.getCurrentlyPlaying():
            print("player set to play")
            self.label.setMovie(self.movie)
            self.movie.start()

        else:
            print("player set to pause")
            self.label.setPixmap(self.pixmap)

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


