Dec-18-2022, 07:02 PM
(This post was last modified: Dec-18-2022, 08:08 PM by Yoriz.
Edit Reason: Added code tags, Added prefix
)
I am new to Python and trying to run a small program that takes a input from a text field and submit it into a shelf.
The code runs with no errors but does not input any data
Thanks for any direction you may give
The code runs with no errors but does not input any data
Thanks for any direction you may give
# Sample Solution
from tkinter import *
import shelve
class MyFrame (Frame):
def __init__(self):
Frame.__init__(self)
self.master.geometry("600x600")
self.master.title("Student Scores")
self.grid()
#open text file
student_scores = shelve.open('student_name', 'c')
#Display menue here here
self.student_name = StringVar()
# Prompt, Entry and Button... will be more buttons added eventually
self.prompt = Label(self, text = "Select one of the 3 menu options")
self.prompt.grid(row = 0, column = 0)
#Radio Button Menu options
#Button to enter students name
self.button_selected = IntVar()
self.button_selected.set(1)
#self.button_selected.get() == 1
self.menu_button = Radiobutton(self, text = "Add student name",
variable = self.button_selected, value = 1)
self.menu_button.grid(row = 3, column = 0)
self.prompt = Label(self, text = "Enter students name: ")
self.prompt.grid(row = 7, column = 0)
#text box
self.input = Entry(self)
self.input.grid(row = 7, column = 1)
# submit button
self.button_submit = Button(self, text = "Submit",
command = self.set_names)
self.button_submit.grid(row = 7, column = 2)
#print(list(student_scores.values()))
#close test file
student_scores.close()
#function to set student names
def set_names(self):
student_name = [self.student_name.get()]
print("submitt function pressed")
asn_frame = MyFrame()
asn_frame.mainloop()
