获取Python Tkinter多个条目

时间:2017-02-14 18:29:34

标签: python-3.x tkinter

我想用GUI(Tkinter)创建数独(6x6),我用for循环创建了36个条目。我怎样才能从所有条目中检索数字? 使用我的代码我只能从最后一个条目中获得数字

python 3

class Window(Frame):
def __init__(self, master=None):
    Frame.__init__(self, master)
    self.master = master      


    self.Bstart = Button(top, text="CHECK", command=self.check)
    self.Bstart.pack()
    self.Bstart.place(x=500, y=200)

    for g in [0, 30, 60, 90, 120, 150]:
        for i in [0, 40, 80, 120, 160, 200]:

         self.E = Entry(top, width=3)
         self.E.place(x=100+i, y=300+g)

    def check(self):

        av = self.E.get()
        self.enjoy.configure(text=av)


top = Tk()
top.geometry('800x800')
app = Window(top)

top.mainloop()

I am thinking about giving different name for self.E 
every time when looping: 

self.E{0} = Entry(top, width=3).format(g+i)
self.E.place(x=100+i, y=300+g)

But of course it does not work.

0 个答案:

没有答案