You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I upgraded to v0.1.11 and trying to run an app using v0.1.10 immediately crashed (no other changes were introduced, just the version bump:
❯ python main.py
Traceback (most recent call last):
File "/Users/josephlyons/Programming/Python/termifind/main.py", line 34, in<module>main()
File "/Users/josephlyons/Programming/Python/termifind/main.py", line 30, in main
TermiFindApplication.run(log="termifind.log")
File "/Users/josephlyons/Programming/Python/termifind/virtual_environment/lib/python3.10/site-packages/textual/app.py", line 187, in run
asyncio.run(run_app())
File "/Users/josephlyons/.pyenv/versions/3.10.0b3/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Users/josephlyons/.pyenv/versions/3.10.0b3/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
returnfuture.result()
File "/Users/josephlyons/Programming/Python/termifind/virtual_environment/lib/python3.10/site-packages/textual/app.py", line 184, in run_app
app = cls(console=console, screen=screen, driver_class=driver, **kwargs)
File "/Users/josephlyons/Programming/Python/termifind/main.py", line 14, in __init__
self.ui: UI = UI(self.path_container)
File "/Users/josephlyons/Programming/Python/termifind/src/ui/ui.py", line 22, in __init__
self.previous_directory_container_scroll_view: TermiFindScrollView = self.__get_scroll_view(
File "/Users/josephlyons/Programming/Python/termifind/src/ui/ui.py", line 38, in __get_scroll_view
item_buttons_view: TermiFindButtonsView = self.__get_item_buttons_view(directory_container, should_style_text)
File "/Users/josephlyons/Programming/Python/termifind/src/ui/ui.py", line 66, in __get_item_buttons_view
termifind_buttons_view.add(TermiFindButton(item_name_text))
File "/Users/josephlyons/Programming/Python/termifind/src/ui/custom_views.py", line 10, in add
self.layout.add(button)
File "/Users/josephlyons/Programming/Python/termifind/virtual_environment/lib/python3.10/site-packages/textual/layouts/vertical.py", line 27, in add
self._max_widget_width = max(widget.app.measure(widget), self._max_widget_width)
File "/Users/josephlyons/Programming/Python/termifind/virtual_environment/lib/python3.10/site-packages/textual/message_pump.py", line 58, in app
returnactive_app.get()
LookupError: <ContextVar name='active_app' at 0x1031a4f90>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='termifind.log' mode='wt' encoding='UTF-8'>
I will try to post a minimal working piece of code that causes the crash, just wanted to get this logged before I forgot about it.
I think I see the problem. You may be constructing widgets or views from the App constructor, prior to the asyncio context running. This may have worked in a previous version, but you will need to create widgets in a handler, on_mount is the best place for that.
That solved the original issue here. I have a few other issues that have come up, but I will close this one and open new issues if I can't solve it on my own. Thank you.
I upgraded to v0.1.11 and trying to run an app using v0.1.10 immediately crashed (no other changes were introduced, just the version bump:
I will try to post a minimal working piece of code that causes the crash, just wanted to get this logged before I forgot about it.
Repo & Branch I'm working on is here: https://github.com/JosephTLyons/termifind-python/tree/Continue-Adapting-Code-To-Use-Textual
The text was updated successfully, but these errors were encountered: