Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Do you want to quit?" notification won't show when ModalScreen is pushed to the top #5474

Open
peppedilillo opened this issue Jan 15, 2025 · 3 comments

Comments

@peppedilillo
Copy link

peppedilillo commented Jan 15, 2025

Have you checked closed issues? https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed

yes

Have you checked against the most recent version of Textual? https://pypi.org/search/?q=textual

yes, tested on textual 1.0.0.

Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.

As per title, the "Do you want to quit?" notification won't show when a ModalScreen is pushed to the top and ctrl+c is pressed.
This is reproduced using the ModalScreen doc example:

from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.screen import ModalScreen
from textual.widgets import Button, Footer, Header, Label

TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""


class QuitScreen(ModalScreen):
    """Screen with a dialog to quit."""

    def compose(self) -> ComposeResult:
        yield Grid(
            Label("Are you sure you want to quit?", id="question"),
            Button("Quit", variant="error", id="quit"),
            Button("Cancel", variant="primary", id="cancel"),
            id="dialog",
        )

    def on_button_pressed(self, event: Button.Pressed) -> None:
        if event.button.id == "quit":
            self.app.exit()
        else:
            self.app.pop_screen()


class ModalApp(App):
    """An app with a modal dialog."""

    CSS_PATH = "modal01.tcss"
    BINDINGS = [("q", "request_quit", "Quit")]

    def compose(self) -> ComposeResult:
        yield Header()
        yield Label(TEXT * 8)
        yield Footer()

    def action_request_quit(self) -> None:
        """Action to display the quit dialog."""
        self.push_screen(QuitScreen())


if __name__ == "__main__":
    app = ModalApp()
    app.run()

Note that the same problem does not happen when pushing Screen (in place of ModalScreen).

Diagnostic output:

<!-- This is valid Markdown, please paste the following directly in to a GitHub issue -->
# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 1.0.0  |
| Rich    | 13.9.4 |

## Python

| Name           | Value                                                 |
|----------------|-------------------------------------------------------|
| Version        | 3.11.11                                               |
| Implementation | CPython                                               |
| Compiler       | Clang 14.0.6                                          |
| Executable     | /Users/peppedilillo/anaconda3/envs/misfits/bin/python |

## Operating System

| Name    | Value                                                                                                 |
|---------|-------------------------------------------------------------------------------------------------------|
| System  | Darwin                                                                                                |
| Release | 24.2.0                                                                                                |
| Version | Darwin Kernel Version 24.2.0: Fri Dec  6 18:40:14 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8103 |

## Terminal

| Name                 | Value           |
|----------------------|-----------------|
| Terminal Application | ghostty (1.0.1) |
| TERM                 | xterm-ghostty   |
| COLORTERM            | truecolor       |
| FORCE_COLOR          | *Not set*       |
| NO_COLOR             | *Not set*       |

## Rich Console options

| Name           | Value               |
|----------------|---------------------|
| size           | width=88, height=28 |
| legacy_windows | False               |
| min_width      | 1                   |
| max_width      | 88                  |
| is_terminal    | False               |
| encoding       | utf-8               |
| max_height     | 28                  |
| justify        | None                |
| overflow       | None                |
| no_wrap        | False               |
| highlight      | None                |
| markup         | None                |
| height         | None                |

Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

TomJGooding commented Jan 15, 2025

I can't see a "Do you want to quit?" notification in the example above, did you perhaps paste the wrong code?

Edit: Sorry, I've just read the issue again and realise now you mean the 'quit help' notified by default when you try to quit with Ctrl+C. Ignore me!

@peppedilillo
Copy link
Author

I can't see a "Do you want to quit?" notification in the example above, did you perhaps paste the wrong code?

Edit: Sorry, I've just read the issue again and realise now you mean the 'quit help' notified by default when you try to quit with Ctrl+C. Ignore me!

Yes I'm referring to this. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants