Untitled
unknown
plain_text
5 months ago
3.6 kB
4
Indexable
# Modify the create_saying_label function to handle WiFi status def create_saying_label(parent, dark_mode, check_wifi=True): # Create a main container with some extra vertical space container = ctk.CTkFrame( parent, fg_color='transparent', height=120 ) container.place(relx=0.5, rely=0.15, anchor='center') # Create decorative elements container for top elements top_decorative = ctk.CTkFrame( container, fg_color='transparent' ) top_decorative.pack(pady=(0, 10)) line_color = '#2c2c2e' if dark_mode else '#e5e5e7' # Top decorative elements left_line = ctk.CTkFrame( top_decorative, width=40, height=2, fg_color=line_color ) left_line.pack(side='left', padx=10) dot = ctk.CTkFrame( top_decorative, width=4, height=4, corner_radius=2, fg_color=line_color ) dot.pack(side='left') right_line = ctk.CTkFrame( top_decorative, width=40, height=2, fg_color=line_color ) right_line.pack(side='left', padx=10) # Create the main saying label saying_label = ctk.CTkLabel( container, text="", font=("Dongle", 42, "bold"), text_color='white' if dark_mode else 'black', pady=15 ) saying_label.pack(expand=True) # Bottom decorative elements bottom_decorative = ctk.CTkFrame( container, fg_color='transparent' ) bottom_decorative.pack(pady=(5, 0)) # Bottom elements left_line = ctk.CTkFrame( bottom_decorative, width=120, height=2, fg_color=line_color ) left_line.pack(side='left', padx=10) dot = ctk.CTkFrame( bottom_decorative, width=4, height=4, corner_radius=2, fg_color=line_color ) dot.pack(side='left') right_line = ctk.CTkFrame( bottom_decorative, width=120, height=2, fg_color=line_color ) right_line.pack(side='left', padx=10) def check_wifi_status(): if check_wifi: try: # Check WiFi connection using nmcli result = subprocess.run( ["nmcli", "-t", "-f", "STATE", "networking"], capture_output=True, text=True ) if "connected" not in result.stdout.lower(): return False # Also check if we have an active connection result = subprocess.run( ["nmcli", "-t", "-f", "ACTIVE", "connection"], capture_output=True, text=True ) return "yes" in result.stdout.lower() except Exception: return False return True def update_label(): if not check_wifi_status(): # Show disconnected warning in red saying_label.configure( text=TRANSLATIONS[container.winfo_toplevel().LANGUAGE]['wifi_disconnected_warning'], text_color='#ff3b30' # Red color that works in both light and dark mode ) container.after(5000, update_label) # Check every 5 seconds if check_wifi: container.after(0, update_label) return saying_label
Editor is loading...
Leave a Comment