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

SHOW ME THE ERRORS IN MY CODE!!!! .The Gui has all the right buttons, but from t

ID: 3681205 • Letter: S

Question

SHOW ME THE ERRORS IN MY CODE!!!!.The Gui has all the right buttons, but from there i get lost.

I need to know whats wrong with my assignment can someone please help. The code I have so far is listed below, could you please show me the errors in my code.

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

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 (Entry box)

1. 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.

2. use a class that inherits Frame to implement your program.

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

4. Round the result to 1 decimal place.

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

Code:

from tkinter import *

class Application(Frame):                    # inherit from Frame.

    def __init__(self):
        Frame.__init__(self)                 #call superclass constructor
        self.master.title("Temperature Converter")      #give frame a title
        self.master.geometry("330x230")
        self.grid()
       
        self._temperature = StringVar()
        self._tcEntry = Entry(self, width=15, textvariable = self._temperature)
        self._tcEntry.grid(row=0, column=2, pady=10)

        Label(self, text="Enter a temperature").grid(row=0, column=1, padx=3, pady=10)
       
        self._button = Button(self, text = "Convert Value", command = self._convert)
        self._button.grid(row=3, column=1, padx=5, pady=5)
       
        self._result = StringVar()
        self._resultEntry = Entry(self, width=15, textvariable = self._result)
        self._resultEntry.grid(row=7, column=2, pady=10)
       
        Label(self, text="Result").grid(row=7, column=1, padx=5, pady=5)

        self._radioButton = Radiobutton(self, text = "Convert to Fahrenheit", variable = self.convertofahr, value = 1, command = self.convertofahr)
        self._radioButton.grid(row=1, column=2, sticky=W, padx=10, pady=10)

        self._radioButton2 = Radiobutton(self, text = "Convert to Celsius", variable = self.convertocelsius, value = 2, command = self.convertocelsius)
        self._radioButton2.grid(row=2, column=2, sticky=W, padx=10, pady=10)

        self._button = Button(self, text = "Clear", command=self.destroy)
        self._button.grid(row=3, column=2, pady=10)
       
    def convertofahr(self):
        self._tcEntry = float(self.tcEntry.get())
        self.convertofahr.set()
              
    def convertocelsius(self):
        self._tcEntry = float(self.tcEntry.get())
        self.convertocelsius.set()
        self._resultEntry(text = "Celsius = ", round(tc - 32) / 1.8,1
         
    def _convert(self):
        tc = float(self._temperature.get())
        self._resultEntry(text = "Fahrenheit = ", round(tc * 1.8 + 32),1
        self._resultEntry(text = "Celsius = ", round(tc - 32) / 1.8,1                
        f = self.convertofahr.get()
        c = self.convertocelsius.get()
       
def main():
    Application().mainloop()
main()

Explanation / Answer

temperatureConversion.py

def fahrenheitToCelsius(fahrenheit):
    """Receives Fahrenheit, computes and returns Celsius"""

    return (round(((fahrenheit - 32) * (5/9)), 2))

def celsiusToFahrenheit(celsius):
    """Receives Celsius, computes and returns Celsius"""

    return (round(((celsius * (9/5)) + 32), 2))