Closed
Description
Outputs from os.system
or subprocess.call
are not captured by textual, and appear at the top-left of the terminal instead.
My goal is to run scripts upon button presses, and to see the scripts' outputs in a Log widget in realtime.
textual diagnose
didn't recognize my terminal. I am using Windows Terminal version 1.21.2911.0, but I have the same issue using the legacy terminal (by selecting "Windows Console Host" in Windows 11 settings). The issue is there using PowerShell 7.4.6 or MS-DOS for the terminal. Note that os.system
runs MS-DOS.
Here is a video, and the MRE can be found below.
textual.mp4
from textual.app import App
from textual.widgets import Log
import os
class MyApp(App):
def compose(self):
yield Log(id="log")
def on_print(self, event):
self.query_one("#log", Log).write(event.text)
def on_key(self, event):
if event.key == 'q':
print('q was pressed')
elif event.key == 'w':
os.system("echo w was pressed")
def on_ready(self):
self.begin_capture_print(self, True, True)
if __name__ == "__main__":
app = MyApp()
app.run()
Textual Diagnostics
Versions
Name | Value |
---|---|
Textual | 0.85.2 |
Rich | 13.9.3 |
Python
Name | Value |
---|---|
Version | 3.12.5 |
Implementation | CPython |
Compiler | MSC v.1940 64 bit (AMD64) |
Executable | C:\Program Files\Python312\python.exe |
Operating System
Name | Value |
---|---|
System | Windows |
Release | 11 |
Version | 10.0.22631 |
Terminal
Name | Value |
---|---|
Terminal Application | Unknown |
TERM | Not set |
COLORTERM | Not set |
FORCE_COLOR | Not set |
NO_COLOR | Not set |
Rich Console options
Name | Value |
---|---|
size | width=120, height=30 |
legacy_windows | False |
min_width | 1 |
max_width | 120 |
is_terminal | True |
encoding | utf-8 |
max_height | 30 |
justify | None |
overflow | None |
no_wrap | False |
highlight | None |
markup | None |
height | None |
Metadata
Metadata
Assignees
Labels
No labels