这是我正在处理的 Quickly 应用程序代码的摘录:
# Code for other initialization actions should be added here.
self.apachestart = self.builder.get_object("apachestart")
self.label1 = self.builder.get_object("label1")
def on_apachestart_clicked(self, widget):
subprocess.call(['sudo', 'service', 'apache2', 'start'])
Run Code Online (Sandbox Code Playgroud)
现在,当我按下按钮启动 Apache(名为apachestart
)时,它会在服务器启动的终端中打印为标准输出:
* Starting web server apache2 [ OK ]
Run Code Online (Sandbox Code Playgroud)
如何从终端获取要显示在标签中的文本输出?