Mar-31-2023, 08:52 PM
(This post was last modified: Mar-31-2023, 09:04 PM by Gribouillis.)
Hello, I am an amateur programmer.
I wanted to know if my codes are correct?
And why is it not implemented?
Meanwhile, I wrote this program in the object-oriented method and in the tkinter framework.
thank you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
I wanted to know if my codes are correct?
And why is it not implemented?
Meanwhile, I wrote this program in the object-oriented method and in the tkinter framework.
thank you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
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", 10)) 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.calculate) self.calculate_button.grid(row=2, column=0) def rule(master): return 72/master def calculate(self): x = int(self.display.get()) result = "Result: " + self.rule() self.res_label.config(text=result) # create the main window and profit object root = tk.Tk() pro = Profit(root) root.mainloop()
Gribouillis write Mar-31-2023, 09:04 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.