如何在 Tkinter 中执行 Python 程序 [英] How to execute a Python program in Tkinter

查看:46
本文介绍了如何在 Tkinter 中执行 Python 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 Tkinter GUI,只有一个按钮,当按下按钮时,我希望它运行我用 Python 编写的另一个程序.

I have a simple Tkinter GUI, with one button and when the button is pushed I want it to run another program that I have written in Python.

 def openProgram ():
     #open up MyProgram.py

 MGui = Tk()
 MGui.geometry('450x450')

 mbutton = Button(text = "Go", command = openProgram).pack()

看起来很简单,也许我没有搜索正确的术语.

Seems easy enough, maybe I am not searching the correct terms.

推荐答案

尝试使用 os.system:

Try to use os.system:

导入操作系统os.system("MyProgram.py")

这篇关于如何在 Tkinter 中执行 Python 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆