How do I get textual app restarted after running a subprocess #1654
Unanswered
WaylonWalker
asked this question in
Q&A
Replies: 3 comments 3 replies
-
nevermind, found the issue |
Beta Was this translation helpful? Give feedback.
0 replies
-
If I'm understanding your question correctly, I think this PR that is in the works right now will help here (once live in Textual). |
Beta Was this translation helpful? Give feedback.
2 replies
-
Not sure if this is correct, but I was able to get control back with stop_application_mode and start_application_mode def action_edit(self):
prompt = {"prompt": "this is the prompt"}
editor = os.environ.get("EDITOR", "vim")
file = tempfile.NamedTemporaryFile(prefix="lockhart", suffix=".toml")
file.write(tomlkit.dumps(prompt).encode())
file.seek(0)
self._driver.stop_application_mode()
with subprocess.Popen([editor, file.name]) as proc:
proc.wait()
self.refresh()
self._driver.start_application_mode() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to build a textual app to explore objects, I want the ability to edit them with the users text editor of choice. I put a POC into the tutorial, I am able to open the editor in a subprocess, and refresh textual, but I am unable to get textual to respond after the editor is closed.
Here is my POC, at the action_edit
https://github.com/WaylonWalker/textual-tutorial/blob/8b7e27d5c68cc69fcea3a8a2bccde215e6917589/textual_tutorial/tui.py#L118
I recorded a short clip of it running. I hit the edit key around 0:27 and after the editor is closed, textual is unresponsive.
textual-locked.webm
Beta Was this translation helpful? Give feedback.
All reactions