It occurred to me to make use of event.widget.winfo_parent(), but it returns a str with the full path of the widget and I can't grab wrapper to put it inside an if to prevent the statement block from executing. Hence my question if there is a more correct method to do this or some way to grab the container, in this case from of self.btn and use it in a statement. Thanks
The challenge is making exceptions between buttons, in the example I only put two, but what do I do if I want the exception to be for a few buttons and not all?
from tkinter import *
class Example(Frame)
def __init__(self, master, *args, **kwargs):
super().__init__(master, *args, **kwargs)
self.frame = Frame(self, bg='yellow')
self.frame .pack(side=TOP, fill=BOTH)
self.cnt = Frame(self.frame, bg='green2')
self.cnt .pack(side=TOP, fill=BOTH)
self.btn = Button(self.cnt, text='Button 1 ')
self.btn.pack()
self.btn2 = Button(self.cnt, text='Button 2')
self.btn2.pack()
self.bind_all('<Motion-1>', self.hellow)
def hellow(self, event):
print('I always run how I want')
root = Tk()
app = Example(root)
app .pack(side=TOP, fill=BOTH)
root.mainloop()