Setting/getting size #2200
Answered
by
willmcgugan
davidbrochart
asked this question in
Q&A
-
I'm trying to set the size of the terminal, but the application takes the size of my terminal anyway. Also, printing the size of the widget shows from textual.app import App, ComposeResult
from textual.widgets import Static
class MyStatic(Static):
def on_mount(self):
print(self.size)
class MyApp(App):
def compose(self) -> ComposeResult:
yield MyStatic("\n".join([f"{i} " * 100 for i in range(100)]))
if __name__ == "__main__":
app = MyApp()
app.run(size=(10, 10)) |
Beta Was this translation helpful? Give feedback.
Answered by
willmcgugan
Apr 2, 2023
Replies: 1 comment 9 replies
-
The The widget size will be (0, 0) on mount because you get the mount prior to the first layout. What behaviour were you expecting by setting the size on run? |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
davidbrochart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
size
argument was mainly for situations where there isn't a physical terminal, like testing. We could make that clearer in the docs.The widget size will be (0, 0) on mount because you get the mount prior to the first layout.
What behaviour were you expecting by setting the size on run?