To get the input from shelve into the GUI when it is created you could change
Then the StringVar is set to the value from student_name
The following close is not needed as it automatically closed above
Also, the entry needs to be told to use the stringvar
Change
#open text file student_scores = shelve.open('student_name', 'c') #Display menue here here self.student_name = StringVar()to
#open text file with shelve.open('student_name', 'c') as db: student_name = db["Student Name"] #Display menue here here self.student_name = StringVar() self.student_name.set(student_name)This will open the file and automatically close it after the value has been read into student_name
Then the StringVar is set to the value from student_name
The following close is not needed as it automatically closed above
#close test file student_scores.close()In the button handler event you didn't do anything with shelve, that is why nothing happened
#function to set student names def set_names(self): student_name = [self.student_name.get()] print("submitt function pressed")You can change it to
#function to set student names def set_names(self): student_name = self.student_name.get() print("submitt function pressed") with shelve.open('student_name', 'c') as db: db["Student Name"] = student_name
Also, the entry needs to be told to use the stringvar
Change
#text box self.input = Entry(self) self.input.grid(row = 7, column = 1)to
#text box self.input = Entry(self,textvariable=self.student_name) self.input.grid(row = 7, column = 1)