38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
|
|
from PySide6.QtWidgets import QWidget, QLabel
|
||
|
|
from PySide6.QtGui import QPixmap
|
||
|
|
from typing import final
|
||
|
|
|
||
|
|
@final
|
||
|
|
class Movie:
|
||
|
|
"""
|
||
|
|
Describes a movie which will be displayed in the GUI.
|
||
|
|
Usage:
|
||
|
|
Movie("Movie name", <Movie price>, "Path to movie cover image")
|
||
|
|
"""
|
||
|
|
def __init__(self, name: str, price: float, image_path: str, description: str):
|
||
|
|
self.name = name
|
||
|
|
self.price = price
|
||
|
|
self.image_path = image_path
|
||
|
|
self.description = description
|
||
|
|
|
||
|
|
def createImage(filename: str) -> QLabel:
|
||
|
|
"""
|
||
|
|
Creates an image (in form of a QLabel) from a provided filename.
|
||
|
|
The filename must be a path to the image file.
|
||
|
|
It does not have to be an absolute path.
|
||
|
|
"""
|
||
|
|
label = QLabel()
|
||
|
|
pixmap = QPixmap(filename)
|
||
|
|
label.setPixmap(pixmap.scaled(300, 450))
|
||
|
|
return label
|
||
|
|
|
||
|
|
"""
|
||
|
|
Dictionary mapping strings (movie ID's) to Movie() objects.
|
||
|
|
"""
|
||
|
|
movies = {
|
||
|
|
"spiderman": Movie("Spider-Man: Very far from home", 39.95, "resources/spiderman.png", "spiderman, spiderman, he's a spider, and he's a man"),
|
||
|
|
"cars2": Movie("Cars 2", 79.95, "resources/cars2.png", "I am speed"),
|
||
|
|
"leo": Movie("The Nerd Movie", -189.95, "resources/leo.png", "Did you know that the quadratic formula is negative b plus or minus square root of b squared minus 4 a c all divided by 2 a"),
|
||
|
|
"hairypotty": Movie("Harry Potter and the Deathly Weapons", 447.95, "resources/hairypotty.png", "Dobby's got a glock")
|
||
|
|
}
|