I'm writing an app with many windows and buttons, a calculator is a built into the app and it's keyboard when clicking on the inclusion button of the calculator is on the menu window. I don't know what the problem is, there are many apps in the main menu and only such a problem. This is calculator function: import tkinter as tk from tkinter import messagebox def add_digit(digit): value = calc.get() + str(digit) calc['state']=tk.NORMAL calc.delete(0, tk.END) calc.insert(0, value) calc['state'] = tk.DISABLED def add_operation(operation): value = calc.get() if value[-1] in '**-+/*!': value = value[:-1] elif '+' in value or '-' in value or '*' in value or '/' in value or '!' in value or '**' in value: calculate() value = calc.get() calc['state'] = tk.NORMAL calc.delete(0, tk.END) calc.insert(0, value+operation) calc['state'] = tk.DISABLED member=[] def calculate(): value = calc.get() if value[-1] in '+-/*': value = value+value[:-1] calc['state'] = tk.NORMAL calc.delete(0, tk.END) member.append(value) calc['state'] = tk.DISABLED try: calc['state'] = tk.NORMAL calc.insert(0, eval(value)) calc['state'] = tk.DISABLED except (NameError, SyntaxError): messagebox.showinfo('Ошибка ввода!', 'Можно писать только числовые выражения!') except ZeroDivisionError: messagebox.showinfo('Внимание!', 'На ноль делить нельзя!') def clear(): calc['state'] = tk.NORMAL calc.delete(0, tk.END) calc['state'] = tk.DISABLED def button(digit): return tk.Button(text=digit, bd=5, font=('Arial Black', 12),fg ='#458B00', command=lambda : add_digit(digit)) def oper_button(operation): return tk.Button(text=operation, bd=5, font=('Arial Black', 12), fg ='#3D59AB',command=lambda: add_operation(operation)) def answer_button(operation): return tk.Button(text=operation, bd=5, font=('Arial Black', 12), fg ='#FF1493',command=calculate) def clear_button(operation): return tk.Button(text=operation, bd=5, font=('Arial Black', 12), fg ='#FF1493',command=clear) def press_key(event): print(event.char) if event.char.isdigit(): add_digit(event.char) elif event.char in '**+-/*abs()': add_operation(event.char) elif event.char == '\r': calculate() win = tk.Tk() win.geometry(f"310x400+100+200") win['bg']='#C1CDCD' win.title('Qcalc') win.bind('<Key>', press_key) calc = tk.Entry(win, justify=tk.RIGHT, font=('Arial Black', 14), width=15) calc['state'] = tk.DISABLED calc.grid(row=0, column=0, columnspan=3, stick = 'we') button('1').grid(row=1, column=0, stick='wens', padx=5, pady=5) button('2').grid(row=1, column=1, stick='wens', padx=5, pady=5) button('3').grid(row=1, column=2, stick='wens', padx=5, pady=5) button('4').grid(row=2, column=0, stick='wens', padx=5, pady=5) button('5').grid(row=2, column=1, stick='wens', padx=5, pady=5) button('6').grid(row=2, column=2, stick='wens', padx=5, pady=5) button('7').grid(row=3, column=0, stick='wens', padx=5, pady=5) button('8').grid(row=3, column=1, stick='wens', padx=5, pady=5) button('9').grid(row=3, column=2, stick='wens', padx=5, pady=5) button('0').grid(row=4, column=0, stick='wens', padx=5, pady=5) button('.').grid(row=3, column=4, stick='wens', padx=5, pady=5) button('-1').grid(row=4, column=1, stick='wens', padx=5, pady=5) button('-2').grid(row=4, column=2, stick='wens', padx=5, pady=5) button('-3').grid(row=4, column=3, stick='wens', padx=5, pady=5) button('-4').grid(row=5, column=0, stick='wens', padx=5, pady=5) button('-5').grid(row=5, column=1, stick='wens', padx=5, pady=5) button('-6').grid(row=5, column=2, stick='wens', padx=5, pady=5) button('-7').grid(row=5, column=3, stick='wens', padx=5, pady=5) button('-8').grid(row=6, column=0, stick='wens', padx=5, pady=5) button('-9').grid(row=6, column=1, stick='wens', padx=5, pady=5) oper_button('+').grid(row=1, column=3, stick='wens', padx=5, pady=5) oper_button('-').grid(row=1, column=4, stick='wens', padx=5, pady=5) oper_button('/').grid(row=2, column=3, stick='wens', padx=5, pady=5) oper_button('*').grid(row=2, column=4, stick='wens', padx=5, pady=5) oper_button('**').grid(row=3, column=3, stick='wens', padx=5, pady=5) answer_button('=').grid(row=6, column=3, stick='wens', padx=5, pady=5) clear_button('C').grid(row=6, column=2, stick='wens', padx=5, pady=5) win.grid_columnconfigure(0, minsize=50) win.grid_columnconfigure(1, minsize=50) win.grid_columnconfigure(2, minsize=50) win.grid_columnconfigure(3, minsize=50) win.grid_columnconfigure(4, minsize=50) win.grid_columnconfigure(5, minsize=50) win.grid_columnconfigure(6, minsize=50) win.grid_columnconfigure(7, minsize=50) win.grid_columnconfigure(8, minsize=50) win.grid_columnconfigure(9, minsize=50) win.grid_rowconfigure(0, minsize=50) win.grid_rowconfigure(1, minsize=50) win.grid_rowconfigure(2, minsize=50) win.grid_rowconfigure(3, minsize=50) win.grid_rowconfigure(4, minsize=50) win.grid_rowconfigure(5, minsize=50) win.grid_rowconfigure(6, minsize=50) win.grid_rowconfigure(7, minsize=50) win.grid_rowconfigure(8, minsize=50) win.grid_rowconfigure(9, minsize=50) win.mainloop() I surf for such a problem on the Internet, l seem to be the only one. Please, sched the code line to solve the prolem! Continue reading...