Question: Modify the temperature conversion program so that it responds to the users press of the return or enter key. If the user presses this key

Modify the temperature conversion program so that it responds to the users press of the return or enter key. If the user presses this key when the insertion point is in a given field, the action which uses that field for input is triggered. import Tkinter def CelsiusToFahenheit(Celsius, entry): #function for CelsiusToFahenheit #Celsius = int(input("Enter a temperature in Celsius: ")) Fahrenheit = 9.0/5.0 * float(Celsius) + 32 entry.delete(0, 'end') entry.insert(0, str(Fahrenheit)) def FahenheitToCelsius(Fahrenheit, entry): #function for FahenheitToCelsius #!Fahrenheit = int(input("Enter a temperature in Fahrenheit: ")) Celsius = (float(Fahrenheit) - 32) * 5.0/9.0 entry.delete(0, 'end') entry.insert(0, str(Celsius)) def main(): window = Tkinter.Tk() # Creating main window window.title("Grid") lb = Tkinter.Label(window, text='Fahrenheit')# Creating label lb.grid (row=0,column=0) lb1=Tkinter.Label(window,text='Celsius:')# Creating label lb1.grid (row=0,column=1) en =Tkinter. Entry(window, justify='right') # Creating text field en.grid(row=1,column=0) en.insert(0, "32.0") #set default value en1=Tkinter.Entry(window, justify='right') # Creating text field en1.grid(row=1,column=1) en1.insert(0, "0.0") #set default value # Creating buttons btnFtoc =Tkinter.Button(window, text='>>>>', command=lambda: FahenheitToCelsius(en.get(), en1)) btnFtoc.grid(row=2,column=0) btnCtoF =Tkinter.Button(window, text='<<<<', command=lambda: CelsiusToFahenheit(en1.get(), en)) btnCtoF.grid(row=2,column=1) window.mainloop() # Running the application if __name__ == '__main__': main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!