Untitled
unknown
plain_text
a year ago
5.7 kB
5
Indexable
class WifiConfigurationScreen(ctk.CTkToplevel):
def __init__(self, parent, dark_mode: bool, language='EN'):
super().__init__(parent)
# Fullscreen and other properties
self.overrideredirect(True)
self.geometry(f"{self.winfo_screenwidth()}x{self.winfo_screenheight()}+0+0")
self.attributes('-topmost', True)
self.protocol("WM_DELETE_WINDOW", lambda: None)
# Colors
self.dark_mode = dark_mode
self.bg_color = '#1c1c1e' if dark_mode else '#f5f5f7'
self.text_color = 'white' if dark_mode else 'black'
self.configure(fg_color=self.bg_color)
# Initialize variables
self.networks = []
self.selected_network = StringVar()
self.password = StringVar()
self.show_password = ctk.BooleanVar(value=False)
self.keyboard_visible = False
# Main container
self.main_container = ctk.CTkFrame(self, fg_color=self.bg_color, corner_radius=0)
self.main_container.pack(fill="both", expand=True)
# Close button
self.close_button = ctk.CTkButton(
self,
text="×",
width=35,
height=20,
command=self.destroy,
fg_color='#ff3b30',
hover_color='#ff453a',
text_color='white',
font=("Dongle", 24, "bold"),
)
self.close_button.place(relx=0.995, rely=0.01, anchor="ne")
# Create UI elements
self.create_widgets()
self.scan_wifi_networks()
def create_widgets(self):
# Title and Status
title_label = ctk.CTkLabel(
self.main_container,
text="Wi-Fi Diagnostics",
font=("Dongle", 42, "bold"),
text_color=self.text_color
)
title_label.pack(pady=(20, 10))
self.status_label = ctk.CTkLabel(
self.main_container,
text="Status: Scanning...",
font=("Dongle", 24),
text_color=self.text_color
)
self.status_label.pack(pady=(0, 20))
# Main content container
content_container = ctk.CTkFrame(self.main_container, fg_color="transparent")
content_container.pack(fill="x", expand=False, pady=(0, 20), padx=40)
# Left Frame (Network Selection)
left_frame = ctk.CTkFrame(content_container, fg_color="transparent")
left_frame.grid(row=0, column=0, padx=(0, 20))
network_label = ctk.CTkLabel(
left_frame,
text="Available Networks",
font=("Dongle", 25),
text_color=self.text_color
)
network_label.pack(pady=(0, 10))
self.network_dropdown = ctk.CTkOptionMenu(
left_frame,
variable=self.selected_network,
values=self.networks,
width=300,
fg_color="#333",
text_color=self.text_color,
font=("Dongle", 20)
)
self.network_dropdown.pack()
password_label = ctk.CTkLabel(
left_frame,
text="Password",
font=("Dongle", 25),
text_color=self.text_color
)
password_label.pack(pady=(20, 10))
password_container = ctk.CTkFrame(left_frame, fg_color="transparent")
password_container.pack()
self.password_entry = ctk.CTkEntry(
password_container,
textvariable=self.password,
show="*",
width=300,
font=("Dongle", 20),
fg_color="#444"
)
self.password_entry.pack(side="left", padx=(0, 10))
self.toggle_password_btn = ctk.CTkButton(
password_container,
text="",
width=35,
command=self.toggle_password_visibility,
fg_color="#555",
)
self.toggle_password_btn.pack(side="left")
# Right Frame (Connection Info)
right_frame = ctk.CTkFrame(content_container, fg_color="transparent")
right_frame.grid(row=0, column=1)
self.connection_frame = ctk.CTkFrame(right_frame, fg_color="#333", corner_radius=10)
self.connection_frame.pack(fill="both", expand=True)
connection_title = ctk.CTkLabel(
self.connection_frame,
text="Connection Details",
font=("Dongle", 28, "bold"),
text_color=self.text_color
)
connection_title.pack(pady=(10, 5))
self.ssid_label = ctk.CTkLabel(
self.connection_frame,
text="SSID: Not connected",
font=("Dongle", 24),
text_color=self.text_color
)
self.ssid_label.pack(pady=5)
self.ip_label = ctk.CTkLabel(
self.connection_frame,
text="IP Address: N/A",
font=("Dongle", 24),
text_color=self.text_color
)
self.ip_label.pack(pady=(0, 10))
# Keyboard container
self.keyboard_frame = ctk.CTkFrame(self.main_container, fg_color="transparent")
self.keyboard_frame.pack(side="bottom", fill="x", pady=(10, 20), padx=40)
self.keyboard = TouchKeyboard(
self.keyboard_frame,
self.password_entry,
self.hide_keyboard,
dark_mode=self.dark_mode
)
self.keyboard.pack()
def toggle_password_visibility(self):
if self.password_entry.cget("show") == "*":
self.password_entry.configure(show="")
else:
self.password_entry.configure(show="*")
Editor is loading...
Leave a Comment