Data Entry error
<p>l would like to create  a control system for administrator on Tkinter and  some functions (add, delete, update and load) are main part of control system  but when l run the code , these functions do not work and there is no error message. But ,l could not figure out where the problem is. My code is still not completed yet. Ä°f l solve it, then l will move to another step.</p>

<pre><code>import tkinter
from tkinter import *


userlist = [
  ['Meyers',  '12356'],
  ['Smith','abcde'],
  ['Jones','123abc34'],
  ['Barnhart','12//348'],
  ['Nelson','1234'],
  ["Prefect",'1345'],
  ["Zigler",'8910'],
  ['Smith','1298']]


def domain():

    def whichSelected () :
        print ("At %s of %d" % (select.curselection(), len(userlist)))
        return int(select.curselection()[0])

    def addEntry():
        userlist.append ([nameVar.get(), passwordVar.get()])
        setSelect()

    def updateEntry():
        userlist[whichSelected()] = [nameVar.get(), passwordVar.get()]
        setSelect()

    def deleteEntry():
        del userlist[whichSelected()]
        setSelect()

    def loadEntry():
        name, password = userlist[whichSelected()]
        nameVar.set(name)
        passwordVar.set(password)

    def makeWindow():
        win=Tk()
        global nameVar, passwordVar, select

        frame1 = Frame(win)
        frame1.pack()

        Label(frame1, text="Name").grid(row=0, column=0, sticky=W)
        nameVar = StringVar()
        name = Entry(frame1, textvariable=nameVar)
        name.grid(row=0, column=1, sticky=W)

        Label(frame1, text="Password").grid(row=1, column=0, sticky=W)
        passwordVar= StringVar()
        password= Entry(frame1, textvariable=passwordVar)
        password.grid(row=1, column=1, sticky=W)

        frame2 = Frame(win)       # Row of buttons
        frame2.pack()
        b1 = Button(frame2,text=" Add  ",command=addEntry)
        b2 = Button(frame2,text="Update",command=updateEntry)
        b3 = Button(frame2,text="Delete",command=deleteEntry)
        b4 = Button(frame2,text=" Load ",command=loadEntry)
        b1.pack(side=LEFT); b2.pack(side=LEFT)
        b3.pack(side=LEFT); b4.pack(side=LEFT)

        frame3 = Frame(win)       # select of names

        frame3.pack()
        scroll = Scrollbar(frame3, orient=VERTICAL)
        select = Listbox(frame3, yscrollcommand=scroll.set, height=6)
        scroll.config (command=select.yview)
        scroll.pack(side=RIGHT, fill=Y)
        select.pack(side=LEFT,  fill=BOTH, expand=1)
        return win

    def setSelect():
        userlist.sort()
        select.delete(0,END)
        for name in userlist:
            select.insert(END,name)

    win=makeWindow()
    setSelect()
    win.mainloop()




page1=Tk()
but1=Button(page1,text="Domain",command=domain).pack()
</code></pre>

<p>It is bad practice to define your functions in a function and makes debugging pretty difficult. I would start by using an object to create this GUI. Object variables: </p>

<ul>
<li>passwordVar and nameVar, </li>
<li>select</li>
<li>userlist</li>
<li>win</li>
</ul>

python tkinter