Why doesn’t IPython recognize the event binding method and the bind event handler? How to replace it?

def output(event): y = eval(text1.get()) from sympy import * x = Symbol('x') y = Symbol('y') init_printing(use_unicode=False) tex2 = eval('y.diff(x)') from tkinter import* # родительский элемент root = Tk() # устанавливаем название окна root.title("Вычисление производных сложных функций") # устанавливаем минимальный размер окна root.minsize(width=80,height=60) # включаем возможность изменять окно root.resizable(width=True, height=True) # поле для ввода функции lab = Label(root, height=2, text="Введите функцию", font="Arial 18").grid(row=1,column=1) tex1 = Text(root,width=25, height=2, font="Arial 16", wrap=WORD) tex1.grid(row=1,column=2) # поле для вывода производной lab = Label(root, height=2, text="Производная", font="Arial 18").grid(row=2,column=1) tex2 = Text(root,width=25, height=2, font="Arial 16", wrap=WORD).grid(row=2,column=2) # поле для ввода значения производной lab = Label(root, height=2, text="Введите x", font="Arial 18").grid(row=3,column=1) tex3 = Text(root,width=10, height=1, font="Arial 16", wrap=WORD) tex3.grid(row=3,column=2) # поле для вывода значения производной lab = Label(root, height=2, text="Значение f'(x)", font="Arial 18").grid(row=4,column=1) tex4 = Text(root,width=10, height=1, font="Arial 16", wrap=WORD).grid(row=4,column=2) # кнопка вычислить but1 = Button(root, height=1, text="Вычислить", font="Verdana 16", bg="grey", fg="black", command=lambda:output).grid(row=5, column=1) # кнопка подставить but2 = Button(root, height=1, text="Подставить", font="Verdana 16", bg="grey", fg="black").grid(row=5, column=2) but1.bind('<Button-1>',output) # запускаем главное окно root.mainloop() 

AttributeError Traceback (most recent call last) in ()
---> 43 but1.bind ('Button-1', output) AttributeError: 'NoneType' object has no attribute 'bind'

  • Show the code, but1 does not have a bind() method - Igor Lavrynenko
  • At the beginning of the code I try to insert a formula into sympy from the text field tex1 to find the derivative and derive the resulting derivative to tex2. Surely there is a mistake. - user252640
  • Try adding print() to understand what is happening there - Igor Lavrynenko
  • in which part of the code? - user252640
  • Add wherever you are not sure what exactly is happening, look towards the debug tools - Igor Lavrynenko

0