I have a simple form that I copied/modified from a python web site. A lot of it makes sense but I do not see how the form in activated.
Is there some call in there that I am just not seeing? How do I use the information entered into the form. Everything works here except for line 30 where I get a "fetch not defined" error. I can send the entered information to the screen but I do not see how I can use the information outside the functions defined. Do I need a "return SR, TSR"? ================================ def Data_Entry(entries): SR = (entries['Sensor_Reading'].get()) print("SR: ", SR) #This line prints TSR = (entries['Test_Strip_Reading'].get()) print("TSR: ", TSR) #This line prints def SubmitForm(entries): print("Form Submitted") SR = entries['Sensor_Reading'].get() print("SR inside = " + SR) #This line prints def makeform(root, fields): entries = {} for field in fields: row = Frame(root) lab = Label(row, width=22, text=field+": ", anchor='w') ent = Entry(row) ent.insert(0,"0") row.pack(side = TOP, fill = X, padx = 5 , pady = 5) lab.pack(side = LEFT) ent.pack(side = RIGHT, expand = YES, fill = X) entries[field] = ent return entries if __name__ == '__main__': root = Tk() ents = makeform(root, fields) # root.bind('<Return>', (lambda event, e = ents: fetch(e))) #"fetch not defined" reported here b1 = Button(root, text = 'Submit', command=(lambda e = ents: SubmitForm(e))) b1.pack(side = LEFT, padx = 5, pady = 5) b2 = Button(root, text = 'Quit', command = root.quit) b2.pack(side = LEFT, padx = 5, pady = 5) root.mainloop() SR = (entries['Sensor_Reading'].get()) print ("SR Outside = " + SR) ================================== The last two lines were guesses but they still failed. Steve ====================================== Footnote: English speakers on a roller coaster: "Weeee" Spanish speakers on a rollercoaster: " Nosostros" -- https://mail.python.org/mailman/listinfo/python-list