I've recently decided that I wanted to have a play about with Tkinter, however I am trying to have an 'Enter' button to send me to the next window once a piece of data has been put into the entry but my button doesn't show up and the program tries running the command I have put into the button statement. Whenever I remove the command the button shows up but clearly does nothing.
Please note that I am fairly new to Tkinter so I may be doing some things inefficiently.
if os.path.isfile(NameDict):
Login()
else:
rootS = Tk()
rootS.title('Authentication')
rootS.geometry('400x300')
Name = Label(rootS, text = 'Please Enter Your Full Name\n')
Name.grid(row = 0, column = 0, sticky = N)
NameIn = Entry(rootS)
NameIn.grid(row = 0, column = 1, sticky = N)
#this is where i am having the issue
NameB = Button(rootS, text = 'Enter', command = CloseName(NameIn,rootS)
NameB.grid(columnspan = 2, sticky = W)
rootS.mainloop()
The CloseName
function.
def CloseName(NameIn,rootS):
name = NameIn.get()
if os.path.isfile('C:\\Users\\Bradley\\Desktop\\Log In system\\Members\\' + name + '.txt'):
login(name)
else:
with open('C:\\Users\\Bradley\\Desktop\\Log In system\\Members\\' + name + '.txt') as f:
data = f.readlines
Created = Label(rootS, text = 'User files has been created')
Created.grid(row = 1, column = 1, sticky = CENTER)
rootS.destroy()
signup()