added Georg class and implemented functioning pause/play button
This commit is contained in:
15
Grzegorz.py
Normal file
15
Grzegorz.py
Normal 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()}")
|
||||
BIN
__pycache__/Grzegorz.cpython-310.pyc
Normal file
BIN
__pycache__/Grzegorz.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/georg.cpython-310.pyc
Normal file
BIN
__pycache__/georg.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/widget.cpython-310.pyc
Normal file
BIN
__pycache__/widget.cpython-310.pyc
Normal file
Binary file not shown.
13
readme.md
13
readme.md
@@ -1,12 +1,21 @@
|
||||
Hei
|
||||
|
||||
Denne tingen skal vise ting på en skjerm
|
||||
## Denne tingen skal vise ting på en skjerm
|
||||
|
||||

|
||||
|
||||
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'
|
||||
|
||||
34
widget.py
34
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())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user