提问人:user22758952 提问时间:11/13/2023 最后编辑:user22758952 更新时间:11/13/2023 访问量:32
我正在尝试在 Python 中创建一个 GUI,它将接受 bash 命令并显示所有内容,包括图形输出
I'm trying to create a GUI in Python which would accept a bash command and would display everything including graphical outputs
问:
我正在尝试在 Python 中创建一个 GUI,它将接受这样的 bash 命令并显示此命令的所有输出,包括任何图形。python OK21.py
如果我从命令行运行这个python OK21.py
它确实这样做了,但是当尝试从 GUI 执行此操作时,如下所示:
# import required modules
import os
import pyautogui
# prompts message on screen and gets the command
# value in val variable
value = pyautogui.prompt("Enter Shell Command")
# executes the command and returns
# the output in stream variable
stream = os.popen(value)
# reads the output from stream variable
out = stream.read()
pyautogui.alert(out)
它仅显示文本输出,省略了存在的图形窗口。编辑 最好的解决方案是在不将任何图像保存到文件的情况下执行此操作。但是,如果这可以自动完成,这对我来说可能是一个很好的解决方案。
此外,由于某些原因,我有并且无法升级。png
python 3.6.13
答: 暂无答案
评论
screen capture
import pyautogui im1 = pyautogui.screenshot() im1.save(r"C:/Users/Hynek/Desktop/Untitled.png")