-
Notifications
You must be signed in to change notification settings - Fork 815
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
ModalScreen takes the size of the terminal window when it was first opened and not its current size #5118
Comments
Code used in the video from textual.app import App, ComposeResult
from textual.containers import (
Grid,
)
from textual import work
from textual.widgets import Label, Button
from textual.screen import ModalScreen
class ErrorMessage(ModalScreen):
DEFAULT_CSS = """
ErrorMessage {
align: center middle;
}
#ErrorPopup {
align: center middle;
grid-size: 1 3;
width: 80;
height: 20;
padding: 2;
grid-rows: 1 1fr 3;
}
.center {
content-align: center middle;
}
.label {
height: 1fr;
width: 1fr;
}
.btn {
width: 100%;
}
"""
def __init__(self, errormsg: str = "", *args, **kwargs):
self.errormsg = errormsg
super().__init__(*args, **kwargs)
def compose(self) -> ComposeResult:
with Grid(id="ErrorPopup"):
yield Label("Error!", classes="center label")
yield Label("ErrorMSG", id="ErrorMsg", classes="center label")
yield Button("Okay", variant="error", id="Okay", classes="btn")
def on_mount(self):
self.query_one("#ErrorMsg", Label).update(self.errormsg)
def on_button_pressed(self, event: Button.Pressed):
self.dismiss()
class App(App):
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Button("Open Modal", id="btn")
@work(exclusive=True)
async def on_button_pressed(self, event: Button.Pressed):
if event.button.id == "btn":
self.push_screen(ErrorMessage(errormsg="This is an error message."))
if __name__ == "__main__":
app = App()
app.run() |
I can't reproduce this on macOS or Windows. Can you try with the latest Windows Terminal? https://apps.microsoft.com/detail/9n0dx20hk701?hl=en-gb&gl=US Screen.Recording.2024-10-14.at.15.21.53.mov |
Initially Tested on Windows Terminal Version 1.20.11781.0 Updated to Windows Terminal Version 1.21.2701.0 (from GitHub): Bug Still Occurs 2024-10-14.22-35-25.mp4 |
Clink (https://github.com/chrisant996/clink) conflicts with Textual. When Clink is disabled, the functionality works properly 2024-10-14.22-48-26.mp4 |
ModalScreen takes the size of the terminal window when the program was first opened and not its current size.
2024-10-14.21-53-59.mp4
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: