-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
Textual apps require window content to run #2818
Comments
This came up recently in the context of #2473, there's some edge cases where it would be helpful to guarantee that |
I would like to give this a go! If I understand the codebase correctly the change should be made here, to check if the toga/textual/src/toga_textual/window.py Lines 114 to 119 in bd0a592
Sidenote: It's kind of hard to debug the Textual backend. I usually use the pdb debugger, but Textual completely hijacks the terminal window so that doesn't work at all. Any tips to overcome that? |
I've been using two different methods. Write to a log file on the App object: class HelloWorld(toga.App):
file = open(Path.home() / "toga_app_log.txt", "w")
@classmethod
def log(cls, msg: str):
cls.file.write(f"{msg}\n")
cls.file.flush() Or add |
Not quite. The issue is that right now, this is possible:
That's legal, but the Window has no content (i.e., What we need to do is ensure that at time of construction, the initial value of
Textual has some developer tools that involves running a second terminal that gives you access to the "console" that you'd normally see when running an app; see https://textual.textualize.io/guide/devtools/ for details. Run your Toga app with those tools, and it should be a lot easier to debug. |
So, I should instead make the change on the Window constructor on toga-core, right? |
Correct - along with updates to the tests in the toga-core package to validate the change (I suspect you'll find there's a test that will fail when you add a default widget). Also - make sure you have a read of the contribution guide (if you haven't already) - it's got lots of details of how to set up your development environment, and the other details you'll need to have in place in any pull request you submit. |
I can't find a way to provide a default value (an empty |
@cgkoutzigiannis Using
The output of the first call to
But the output of the second call to
And a third call would be
That is - the default value isn't instantiated on each call to the method - it's instantiated once, when the method is parsed. This doesn't matter when the object is a primitive like an integer or None, or an immutable object like a string; but when it's an object that can have state (like a list, dictionary... or a If you use So - using It has the additional benefit that |
Describe the bug
If a Toga textual app does not define any window content, the app will crash.
Steps to reproduce
Run this app:
Windows:
Expected behavior
Apps using the textual backend are not required to use window content.
Screenshots
No response
Environment
0.3.20.dev192+g32f529a4
0.4.7.dev43+g63480d545
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: