Sumator - Python
Здравейте,
Опитвам се да създам Sumator от глава пътва на Programming basics - Python Но ми дава грешка. Някой би ли ми погледнал кода и би ли ми показал къде ми е грешката?
import tkinter as tk class Application(tk.Frame): def _init_(self, master=None): super()._init_(master) self.pack() app = Application() app.master.title("Sumator") app.master.minsize(width=100, height=50) app.mainloop() def _init_(self, master=None): super()._init_(master) self.pack() self.create_widgets() def create_widgets(self): # create widgets self.firstNumberEntry = tk.Entry() self.plusSign = tk.Label(text="+") self.secondNumberEntry = tk.Entry() self.equalSign = tk.Label(text="=") self.resultLabel = tk.Label(text="Result...", bg="green", fg="white") self.calculateButton = tk.Button(text="Calculate") self.firstNumberEntry.pack(side="left") self.plusSign.pack(side="left") self.seconNumberEntry.pack(side="left") self.equalSign.pack(side="left") self.resultLabel.pack(side="left") self.calculateButton.pack(side="left") tk.Button(text="Calculate", command=self.calculate) def calculate(self): first_value = float(self.firstNumberentry.get()) second_value = float(self.secondNumberentry.get()) result = first_value + second_value elf.resultLabel.gonfig(text=str(result), bg="green", fg="white") def calculate(self): try: first_value = float(self.firstNumberentry.get()) secon_value = floqt(self.secondNumberentry.get()) result = first_value + secon_value self.resutLabel.config(text=str(result), bg="green", fg="white") except valueError: self.resultLablel.config(text=str(result), bg="red", fg="black")
Поздрави,
Йордан
Много благодаря, за помощта!