I am trying to iteratively add fields to a Tkinter form by looping through a list. The form generates with no errors, but the labels are not present. What is going on here?
from Tkinter import *
class User_Input:
def __init__(self, parent):
fields = ['Text Box 1', 'Text Box 2']
GUIFrame =Frame(parent, width=300, height=200)
GUIFrame.pack(expand=False, anchor=CENTER)
field_index = 10
for field in fields:
self.field = Entry(text=field)
self.field.place(x=65, y = field_index)
field_index += 25
self.Button2 = Button(parent, text='exit', command= parent.quit)
self.Button2.place(x=160, y=60)
root = Tk()
MainFrame =User_Input(root)
root.mainloop()
Aucun commentaire:
Enregistrer un commentaire