from typing import Callable
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QVBoxLayout, QWidget, QLabel
from PySide6.QtCore import QTimer
from Movie import Movie, createImage

class MovieButton(QWidget):
    """
    Buttons for selecting the movie on the main screen.
    Usage:
        MovieButton(Movie(...), self.show<Movie>)
    """

    def __init__(self, movie: Movie, callback: Callable[[], None]):
        super().__init__()
        
        layout = QVBoxLayout()
        
        self.movie: Movie = movie

        layout.addWidget(createImage(movie.image_path))
        layout.addWidget(QLabel(movie.name))

        self.setLayout(layout)
        self.callback: Callable[[], None] = callback


    def mousePressEvent(self, event: QMouseEvent):
        QTimer.singleShot(0, self.callback)

