python - 打开第二个 python 文件 (tkinter)

标签 python python-3.x user-interface tkinter

我有两个程序想要合并,但我似乎不知道如何合并。第一个程序是一个主页/菜单(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/

相关文章:

python - 使用包含新标签的数据附加带有 MultiIndex 的 pandas DataFrame,但保留旧 MultiIndex 的整数位置

Python Gmail API : Email is not sending as the specified from

python - 如何在 Airflow 中使用 PythonVirtualenvOperator?

java - 调用基本重绘方法?

c++ - QTableView 中的 QPushButton

python - 递归 - Python - 为什么 print(Foo) 显示的内容与 print(FunctionReturningFoo()) 不同

python - Django、Python 模块和 Git 子模块

python-3.x - 使用 panda 数据帧 groupby 中的百分位数删除异常值

python-3.x - 如何用唯一符号替换列表中的随机元素?

android - 如何在 Android 应用程序 UI 上获取带阴影的框?