简体   繁体   English

如何在GUI中启动另一个程序(python tkinter)

[英]How to launch another program in GUI (python tkinter)

i wrote a simple GUI using Python Tkinter. 我使用Python Tkinter编写了一个简单的GUI。 When i click a button it launches another program. 当我单击一个按钮时,它将启动另一个程序。 But the GUI window stays there waiting for the the program to exit. 但是GUI窗口停留在那里,等待程序退出。 I want the GUI to launch the program on Button1 and I can click on Button2 to run the test. 我希望GUI在Button1上启动程序,然后单击Button2来运行测试。 I used os.system() to launch the program. 我使用os.system()启动程序。 Pls advise. 请建议。

thanks maximus 感谢maximus

Yes, os.system() will wait. 是的, os.system()将等待。

As the documentation for os.system() points out, you might want to replace it by using the subprocess module, where there are many different ways to start commands and where you can choose if you want to wait for it to finish or not. 正如os.system()的文档所指出的那样,您可能希望使用子流程模块来替换它,那里有很多不同的方式来启动命令,并且可以选择是否等待它完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM