diff --git a/Grzegorz.py b/Grzegorz.py new file mode 100644 index 0000000..4c7b664 --- /dev/null +++ b/Grzegorz.py @@ -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()}") diff --git a/__pycache__/Grzegorz.cpython-310.pyc b/__pycache__/Grzegorz.cpython-310.pyc new file mode 100644 index 0000000..877ccb7 Binary files /dev/null and b/__pycache__/Grzegorz.cpython-310.pyc differ diff --git a/__pycache__/georg.cpython-310.pyc b/__pycache__/georg.cpython-310.pyc new file mode 100644 index 0000000..ca625bd Binary files /dev/null and b/__pycache__/georg.cpython-310.pyc differ diff --git a/__pycache__/widget.cpython-310.pyc b/__pycache__/widget.cpython-310.pyc new file mode 100644 index 0000000..efed782 Binary files /dev/null and b/__pycache__/widget.cpython-310.pyc differ diff --git a/readme.md b/readme.md index d601af9..9d2e3ed 100644 --- a/readme.md +++ b/readme.md @@ -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' diff --git a/widget.py b/widget.py index a68de6a..cc1cab1 100644 --- a/widget.py +++ b/widget.py @@ -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())