Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In PYTHON Create the GUI-Graphical User Interface. Use tkinter to produce a form

ID: 3679787 • Letter: I

Question

In PYTHON Create the GUI-Graphical User Interface. Use tkinter to produce a form that looks much like the following. It should have these widgets.

The user will enter a temperature in the first entry box. They will then click either the Convert to Fahrenheit or the Convert to Celsius radio button (but not both). And when they click the Convert button the value entered in the first entry box will be converted to the proper temperature and put into the second entry box.

EXAMPLE:

Temperature Converter GUI

Enter a temperature (entry box)

Convert to Fahrenheit (radio button)

Convert to Celsius (radio button)

CONVERT VALUE             CLEAR (clears both entry boxes)

Result (entrybox)

use a class that inherits Frame to implement your program.

Your 2 entry boxes need to have labels explaining the purpose of the entry boxes.

Round the result to 1 decimal place.

In addition to the Convert Value button, you need to have a Clear button that clears both entry boxes.

Explanation / Answer

Run this program in ubuntu

Install the python Tkinter package using the following command

sudo apt-get install python-tk

import the package tkinter

save the file using filename.py

run it using python filename.py on terminal

-----------------------------------------------------------------------------------

from Tkinter import*


def convert():
    celTemp = celTempVar.get()
    fahTemp = fahTempVar.get()



    if celTempVar.get() != 0.0:
        celToFah = (celTemp * 9/5 + 32)
        print celToFah
        fahTempVar.set(celToFah)

    elif fahTempVar.get() != 0.0:
        fahToCel = ((fahTemp - 32) * (5/9))
        print fahToCel
        celTempVar.set(fahToCel)



def reset():
    top = Toplevel(padx=50, pady=50)
    top.grid()
    message = Label(top, text = "Reset Complete")
    button = Button(top, text="OK", command=top.destroy)

    message.grid(row = 0, padx = 5, pady = 5)
    button.grid(row = 1, ipadx = 10, ipady = 10, padx = 5, pady = 5)

    fahTempVar.set(int(0))
    celTempVar.set(int(0))





###MAIN###
root = Tk()
root.title("Temperature Converter")
mainframe = Frame(root)
mainframe.grid()

celTempVar = IntVar()
celTempVar.set(int(0))
fahTempVar = IntVar()
fahTempVar.set(int(0))


titleLabel = Label (mainframe, text = "Celcius/Fahrenheit Temperature", font = ("Arial", 20, "bold"), justify = CENTER)
titleLabel.grid(row = 1, column = 1, columnspan = 3, pady = 10, padx = 20)

celLabel = Label (mainframe, text = "Celcius: ", font = ("Arial", 16), fg = "red")
celLabel.grid(row = 2, column = 1, pady = 10, sticky = NW)

fahLabel = Label (mainframe, text = "Fahrenheit: ", font = ("Arial", 16), fg = "blue")
fahLabel.grid(row = 3, column = 1, pady = 10, sticky = NW)

celEntry = Entry (mainframe, width = 10, bd = 5, textvariable = celTempVar)
celEntry.grid(row = 2, column = 1, pady = 10, sticky = NW, padx = 125 )


fahEntry = Entry (mainframe, width = 10, bd = 5, textvariable = fahTempVar)
fahEntry.grid(row = 3, column = 1, pady = 10, sticky = NW, padx = 125 )

convertButton =Button (mainframe, text = "Convert", font = ("Arial", 8, "bold"), relief = RAISED, bd=5, justify = CENTER, highlightbackground = "red", overrelief = GROOVE, activebackground = "green", activeforeground="blue", command = convert)
convertButton.grid(row = 4, column = 1, ipady = 8, ipadx = 12, pady = 5, sticky = NW, padx = 55)

resetButton = Button (mainframe, text = "Reset", font = ("Arial", 8, "bold"), relief = RAISED, bd=5, justify = CENTER, highlightbackground = "red", overrelief = GROOVE, activebackground = "green", activeforeground="blue", command = reset)
resetButton.grid(row = 5, column = 1,ipady = 8, ipadx = 12, pady = 5, sticky = NW)

root.mainloop()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote