【发布时间】:2018-10-31 08:24:19
【问题描述】:
大家好,我是初学者,正在使用 Tkinter 开发 Project Linear 和 Binary search GUI 应用程序,我想在此处添加多个条目框值到标签和数组中,我尝试过,但它不能正常工作:
import tkinter as tk
root=tk.Tk()
root.title("Looping of entry box")
root.geometry("1200x600")
def ApplytoLabel():
xx=size.get()
for i in range(xx):
ArrayLabel=tk.Label(root,text="Array Element")
ArrayLabel.pack()
def Boxes():
xx=size.get()
for i in range(xx):
box=tk.Entry(root)
box.pack()
ApplytoLabel1=tk.Button(root,text="Submit To Array",command=ApplytoLabel)
ApplytoLabel1.pack()
Array = tk.Frame(root)
Array.pack()
text1=tk.Label(Array,text="Enter the Size of Array:",
font="Arial 10 bold",fg="blue")
text1.grid(row=0,column=0,sticky="w")
size=tk.IntVar()
ArraySize=tk.Entry(Array,textvariable=size)
ArraySize.grid(row=0,column=1,sticky="w")
SizeofArray=tk.Button(Array,text="Submit",command=Boxes)
SizeofArray.grid(row=0,column=2,sticky="w")
root.mainloop()
【问题讨论】:
标签: python python-3.x tkinter