added push button ui
This commit is contained in:
BIN
assets/images/rick.png
Normal file
BIN
assets/images/rick.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/images/ricky.gif
Normal file
BIN
assets/images/ricky.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 MiB |
@@ -5,6 +5,7 @@ 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/#/
|
||||
```
|
||||
|--| |--|
|
||||
.._ o' o' (()))) _ o' o'
|
||||
|
||||
10
screen.py
Normal file
10
screen.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from widget import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([])
|
||||
|
||||
widget = MyWidget()
|
||||
widget.resize(800, 600)
|
||||
widget.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
45
widget.py
Normal file
45
widget.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import sys
|
||||
import random
|
||||
from PySide6 import QtCore, QtWidgets, QtGui
|
||||
|
||||
class MyWidget(QtWidgets.QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.acceptDrops()
|
||||
|
||||
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
|
||||
self.imgs = ["assets/images/rick.png", "assets/images/ricky.gif"]
|
||||
|
||||
self.button = QtWidgets.QPushButton("Click me!")
|
||||
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.button.clicked.connect(self.magic)
|
||||
|
||||
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)
|
||||
|
||||
@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:
|
||||
self.label.setMovie(self.movie)
|
||||
self.movie.start()
|
||||
|
||||
#self.label.resize(self.pixmap.width(),self.pixmap.height())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user