Untitled
unknown
plain_text
a year ago
4.6 kB
8
Indexable
# Create circles frame with transparent background
self.circles_frame = ctk.CTkFrame(self.content_frame, fg_color="transparent")
self.circles_frame.place(relx=0.5, rely=0.5, anchor='center')
self._stored_widgets.append(self.circles_frame)
# Add padding frame with transparent background
self.padding_frame = ctk.CTkFrame(self.circles_frame, fg_color="transparent")
self.padding_frame.pack(padx=50)
self._stored_widgets.append(self.padding_frame)
# Create list to track circle widgets
self.circle_widgets = []
# Create Grey Circles for each bin
for bin_config in self.bin_config.bins:
container = ctk.CTkFrame(self.padding_frame, fg_color="transparent")
container.pack(side='left', padx=15)
self._stored_widgets.append(container)
progress = RotationCircleButton(
container,
bin_id=bin_config['id'],
size=220,
language=language,
dark_mode=dark_mode,
command=lambda bid=bin_config['id']: self._rotate_to_position(bid)
)
progress.pack()
progress.set_dark_mode(dark_mode)
self.circle_widgets.append(progress)
self._stored_widgets.append(progress)
# Add close button
self.close_button = ctk.CTkLabel(
self.content_frame,
text="×",
width=40,
height=40,
text_color='white' if dark_mode else 'black',
font=("Arial", 32, "bold"),
cursor="hand2"
)
self.close_button.place(relx=0.995, rely=0.01, anchor="ne")
self.close_button.bind("<Button-1>", self.handle_close)
self.close_button.bind("<Enter>", lambda e: self.close_button.configure(text_color="#ff3b30"))
self.close_button.bind("<Leave>", lambda e: self.close_button.configure(
text_color='white' if dark_mode else 'black'
))
self._stored_widgets.append(self.close_button)
# Bind click events
self.bind('<Button-1>', self.check_click_location)
def check_click_location(self, event):
"""Check if click is outside the circles"""
if self._closing or self._destroyed:
return
# Get the clicked widget
clicked_widget = event.widget.winfo_containing(event.x_root, event.y_root)
# Check if click is on close button
if clicked_widget == self.close_button:
return
# Check if click is inside any circle or circle container
for circle in self.circle_widgets:
if clicked_widget == circle or clicked_widget in circle.winfo_children():
return
# Get circle's position and bounds
circle_x = circle.winfo_rootx()
circle_y = circle.winfo_rooty()
circle_width = circle.winfo_width()
circle_height = circle.winfo_height()
# Check if click is within circle bounds
if (circle_x <= event.x_root <= circle_x + circle_width and
circle_y <= event.y_root <= circle_y + circle_height):
return
# If we get here, click was outside circles
self.handle_close()
def handle_close(self, event=None):
"""Handle closing the screen safely"""
if self._closing or self._destroyed:
return
self._closing = True
try:
# Disable all circle widgets first
for circle in self.circle_widgets:
circle.configure(state="disabled")
# Close settings menu if open
if self.settings_menu and self.settings_menu.is_open:
self.settings_menu.close_menu()
# Apply temporary cooldown to all instances
for instance in CircularProgress._instances:
if not instance._destroyed:
instance.can_press = False
instance.is_pressed = False
instance.press_animation_active = False
# Schedule re-enabling after delay
self.after(1500, self._re_enable_instances)
# Schedule actual destruction
self.after(100, self.destroy)
except Exception as e:
print(f"Error during close: {e}")
self.destroy()Editor is loading...
Leave a Comment