The following script
import logging
from rich.console import Console
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.geometry import Offset
from textual.widgets import Label, Footer
logger = logging.getLogger(__name__)
console = Console()
class Dialog(Container):
def compose(self) -> ComposeResult:
self.content = Container(
Label('This is in the dialog layer'),
id="dialog",
)
yield self.content
DIALOG_LEFT = (console.width - 32) // 2
DIALOG_TOP = (console.height - 3) // 2
class MyApp(App):
CSS = '''
#dialog {
content-align: center middle;
border: solid brown;
background: ansi_white;
height: 3;
width: 32;
}
#dialog Label {
text-align: center;
color: ansi_red;
}
Dialog {
offset: %s %s;
layer: dialog;
visibility: hidden;
}
Screen {
layers: base dialog;
}
''' % (DIALOG_LEFT, DIALOG_TOP)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dialog = Dialog()
self.dialog.visible = False
def compose(self):
yield Container(Label('This is in the base layer'))
yield self.dialog
app = MyApp()
app.run()
Even though the visibility of the Dialog
widget should be hidden, it still shows - can anyone tell me why, and how to actually hide it? Here’s the display: