Untitled
unknown
plain_text
a year ago
3.9 kB
6
Indexable
def create_saying_label(parent, dark_mode):
# 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 - shorter lines
left_line = ctk.CTkFrame(
top_decorative,
width=40, # Shorter top line
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, # Shorter top line
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 with longer lines
left_line = ctk.CTkFrame(
bottom_decorative,
width=120, # Longer bottom line
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, # Longer bottom line
height=2,
fg_color=line_color
)
right_line.pack(side='left', padx=10)
sayings = load_sayings()
current_language = parent.winfo_toplevel().LANGUAGE
original_saying = random.choice(sayings[current_language])
saying_label.configure(text=original_saying)
def check_wifi_status():
try:
result = subprocess.run(
["nmcli", "-t", "-f", "ACTIVE,SSID", "dev", "wifi"],
capture_output=True, text=True
)
is_connected = any(line.startswith("yes:") for line in result.stdout.split("\n"))
if container.winfo_exists():
current_language = parent.winfo_toplevel().LANGUAGE
if not is_connected:
saying_label.configure(
text=TRANSLATIONS[current_language].get('wifi_disconnected', 'No WiFi Connection'),
text_color='#ff3b30'
)
else:
saying_label.configure(
text=original_saying,
text_color='white' if dark_mode else 'black'
)
container.after(5000, check_wifi_status)
except Exception:
if container.winfo_exists():
current_language = parent.winfo_toplevel().LANGUAGE
saying_label.configure(
text=TRANSLATIONS[current_language].get('wifi_disconnected', 'No WiFi Connection'),
text_color='#ff3b30'
)
container.after(5000, check_wifi_status)
# Start checking WiFi status
check_wifi_status()
return saying_labelEditor is loading...
Leave a Comment