(
self,
config: Config,
on_login_callback=None,
on_quit_callback=None,
)
| 58 | |
| 59 | class LoginForm(tk.Tk): |
| 60 | def __init__( |
| 61 | self, |
| 62 | config: Config, |
| 63 | on_login_callback=None, |
| 64 | on_quit_callback=None, |
| 65 | ): |
| 66 | super().__init__() |
| 67 | self.config = config |
| 68 | self.on_login_callback = on_login_callback |
| 69 | self.on_quit_callback = on_quit_callback |
| 70 | |
| 71 | if PLATFORM == MACOS or PLATFORM.startswith(LINUX): |
| 72 | # Set an initial size to avoid 0 size issue |
| 73 | # self.geometry("800x450") |
| 74 | self.update_idletasks() |
| 75 | |
| 76 | self.withdraw() # Hide the root window |
| 77 | self.title("ClipCascade") |
| 78 | self._tooltips = [] |
| 79 | |
| 80 | # Make the window appear on top and grab focus |
| 81 | self.attributes("-topmost", True) |
| 82 | self.focus_force() |
| 83 | |
| 84 | # Configure styles |
| 85 | style = ttk.Style(self) |
| 86 | # Use default theme (may vary by OS); consider 'clam', 'alt', or 'default' |
| 87 | style.configure("TLabel", font=("Helvetica", 13), padding=5) |
| 88 | style.configure("TEntry", font=("Helvetica", 13), padding=5) |
| 89 | style.configure("TButton", font=("Helvetica", 13), padding=5) |
| 90 | style.configure("TCheckbutton", font=("Helvetica", 13), padding=5) |
| 91 | |
| 92 | # Main frame with padding |
| 93 | main_frame = ttk.Frame(self, padding=20) |
| 94 | main_frame.pack(fill=tk.BOTH, expand=True) |
| 95 | |
| 96 | # Title Label |
| 97 | title_label = ttk.Label( |
| 98 | main_frame, |
| 99 | text="Please Log In", |
| 100 | font=("Helvetica", 16, "bold"), |
| 101 | takefocus=False, |
| 102 | ) |
| 103 | title_label.pack(pady=(0, 10)) |
| 104 | |
| 105 | # Create a frame for the fields |
| 106 | self.field_frame = ttk.Frame(main_frame) |
| 107 | self.field_frame.pack(padx=10, pady=10, fill=tk.X) |
| 108 | |
| 109 | # Username |
| 110 | user_label = ttk.Label(self.field_frame, text="Username:") |
| 111 | user_label.grid(row=0, column=0, padx=(0, 10), pady=5, sticky=tk.W) |
| 112 | self.username_entry = ttk.Entry(self.field_frame, width=50, font=("Helvetica", 13)) |
| 113 | self.username_entry.insert(0, self.config.data["username"]) |
| 114 | self.username_entry.grid(row=0, column=1, padx=10, pady=5, sticky=tk.W + tk.E) |
| 115 | self._add_tooltip( |
| 116 | [user_label, self.username_entry], |
| 117 | "Username used to log in to your ClipCascade account.\n\n" |
nothing calls this directly
no test coverage detected