我有两个程序想要合并,但我似乎不知道如何合并。第一个程序是一个主页/菜单(studious_main.py),上面有一个按钮(btnLearn),单击该按钮时,应该(希望)关闭窗口并打开第二个程序studious_create.py。
btnLearn = Button(container2, image = imgLearnBtn,command=destroy).pack(side = BOTTOM, padx = 100)
(目前它只是关闭窗口。)
您建议我如何让程序执行此操作?我仍然是一个新手,我似乎无法解决这个问题,抱歉
最佳答案
一种方法是创建一个函数来处理您需要完成的操作,然后将按钮的命令
绑定(bind)到它。
def close_current_and_open_other():
# code to close the current: destroy(), etc...
# code to open the second program
btnLearn = Button(container2, image=imgLearnBtn, command=close_current_and_open_other).pack(side=BOTTOM, padx=100)
关于python - 打开第二个 python 文件 (tkinter),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45951863/