如何在Tkinter上创建主页按钮

问题描述 投票:-3回答:1

我想创建一个可以在每个窗口上使用的主页按钮,并将我引导回家,使用Python而不使用OOP。

python tkinter
1个回答
-3
投票

这可能有效:

import Tkinter as tk
win1 = tk.Tk()
win2 = tk.Tk()
win3 = tk.Tk()
win4 = tk.Tk()
def home_button():
    print("Home Button Pressed.")
tk.Button(win1, text="home", command=home_button).pack()
tk.Button(win2, text="home", command=home_button).pack()
tk.Button(win3, text="home", command=home_button).pack()
tk.Button(win4, text="home", command=home_button).pack()
win1.mainloop()
win2.mainloop()
win3.mainloop()
win4.mainloop()
© www.soinside.com 2019 - 2024. All rights reserved.