abb button to canvas tkinter code example
Example 1: Function to a button in tkinter
from tkinter import *
win = Tk()
def btn1():
print("I Don't Know Your Name")
button1 = Button(win, text="Click Me To Print SomeThing", command=btn1)
button1.pack()
win.mainloop()
Example 2: buttons on canvas tkinter
button1 = Button(self, text = "Quit", command = self.quit, anchor = W)
button1.configure(width = 10, activebackground = "#33B5E5", relief = FLAT)
button1_window = canvas1.create_window(10, 10, anchor=NW, window=button1)