I'm making a GUI with Tkinter, and I need to find a way to know if a widget (let's call it l = Label(root, text="test")) is packed or not. I know I can do if l in Tk.pack_slaves(root):..., but this seems inefficient.
Is there any way of adding a "line" to the widget.pack() method, such as telling it to set an attribute to widget.is_packed = True? Or is there a way of telling a class, On_method_call(pack()) do this?
Cheers.
No, there is no built-in way to do it. It's your code doing the packing, so you can store a flag in a dictionary, or create your own pack function to do that automatically.
Tkinter "on-pack" method or "is-packed" attribute