I just started working on python and trying to build a small user interface. I am having multiple similar windows with a button on it and a callback function associated with the button. Is there a way to know from which window the button was pressed. I need to know from which window "Create message" was pressed.x argument would be the window number from the button is pressed
for x in range(num):
    Label(newWindow, text="Enter TTL").grid(row=1, column=0)
            TTL = Entry(newWindow, width=10, borderwidth=5)
            TTL.grid(row=1, column=1)
            #ttl = int(TTL.get())
            Label(newWindow, text="Enter Direction").grid(row=2, column=0)
            direction = Ent`enter code here`ry(newWindow, width=10, borderwidth=5)
            direction.grid(row=2, column=1)
            #dir = int(direction.get())
            Button(newWindow, text="Create Message",
            command=lambda: threading.Thread(target=create_message, args=(TTL, direction,x,)).start()).grid(row=4,
                                                                                                                column=0)

