import tkinter as tki # Create a main window root = tki.Tk() # Creating widgets button = tki.Button(root, text = "hi") # Configuring widgets button.configure(fg="yellow") button["bg"] = "blue" # Packing button.pack(side=tki.TOP) # Event handlers def my_event_handler(event): print("entering " + event.widget["text"]) # Binding event handlers to widget button.bind("",my_event_handler) # Listen to events generated by the button button.configure(command=lambda: print("clicking hi")) # Run the event loop root.mainloop()