0

我想在单击“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()
4

1 回答 1

0

布莱恩的意思是这样的:

def create_window():
    window = tk.Toplevel(root)
    tk.Label(window, text='your text').pack(padx=30, pady=30)

正如他所说,在发布之前阅读一些示例。看来你不知道Toplevel是什么......

于 2017-02-13T19:43:19.193 回答