-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
I have a scrollable frame that is populated with a list of frames. These frames include labels and such, imagine a mp3 playlist because that is what it is.
When a user clicks anywhere on the mp3 frame that file should be activated. If I bind an event to the frame (or the canvas) itself the click will only work if it happens on the background i.e. parts of the frame that is free from other objects.
If the click event happens on the title, artist or the timing labels, nothing happens.
Is there a way to make a frame or canvas overlaying the entire frame and catch the event?
Something like this pseudo code:
class Playable(CTkFrame):
def __init__(self, master:any, controller:UiController, pm:PlayableMeta):
super().__init__(master)
self.pm = pm
self.controller = controller
self.grid_rowconfigure((0, 1), weight=1)
self.columnconfigure(index=0, weight=1)
self.columnconfigure(index=1, weight=5)
self.columnconfigure(index=2, weight=1)
self.lbl_title = CTkLabel(self,
text=pm.title,
font=("Arial", 28), anchor="nw")
self.lbl_artist = CTkLabel(self,
text=pm.artist,
font=("Arial", 16), anchor="nw")
self.lbl_length = CTkLabel(self,
text="00:00.000",
font=("Arial", 16), bg_color="#228B22", anchor="e", padx=5, pady=5)
# ... and so on, until...
# Will not work on the labels above
self._canvas.bind("<Button-1>", lambda event: self.play())
# So I thought of something like
self.overlay = CTkFrame(self, bg_color="transparent", fg_color="transparent")
self.overlay.place(x=0, y=0, ...whatever needed to fill up everything)
self.overlay.bind("<Button-1>", lambda event: self.play())
Metadata
Metadata
Assignees
Labels
No labels