Static works but TextLog raises NoActiveAppError() #2103
-
I am having a strange issue. I building an application to monitor some devices over MQTT and, after stumbling on Textual, I really want to use it . I do have a strange issue. The application is started with
The application includes a method used by the dispatcher to update some panel. The method reads:
If I define the panel with
It all work as expected, but the output has no scrollbar, .... If I define the panel with
A NoActiveAppError() exception is raised. I tried to subclass TextLog, to insert TextLog directly ( and have "output_update" do the clear/write.) but to no avail. Any suggestion? How could I get 'Static' to scroll? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You could add a container like
I'm afraid I don't really understand what the rest of your app might be doing, but I found this issue which might be helpful? from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Footer, Static
class OutputApp(App):
CSS = """
Screen {
align: center middle;
}
#cmd-console {
width: auto;
min-height: 100%;
}
VerticalScroll {
height: 30;
overflow: auto;
border: round $primary;
}
"""
BINDINGS = [
("space", "send_message", "Send message to output"),
]
def compose(self) -> ComposeResult:
yield VerticalScroll(Static(id="cmd-console"))
yield Footer()
def output_update(self, msg: str) -> None:
cmd_console = self.query_one("#cmd-console", Static)
cmd_console.update(msg)
def action_send_message(self) -> None:
self.output_update(TEXT * 10)
TEXT = """[bold red]I must not fear.[/bold red]
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.
""" |
Beta Was this translation helpful? Give feedback.
-
Thanks. Even if it does not explain why Static works and TextLog does not, I updated to v0.16 and your recommendation to use VerticalScroll works good. So I marked as "answered". Thanks again. |
Beta Was this translation helpful? Give feedback.
You could add a container like
Vertical
orVerticalScroll
depending on your version of Textual (the latter has only just been released in v0.16). See below for a quick example.I'm afraid I don't really understand what the rest of your app might be doing, but I found this issue which might be helpful?