从文本字段小部件中获取所有值并将其返回给按钮小部件

问题描述 投票:0回答:1

当我将值返回到一组文本字段并希望在相应的按钮中显示相同的条目集时,我只能使用Tkinter python 3将最后输入的文本值返回到所有按钮中。如何获取相应的文本相应按钮字段中的文本值?这是它的相应代码。

def inputt(self):
    x = int(self.number.get())
    entries_list=[]
    path_list=[]
    button_list=[]
    label_list=[]
    button_1_list=[]

    for i in range(0,x):
        l = Label(root,text="Device "+str(i+1)+":")
        l.grid(row=i+5,column=0)
        label_list.append(l)

        self.e = Entry(root)
        self.e.grid(row=i+5,column=1)
        entries_list.append(self.e)

        b1 = Button(root,text="Next",command=lambda:load(self,self.inputt))
        b1.grid(row=i+6,column=0)

def load(self, inputt):
    for i in range(0,x):
        b3=Button(root, text=self.e[i].get())
        b3.grid(row=i+100,column=0)
        button_list.append(b3)

对于给定的文本输入,我想将值返回到Def(load)功能的按钮。

python tkinter
1个回答
0
投票

声明小部件的变量需要单独声明,否则最后一个变量将覆盖当前小部件,并且在调用它时,它将仅显示最后一个小部件值。

© www.soinside.com 2019 - 2024. All rights reserved.