import tkinter as tk\nfrom tkinter import *\nfrom Top1_CustomFileDialogFrame import Top1_CustomFileDialogFrame\nfrom Top2_ContextFrame import Top2_ContextFrame\nfrom Top3_OperateFrame import Top3_OperateFrame\nfrom CustomMenuFrame import CustomMenuFrame\nfrom GlobalFrame import GlobalFrameClass\n \n# 定义全局变量\n# rightframe = None\n#\n# def loadCustomFrame3():\n# # 修改全局变量,只有这样才能修改全局变量\n# global rightframe\n# # 不能使用 rightframe.frame.destroy方法,请自己验证一下\n# rightframe.frame.destroy()\n# rightframe = Top2_ContextFrame(master)\n# master.update()\n#注册一个全局类:无参数传入\nglobalFrame = GlobalFrameClass()\nmaster = tk.Tk()\nmaster.geometry(\"1200x900\")\nmaster.title(\"Tkinter\")\n# 定义菜单\nCustomMenuFrame(master, globalFrame) # 实例化一个类\nTop1_CustomFileDialogFrame(master, globalFrame)\nTop2_ContextFrame(master, globalFrame)\nTop3_OperateFrame(master, globalFrame)\n \n# globalFrame.registerFrame(\"customMenuFrame\", customMenuFrame)\n# globalFrame.registerFrame(\"top1_CustomFileDialogFrame\", top1_CustomFileDialogFrame)\nprint(\"启动完成\")\nmaster.mainloop()
【无标题】tk全局变量
![](https://img-home.csdnimg.cn/images/20240711042549.png)