为什么我点击“←”按钮,却无法删除输入的数字??
# -----------------------------------------------------
def create_btn(text, col, row, cs, rs, px=(1, 1), py=(1, 1)): # 函数生成按钮
t = text
a = tkinter.Button(root2, text=text, width=4, command=lambda: (text_print(t)))
a.grid(column=col, row=row, columnspan=cs, rowspan=rs, padx=px, pady=py, sticky='nswe')
return a
# print(entry_usr_name.select_present())
def text_print(x): # 函数按钮输入算式
if str(x) == '←':
x = str(x)[0:-1]
# 返回有焦点的输入框对象
en = entry_usr_name.focus_get() or entry_usr_pwd.focus_get()
# 插入数字
en.insert("end",x)
btn = {} # 生成按钮
btn['1'] = create_btn('1', 0, 5, 1, 1)
btn['2'] = create_btn('2', 1, 5, 1, 1)
btn['3'] = create_btn('3', 2, 5, 1, 1)
btn['4'] = create_btn('4', 0, 4, 1, 1)
btn['5'] = create_btn('5', 1, 4, 1, 1)
btn['6'] = create_btn('6', 2, 4, 1, 1)
btn['7'] = create_btn('7', 0, 3, 1, 1)
btn['8'] = create_btn('8', 1, 3, 1, 1)
btn['9'] = create_btn('9', 2, 3, 1, 1)
btn['0'] = create_btn('0', 0, 6, 2, 1)
btn['←'] = create_btn('←', 2, 6, 1, 1)
# ----------------------------------------------------