ModalScreen background #3971
-
|
As I have followed the documentation, when using modal screen it's supposed to show previous interface in background after push_screen() . https://textual.textualize.io/guide/screens/#modal-screens I have the same code as doc but it doesn't show anything in background just blank with color. class MyDialog(ModalScreen):
yield Grid(
Label("How was your day?", id="question"),
Button("Good", variant="primary", id="good"),
Button("Nahhh", variant="error", id="nah"),
id="dialog"
)
class MyScreen(Screen):
def compose(self) -> ComposeResult:
# some code
def on_key(self, event):
if event.key == "s":
self.app.push_screen(MyDialog())
class Main(App):
def on_mount(self, event) :
# some code
self.install_screen(MyScreen, "myscreen")
self.push_screen("myscreen")Is it because I use MyDialog in Screen |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
MyDialog Is probably using the entire terminal. Set its dimensions via stylesheet and you’ll see the screen behind it. You can see in the tcss pane of the ModalScreen example they have specified the dialog grid dimensions. |
Beta Was this translation helpful? Give feedback.
-
|
It works now. The problem was because I didn't set the background in MyDialog style which can be found via this https://textual.textualize.io/blog/2023/03/29/textual-0170-adds-translucent-screens-and-option-list/#translucent-screens |
Beta Was this translation helpful? Give feedback.
MyDialog Is probably using the entire terminal. Set its dimensions via stylesheet and you’ll see the screen behind it.
You can see in the tcss pane of the ModalScreen example they have specified the dialog grid dimensions.