Tkinter beginner here, and general python noob.
I have a program that appends items to a list and displays that list in a listbox. It'll display all items properly upon reload, but I want the new values to be visible in the listbox without having to reload. Here's my attempt. It doesn't return any error, but it doesn't work either.
I'm running 2.7 on Mac OSX. Remember, I'm fairly new at this stuff.
def OnPressEnter(self,event):
hold = self.entryVariable.get()
hold = str(hold)
with open('GoalTrak/StudentList.txt', 'a') as textfile: #This appends students to the already existing document of students
if (hold) not in student_list_temp:
student_list_temp.append(hold[:-1])
textfile.write(hold + '\n')
self.labelVariable.set( self.entryVariable.get() + " added" )
self.StudentListDisplay.insert(Tkinter.END,hold[:-1])
else:
self.labelVariable.set( self.entryVariable.get() + " is already in list" )
textfile.close()
self.entry.focus_set()
self.entry.selection_range(0, Tkinter.END)
Thanks in advance!
EDIT: Here is the code in which I define my listbox:
self.StudentListDisplay = Tkinter.Listbox(self)
self.StudentListDisplay.grid(row=2,column=0,columnspan=2,sticky='W')
for student in student_list_temp:
self.StudentListDisplay.insert(Tkinter.END, student)