I am making a custom button using the tk.Label and my own class so i can import use this in a separate module of a project i don't know how i can replicate the command= function of the button object, is this a implementation of the callback function or if not where should i look for information on how to acomplish this
import tkinter as tk
class Main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.geometry(self, "800x400")
tk.Tk.config(self, bg="black")
container = tk.Frame(self)
container.config(bg="black")
container.pack(side="top", fill="both", expand="true", pady=30)
this = Nav(container, text="Button 1")
this.bind("<Button>", lambda event: print("HELLO"))
this.pack()
Nav(container, text="Button 2")
class Nav(tk.Label):
def __init__(self, *args, **kwargs):
btn = tk.Label.__init__(self, *args, **kwargs, bg="green")
def on_enter(event, ref):
ref.config(text="enter", bg="#990000")
def on_leave(event, ref):
ref.config(text="leave", bg="black")
def left_click(event, ref):
ref.config(text="left click")
return True;
def release(event, ref):
ref.config(text="release")
app = Main()
app.mainloop()
commandto your custom button, which mimics the property that exists for standard buttons, or do you simply need a callback function activated when left clicking the button?