0

Everytime i run it, it works, but when I hover over the button, it gives me the error (TypeError: donehovering() takes 0 positional arguments but 1 was given)

Am I missing something completely obvious?

 from tkinter import *

root = Tk()

root["bg"] = "black"

def colorchangeondemand():
    if button.cget('bg') == "black":
        button.config(bg="red", text="Started the program, please exit this window")
        Toplevel(root)

def hoverover():
    statusbar.config(text="Click to start the program already")

def donehovering():
    statusbar.config(text="")

frame = Frame(root, width=1000, height=1000)
frame.grid(row=100, column=25)

statusbar = Label(frame, text="", bd=1, relief=SUNKEN, anchor=W)
statusbar.pack(side=BOTTOM, fill=X)

photo = PhotoImage(file="smaller.png")
put_the_photo_in = Label(frame, image=photo, bg="black")

label1 = Label(root, image=photo, fg="green", bg="black")
label1.grid(row=50,column=25)

label2 = Label(root, text="MadLibs in a GUI", fg="green", bg="black", font=159)
label2.grid(row=1,column=25)

button = Button(frame, text="Start", bg="black", fg="green", command=colorchangeondemand, pady=20, padx=75)
button.pack()

button.bind("<Enter>", hoverover)
button.bind("<Leave>", donehovering)


root.mainloop()
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
  • 4
    Any function you specify via `.bind()` will be called with one parameter - the event object. You have to define the function to accept this parameter, whether or not the function has any actual use for it. – jasonharper Aug 31 '21 at 18:58
  • Welcome to Stack Overflow. Questions like this are best answered by reading the [documentation](https://docs.python.org/3/library/tkinter.html#bindings-and-events), or by [doing an internet search](https://duckduckgo.com/?q=tkinter+button+bind) (I tried `tkinter button bind`, and found the linked duplicate that way), or by following a [tutorial](https://tk-tutorial.readthedocs.io/en/latest/button/button.html). – Karl Knechtel Aug 31 '21 at 20:30

0 Answers0