I know i could call function.__name__ for this, but im trying specificly to get the name of a function a button has if i dont always know before hand what that function is. my current code (which im building as a template for future use, hence the redundant class) is this:
class main:
def __init__(self):
class MainWindow(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
Window = ttk.Frame(self, padding=10)
Window.grid(sticky="news")
def TestFunc1():
x = TestButton.cget('text')
y = TestButton.cget('command')
print(f'This is the "{x}" button which runs the "{y}" function!')
TestLabel = ttk.Label(Window, text="Test Label")
TestLabel.grid(column=1, row=1)
TestButton = ttk.Button(Window, text="Test Button", command=TestFunc1)
TestButton.grid(column=1, row=2)
app = MainWindow()
app.mainloop()
if __name__ == "__main__":
main()
which prints: This is the "Test Button" button, which runs the "1649907075392TestFunc1" function.