Here is my code:
import tkinter as tk
frame = tk.Tk()
lbl = tk.Label(frame, text=line)
lbl.bind("<Button>", lambda x=lbl, y=frame: delete_and_create(x, y))
this is the function:
def delete_and_create(wid, frame):
wid.pack_forget()
lbl = tk.Text(frame)
lbl.pack()
When I try to do wid.pack_forget() I get an exception:
AttributeError: 'Event' object has no attribute 'pack_forget'
When I try to print wid this is what I get:
<ButtonPress event num=1 x=50 y=10>
Meaning, instead of transferring the Label widget (lbl) I'm transferring the event bind to the function delete_and_create
Is there a command for the Label widget in which I can get the widget?