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

15
Grzegorz.py Normal file
View File

@@ -0,0 +1,15 @@
import requests as rq
class Georg:
def __init__(self):
self.url = "https://georg-backend.pvv.ntnu.no"
self.currentlyPlaying = self.getCurrentlyPlaying()
def getCurrentlyPlaying(self):
return rq.get(f"{self.url}/api/play").json()["value"]
def togglePlay(self):
return rq.post(f"{self.url}/play?play={not self.getCurrentlyPlaying()}")

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,12 +1,21 @@
Hei
Denne tingen skal vise ting på en skjerm
## Denne tingen skal vise ting på en skjerm
![trykketing](https://cdn3.botland.store/112467-large_default/capacitive-touch-screen-ips-lcd-7-c-1024x600px-hdmi-usb-rev-41-for-raspberry-pi-case-black-and-white-waveshare-11303.jpg)
Og interagere med en api for å gjøre det.
(useful commands) https://georg-backend.pvv.ntnu.no/docs/#/
## Running
```
python3 screen.py
```
## Useful commands @
https://georg-backend.pvv.ntnu.no/docs/#/
```
|--| |--|
.._ o' o' (()))) _ o' o'

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