我正在制作一个锦标赛软件,我想这样做,当我按下回车键时,会出现另一个条目小部件,这是我的代码
from tkinter import*
import time
import sys
master = Tk()
master.title('Tournament Software')
master.geometry("800x800")
master.configure(background="black")
def end():
master.destroy()
def click1():
master.destroy()
master1 = Tk()
master1.title("Tournament Software")
master1.geometry("800x800")
master1.configure(background="black")
la=Label(master1, text="Enter Contestant Names:",font="none 50 bold", fg="white", bg="black").pack()
#I don't know what to put here
e=Entry(master1, bd=10,width=50).pack()
l=Label(master, text="Tournament Software", font="none 50 bold", bg="black", fg="white").pack()
b=Button(master, text="Start",font="none 50 bold",command = click1).pack(side=LEFT)
b1=Button(master, text="Quit",font="none 55 bold",command = end).pack(side=RIGHT)
mainloop()
答案 0 :(得分:1)
每次按Enter键时,下面的代码会生成一个新的条目小部件:
import tkinter as tk
root = tk.Tk()
entryList = list()
def enter_event(event):
entryList.append(tk.Entry(root))
entryList[-1].pack()
root.bind("<Return>", enter_event)
root.mainloop()