Binding button to label widget

410 Views Asked by At

Trying to call hii function in python tkinter, but nothing happens.

My Code:-

def hii():
    print("hii")


m_root = Tk()
m_frame = Frame(m_root)
m_display = Label(m_frame)

label = Label(m_root,text="hii") #set your text
label.bind("<Enter>",hii)
label.pack()

m_display.pack()
m_frame.pack()
m_display.update()

m_root.mainloop()
1

There are 1 best solutions below

0
On BEST ANSWER

First line should be: def hii(event): and it works fine. The function should expect an event as an argument.