Не выходит
from tkinter import *
def work(event, v1, v2):
text.insert("0.end", int(v1.get()) + int(v2.get()))
root = Tk()
root.title('Calculator')
root.minsize(width=270,height=320)
root.resizable(False,False)
v1 = Entry(root,width=20,bd=2)
v2 = Entry(root,width=20,bd=2)
l = Label(root,text ='Вводим две цифры:', font = 'Arial 10', fg='#CF0000')
c1 = Label(root, text = 'Цифра 1', font = 'Arial 10')
c2 = Label(root, text ='Цифра 2', font = 'Arial 10')
but=Button(root,text='Рассчитать', width=15)
but.bind("<Button-1>", lambda event: work(event, v1, v2, text))
text = Text(root,width=25,height=6,font='12',wrap=WORD)
l.grid(row=0,column=2) # это все можно заменить на _.place(x=_,y=_)
v1.grid(row=1,column=2,padx=20,pady=5)
v2.grid(row=2,column=2,padx=20,pady=5)
c1.grid(row=1,column=1,pady=5)
c2.grid(row=2,column=1,pady=5)
but.place(x=81,y=150)
text.place(x=22,y=190)
mainloop()
Выводит при нажатии на кнопку “Рассчитать”:
Exception in Tkinter callback
Traceback (most recent call last):
File “C:\ProgramData\Anaconda3\lib\tkinter\__init__.py”, line 1699, in __call__
return self.func(*args)
File “<ipython-input-10-e09b328c9e52>”, line 18, in <lambda>
but.bind(“<Button-1>”, lambda event: work(event, v1, v2, text))
TypeError: work() takes 3 positional arguments but 4 were given