Skip to content

confirmation

ConfirmationPopUp #

Bases: Container

A Pop Up that asks for confirmation

Source code in browsr/widgets/confirmation.py
class ConfirmationPopUp(Container):
    """
    A Pop Up that asks for confirmation
    """

    __confirmation_message__: str = dedent(
        """
        ## File Download

        Are you sure you want to download that file?
        """
    )

    class ConfirmationWindowDownload(Message):
        """
        Confirmation Window
        """

    class ConfirmationWindowDisplay(Message):
        """
        Confirmation Window
        """

        def __init__(self, display: bool) -> None:
            self.display = display
            super().__init__()

    class DisplayToggle(Message):
        """
        TableView Display
        """

    def compose(self) -> ComposeResult:
        """
        Compose the Confirmation Pop Up
        """
        self.download_message = Static(Markdown(""))
        yield self.download_message
        yield Button("Yes", variant="success")
        yield Button("No", variant="error")

    @on(Button.Pressed)
    def handle_download_selection(self, message: Button.Pressed) -> None:
        """
        Handle Button Presses
        """
        self.post_message(self.ConfirmationWindowDisplay(display=False))
        if message.button.variant == "success":
            self.post_message(self.ConfirmationWindowDownload())
        self.post_message(self.DisplayToggle())

ConfirmationWindowDisplay #

Bases: Message

Confirmation Window

Source code in browsr/widgets/confirmation.py
class ConfirmationWindowDisplay(Message):
    """
    Confirmation Window
    """

    def __init__(self, display: bool) -> None:
        self.display = display
        super().__init__()

ConfirmationWindowDownload #

Bases: Message

Confirmation Window

Source code in browsr/widgets/confirmation.py
class ConfirmationWindowDownload(Message):
    """
    Confirmation Window
    """

DisplayToggle #

Bases: Message

TableView Display

Source code in browsr/widgets/confirmation.py
class DisplayToggle(Message):
    """
    TableView Display
    """

compose() #

Compose the Confirmation Pop Up

Source code in browsr/widgets/confirmation.py
def compose(self) -> ComposeResult:
    """
    Compose the Confirmation Pop Up
    """
    self.download_message = Static(Markdown(""))
    yield self.download_message
    yield Button("Yes", variant="success")
    yield Button("No", variant="error")

handle_download_selection(message) #

Handle Button Presses

Source code in browsr/widgets/confirmation.py
@on(Button.Pressed)
def handle_download_selection(self, message: Button.Pressed) -> None:
    """
    Handle Button Presses
    """
    self.post_message(self.ConfirmationWindowDisplay(display=False))
    if message.button.variant == "success":
        self.post_message(self.ConfirmationWindowDownload())
    self.post_message(self.DisplayToggle())

ConfirmationWindow #

Bases: Container

Window containing the Confirmation Pop Up

Source code in browsr/widgets/confirmation.py
class ConfirmationWindow(Container):
    """
    Window containing the Confirmation Pop Up
    """

    @on(ConfirmationPopUp.ConfirmationWindowDisplay)
    def handle_confirmation_window_display(
        self, message: ConfirmationPopUp.ConfirmationWindowDisplay
    ) -> None:
        """
        Handle Confirmation Window Display
        """
        self.display = message.display

handle_confirmation_window_display(message) #

Handle Confirmation Window Display

Source code in browsr/widgets/confirmation.py
@on(ConfirmationPopUp.ConfirmationWindowDisplay)
def handle_confirmation_window_display(
    self, message: ConfirmationPopUp.ConfirmationWindowDisplay
) -> None:
    """
    Handle Confirmation Window Display
    """
    self.display = message.display