self.buttonhid = False self.root.bind("<Enter>", self.togglelabelvisibility)…
- User
self.button_hid = False self.root.bind("", self.toggle_label_visibility) self.root.bind("", self.toggle_label_visibility)
codedef toggle_label_visibility(self, event): #global button_visible if self.button_hid: # Hide the label if it’s currently visible self.main_frame.pack_forget() else: # Show the label if it’s currently hidden self.main_frame.pack() # Flip the flag self.button_hid = not self.button_hidhow to add small delay so it doesn't flicker
- Assistant
- User
self.button_hid = False self.root.bind("", self.schedule_toggle) self.root.bind("", self.schedule_toggle) self.toggle_after_id = None # ID for the scheduled task
codedef schedule_toggle(self, event): # Cancel the scheduled toggle if it exists to avoid flicker if self.toggle_after_id is not None: self.root.after_cancel(self.toggle_after_id) # Schedule the toggle with a 300ms delay (you can adjust the delay time) self.toggle_after_id = self.root.after(300, self.toggle_label_visibility) def toggle_label_visibility(self): # global button_visible - not needed if button_hid is an instance variable if self.button_hid: # Hide the label if it's currently visible self.main_frame.pack_forget() else: # Show the label if it's currently hidden self.main_frame.pack() # Flip the flag self.button_hid = not self.button_hid # Clear the scheduled task ID as the task is now completed self.toggle_after_id = None - Assistant
- User
when cursor is on self.main_frame, the self.main_frame is gone and cursor hits self.root and that causes self.main_frame to flicker,
- Assistant