Стоимость такси на 1 км составляет 8 рупий, а на оставшуюся часть километра - 5 рупий.
Составьте уравнение из этой информации:
x = 10 (x is the distance travelled)
y = (10*5)+3 (y is the cost of travel)
Сделайте простой, но функциональный интерфейсс этой информацией:
Код:
import tkinter as tk
window = tk.Tk()
window.title("my maths project")
window.geometry("500x500")
#FUNCTIONS
def fare_calculater():
distance = int(entry_km.get())
fare = 3+(distance*5)
print(fare)
def fare_display():
showup = fare_calculater()
fare_display = tk.Text(master=window, height=10 , width=30)
fare_display.grid(column=0, row=5)
fare_display.insert(tk.NONE ,showup)
#LABEL
label_head = tk.Label(text="Hello User!. welcome to the app", font=("The New Roman", 25))
label_head.grid()
label_enter = tk.Label(text="Enter the distence commuted by the passanger below")
label_enter.grid(column=0, row=1)
#ENTRY
entry_km = tk.Entry()
entry_km.grid(column=0, row=2)
#button
button_submit = tk.Button(text="submit", bg="green", command=fare_display)
button_submit.grid(column=0, row=3)
Вот ошибка
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line
1705, in __call__
return self.func(*args)
File "C:\Users\swadeshi\Desktop\math project 1.py", line 22, in fare_display
fare_display.insert(tk.NONE ,showup)
File "C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line
3272, in insert
self.tk.call((self._w, 'insert', index, chars) + args)
_tkinter.TclError: wrong # args: should be ".!text insert index chars ?tagList chars tagList ...?"
Снимок экрана:
