我一直在试图学习如何使用Kivy python,我想 知道如何与Os控制台/终端进行交互以运行命令,并且 会收到结果。目前为止我看到的教程仅显示如何创建 小部件,按钮等 例如,如何从运行显示在kivy中的命令“uname” 获得结果。下面有这样的代码。使用“按下”。我如何让它与操作系统交互运行命令并将其显示回kivy应用程序。是否有创建桌面应用/公用事业如何获取控制台输出使用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()
更新: 这里是例子我试着去achieve.This什么使用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")
[从python运行shell命令并捕获输出]可能的重复(http://stackoverflow.com/questions/4760215/running-shell-command-from-python-and-capturing-the-output) – 2014-10-08 19:48:13
不可以只是获取控制台输出..但使用可以与控制台交互的kivy构建一个gui应用程序 – mikie 2014-10-08 20:00:35
如果您刚刚学习kivy,这听起来像是一个相当复杂的项目。也许,子进程模块可以帮助? Google subprocess.call – Totem 2014-10-08 22:53:19