Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 插入“;条目“;基于TKinter中用户输入的框_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 插入“;条目“;基于TKinter中用户输入的框

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

这里的新手,我正在从事一个小型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 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]
,这是否回答了你的问题?