Question

The Gui has all the right buttons, but from there i get lost. I need to...

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

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
The Gui has all the right buttons, but from there i get lost. I need to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Help with Python code. Right now I'm creating a code in Python to create a GUI....

    Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk()    myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...

  • Python 3 I am trying to get my GUI Celsius to Fahrenheit calculator to work, why...

    Python 3 I am trying to get my GUI Celsius to Fahrenheit calculator to work, why won't this run? let me know what to change specifically import tkinter import tkinter.messagebox class GUI: def __int__(self): self.main_window=tkinter.Tk() self.frame1=tkinter.Frame(self.main_window) self.frame2=tkinter.Frame(self.main_window) self.frame3=tkinter.Frame(self.main_window) self.label1=tkinter.Label(self.frame1,text="Enter Celsius value: ") self.entry1=tkinter.Entry(self.frame1,width=10) self.label1.pack(side='left') self.entry1.pack(side='left') self.far=tkinter.StringVar() self.res=tkinter.Label(self.frame2,text='The Fahrenheit value is:') self.result=tkinter.Label(self.frame2,textvariable= self.far) self.res.pack(side='left') self.result.pack(side='left') self.calc=tkinter.Button(self.frame3,text='Calculate Fahrenheit',command=self.calfahr) self.quit_button=tkinter.Button(self.frame3,text='Quit',command=self.main_window.destroy) self.calc.pack(side='left') self.quit_button.pack(side='left') self.frame1.pack() self.frame2.pack() self.frame3.pack() tkinter.mainloop() def calfahr(self): self.test1=float(self.entry1.get()) self.thisanswer=float((1.8*(self.test1))+32) self.far.set(self.thisanswer) g=GUI()

  • Python 3 Code does not save the data into excel properly ​​​​​​​ # required library import...

    Python 3 Code does not save the data into excel properly ​​​​​​​ # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) # arraging barcode.grid(row=0, column=1) product.grid(row=1, column=1) money.grid(row=2, column=1) cal =...

  • Python 3 How to change the icon in the error message want to put a yellow...

    Python 3 How to change the icon in the error message want to put a yellow warning icon import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product =...

  • Python 3 Fix the code so if the user enter the same bar code more than...

    Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window,...

  • Demonstrate this result for the parallel calculation. CODE: from Tkinter import * # MODIFY THIS TO...

    Demonstrate this result for the parallel calculation. CODE: from Tkinter import * # MODIFY THIS TO HANDLE THREE RESISTORS __author__ = "robincarr" """ GUI version of Resistor Calculator finds the equivalent resistance for two resistors connected either in series or parallel. Features entry widgets and buttons.""" def series_calculation(): r1 = float(resistor1.get()) r2 = float(resistor2.get()) req = r1 + r2 equivalent_resistance.delete(0, END) # Clear the previous result. equivalent_resistance.insert(0, req) print("Resistor 1: %s\nResistor 2: %s" % (r1, r2)) print "The equivalent series...

  • Programming Exercise 8.3 | Instructions Write a GUI-based program that allows the user to convert temperature...

    Programming Exercise 8.3 | Instructions Write a GUI-based program that allows the user to convert temperature values between degrees Fahrenheit and degrees Celsius. The interface should have labeled entry fields for these two values. breezypythongui.py temperatureconvert... + 1 2 File: temperatureconverter.py 3 Project 8.3 4 Temperature conversion between Fahrenheit and Celsius. 5 Illustrates the use of numeric data fields. 6 • These components should be arranged in a grid where the labels occupy the first row and the corresponding fields...

  • Need help with Intro to Comp Sci 2 (Python) problem: This is what is provided: (Copy/Paste...

    Need help with Intro to Comp Sci 2 (Python) problem: This is what is provided: (Copy/Paste version): from tkinter import Tk, Label, Entry, Button from random import * class Craps(Tk): #set up the main window def __init__(self, parent=None): Tk.__init__(self, parent) self.title('Play Craps') self.new_game() self.make_widgets() #when a new game is started, the firstRoll will start at 0 def new_game(self): self.firstRoll = 0    #create and place the widgets in the window def make_widgets(self): Label(self, text="Die 1").grid(row=0, column=0, columnspan=1) Label(self, text="Die 2").grid(row=0,...

  • Using Python GUI from tkinter import * from tkinter.ttk import * def main(): window = Tk()    window.mainloop() main()...

    Using Python GUI from tkinter import * from tkinter.ttk import * def main(): window = Tk()    window.mainloop() main() Create a basic integer calculator program that uses two entries, a combo box, two labels, and a button to do basic calculations, as shown in the images below. The combo box should have the options for addition, subtraction, and multiplication, displayed as', andrespectively. Row 0 of the layout grid must contain an entry, the combo box and another entry in columns 0...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT