tkinter python entry not being displayed

Posted by user1050619 on Stack Overflow See other posts from Stack Overflow or by user1050619
Published on 2012-06-04T04:37:35Z Indexed on 2012/06/04 4:40 UTC
Read the original article Hit count: 220

Filed under:

I have created a Form with labels and entries..but for some reason the entries are not being created,

peoplegui.py

from tkinter import *
from tkinter.messagebox import showerror
import shelve
shelvename = 'class-shelve'
fieldnames = ('name','age','job','pay')

def makewidgets():
    global entries
    window = Tk()
    window.title('People Shelve')
    form = Frame(window)
    form.pack()
    entries = {}
    for (ix, label) in enumerate(('key',) + fieldnames):
        lab = Label(form, text=label)
        ent = Entry(form)
        lab.grid(row=ix, column=0)
        lab.grid(row=ix, column=1)
        entries[label] = ent
    Button(window, text="Fetch",  command=fetchRecord).pack(side=LEFT)
    Button(window, text="Update", command=updateRecord).pack(side=LEFT)
    Button(window, text="Quit",   command=window.quit).pack(side=RIGHT)    
    return window
def fetchRecord():
    print('In fetch')

def updateRecord():
    print('In update')


if __name__ == '__main__':
    window = makewidgets()
    window.mainloop()    

When I run it the labels are created but not the entries.

© Stack Overflow or respective owner

Related posts about python-3.x