added Georg class and implemented functioning pause/play button

This commit is contained in:
Thomaajo
2025-06-10 18:28:02 +02:00
parent c3905fb61b
commit 49a525c13f
6 changed files with 45 additions and 17 deletions

View File

@@ -1,45 +1,49 @@
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()
self.acceptDrops() # what is this?
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
self.imgs = ["assets/images/rick.png", "assets/images/ricky.gif"]
self.georg = Georg()
self.button = QtWidgets.QPushButton("Click me!")
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.button)
self.layout.addWidget(self.playButton)
self.button.clicked.connect(self.magic)
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))
img = "images.rick.png"
self.movie = QtGui.QMovie("images/ricky.gif")
self.pixmap = QtGui.QPixmap(img)
self.movie = QtGui.QMovie("assets/images/ricky.gif")
self.pixmap = QtGui.QPixmap("assets/images.rick.png")
@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:
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())