Python 插入“;条目“;基于TKinter中用户输入的框
这里的新手,我正在从事一个小型Python项目,它需要接受用户的数字输入,点击按钮后,它应该插入相应数量的行(输入框),以便进一步收集输入。有可能在一个循环中完成吗?如何完成?我在循环中尝试了它,但只插入了第一行Python 插入“;条目“;基于TKinter中用户输入的框,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,这里的新手,我正在从事一个小型Python项目,它需要接受用户的数字输入,点击按钮后,它应该插入相应数量的行(输入框),以便进一步收集输入。有可能在一个循环中完成吗?如何完成?我在循环中尝试了它,但只插入了第一行 label_6.place(x=0,y=320) total_participants = tk.Entry(root, width="5", textvariable=StringVar()) total_participants.place(x=150,y=320) def a
label_6.place(x=0,y=320)
total_participants = tk.Entry(root, width="5", textvariable=StringVar())
total_participants.place(x=150,y=320)
def action():
num_participants = int(total_participants.get())
coordinate = 400
first_name_label = Label(root, text="First Name",width=20,font=("bold", 11))
first_name_label.place(x=0,y=coordinate)
second_name_label = Label(root, text="Second Name",width=20,font=("bold", 11))
second_name_label.place(x=150,y=coordinate)
email_label = Label(root, text="Email ID",width=20,font=("bold", 11))
email_label.place(x=300, y =coordinate )
first_name = []
second_name = []
email_id = []
for i in range(1, num_participants + 1):
fn[i] = Entry(root, width="15").place(x=40,y=coordinate + 40)
sn[i] = Entry(root, width="15").place(x=190,y=coordinate + 40)
em[i] = Entry(root, width="40").place(x=340,y=coordinate + 40)
label_8 = Button(root, text="Participants Details",font=("bold", 13), command = participant_details)
label_8.place(x=30,y=360)
您需要在每次迭代中更新
坐标。添加类似于coordinate+=30的内容作为action()
中for循环的最后一行(实际上应该是participant\u details()
)。此外,不应将.place()
函数与条目()链接起来。将这两个函数分成两个语句。而fn[i]
应该是名字。附加(…)
,所以对于sn[i]
和em[i]
,这是否回答了你的问题?