我想在单击“x”和“x1”按钮时向打开的窗口添加文本。但我无法理解。
import tkinter as tk
from tkinter import *
def create_window():
window = tk.Toplevel(root)
root = tk.Tk()
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
b = tk.Button(root, text="x", command=create_window)
b.pack(side=TOP, anchor=W, fill=BOTH, expand=YES)
b1 = tk.Button(root, text="x1", command=create_window)
b1.pack(side=TOP, anchor=W, fill=BOTH, expand=YES)
root.mainloop()
答案 0 :(得分:0)
布莱恩意味着这样的事情:
def create_window():
window = tk.Toplevel(root)
tk.Label(window, text='your text').pack(padx=30, pady=30)
正如他在发布之前所说的那样阅读了一些例子。看起来你不知道Toplevel是什么......