Python Don';我不理解为什么从函数插入结果会导致此tkinter.tcl错误
第一公里的出租车费用为8卢比,其余公里的出租车费用为5卢比。Python Don';我不理解为什么从函数插入结果会导致此tkinter.tcl错误,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,第一公里的出租车费用为8卢比,其余公里的出租车费用为5卢比。 从这些信息中得出一个等式: x=10(x是行驶的距离) y=(10*5)+3(y是旅行费用) 使用以下信息制作一个简单但功能强大的gui: 代码: 这是错误所在 Tkinter回调中出现异常 回溯(最近一次呼叫最后一次): 文件“C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\\uuuu init\uuuu.py”,第行 1705,在通话中__
从这些信息中得出一个等式:
x=10(x是行驶的距离)
y=(10*5)+3(y是旅行费用)
使用以下信息制作一个简单但功能强大的gui:
代码:
这是错误所在
Tkinter回调中出现异常
回溯(最近一次呼叫最后一次):
文件“C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\\uuuu init\uuuu.py”,第行
1705,在通话中__
返回self.func(*args)
文件“C:\Users\swadeshi\Desktop\math project 1.py”,第22行,在票价显示中
票价显示。插入(tk.NONE,showup)
文件“C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\\uuuu init\uuuu.py”,第行
3272,插入
self.tk.call((self._w,'insert',index,chars)+args)
_tkinter.TclError:错误#args:应为“!文本插入索引字符?标记列表字符标记列表…”
截图:
为什么对变量
fare\u display=tk.Text(…
和函数使用相同的名称:def fare\u display():
?您认为fare\u display.insert(tk.NONE,showup)怎么样
正在做什么?第一个参数是一个索引,你认为索引tk.NONE
代表什么?谢谢……我真的很感激,先生……我不得不把这个项目交给我的数学老师,让她证明她能给我评分,这是提交的最后一天
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)
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)
return fare
def fare_display():
showup = str(fare_calculater())
fare_display = tk.Text(master=window, height=10, width=30)
fare_display.grid(column=0, row=5)
fare_display.insert(tk.END, 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)
window.mainloop()