我一直在尝试学习如何使用Kivy python,并想知道如何与操作系统控制台/终端进行交互以运行命令和接收结果。到目前为止,我看到的教程只展示了如何创建小部件、按钮等。例如,如何在Kivy中显示运行命令"uname"的结果。使用以下代码,在“按下”时如何让它与操作系统进行交互,运行命令并将其显示回Kivy应用程序?是否有关于创建桌面应用程序/实用工具的教程?
from kivy.app import App
from kivy.uix.button import Button
class tutap(App):
def build(self):
return Button(text="Press here")
tutap().run()
更新: 以下是我想要实现的示例。这个示例使用了easygui模块:
import subprocess
from easygui import *
msg= "what you want"
out = subprocess.check_output("uname -a",shell=True)
title = "My choice"
choices=["kernel version","nothing"]
choice=boolbox(msg,title,choices)
if choice==1:
msgbox(out)
elif choice==0:
msgbox("The End")