Python Forum
Why is the program not running? Is there a logical or syntax problem?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is the program not running? Is there a logical or syntax problem?
#11
rule() returns a float. You output does not include formatting the float

import tkinter as tk

class Profit:
    def __init__(self, master):
        self.master = master
        master.title("Profit")
        # create the  pro field
        self.pro_label = tk.Label(master, text= "Interest rate:")
        self.pro_label.grid(row=0, column=0)
        # create the display
        self.display = tk.Entry(master, width=10, justify="center", font=("Arial
        self.display.grid(row=0, column=1)
        # create the  result field
        self.res_label = tk.Label(master, text="Result:")
        self.res_label.grid(row=1, column=0)
        # create and place the buttons on the grid
        self.calculate_button = tk.Button(master,text="Computing",command=self.c
        self.calculate_button.grid(row=2, column=0)
.
    def rule(self , value):
        return 72/value
.
    def calculate(self):
        x = int(self.display.get())
        result = "Result:  %f " % self.rule(x)
        self.res_label.config(text=result)

root = tk.Tk()
pro = Profit(root)
root.mainloop()
 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] logical error - saving file rwahdan 4 2,045 Jul-01-2021, 12:59 PM
Last Post: rwahdan
  Running cli program within a wx window? t4keheart 2 2,730 Jan-23-2020, 04:50 PM
Last Post: buran
  tkinter GUI, problem running seperate files fishglue 17 6,246 Oct-15-2019, 02:56 PM
Last Post: Denni
  Interacting with python console while program is running Murmele 2 3,287 Feb-10-2018, 05:43 PM
Last Post: kmcollins

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020