From a601a6f73a1e0b0fc965089cd5e9b34054ea1821 Mon Sep 17 00:00:00 2001 From: Yannis300307 Date: Sun, 12 Nov 2023 22:36:51 +0100 Subject: [PATCH] Created settings window --- settings_manager.py | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 settings_manager.py diff --git a/settings_manager.py b/settings_manager.py new file mode 100644 index 0000000..6a8ebae --- /dev/null +++ b/settings_manager.py @@ -0,0 +1,87 @@ +from tkinter import ttk, Tk, Canvas, BOTH, Frame +import time + + +class SettingsWindow(Tk): + def __init__(self): + super().__init__() + self.width = 220 + self.height = 200 + + self.bg_color = "#2F2F3F" + self.text_color = "#B5B5B5" + self.field_bg_color = "#43435B" + self.active_field_bg_color = "#1C1C59" + self.outline_color = "#8B8B9E" + self.theme = ttk.Style() + self.theme.theme_use('clam') + self.theme.configure("TLabel", background=self.bg_color, foreground=self.text_color) + self.theme.configure("TEntry", background=self.bg_color, foreground=self.text_color, + fieldbackground=self.field_bg_color, bordercolor=self.outline_color, + lightcolor=self.outline_color, darkcolor=self.outline_color) + self.theme.configure("TButton", background=self.bg_color, foreground=self.text_color, + fieldbackground=self.field_bg_color, bordercolor=self.outline_color, + lightcolor=self.outline_color, darkcolor=self.outline_color) + + print() + self.theme.map("TButton", + background=[('!active', self.bg_color), ('active', self.active_field_bg_color)]) + + self.geometry(f"{self.width}x{self.height}+{self.winfo_screenwidth()-self.width-5}+{self.winfo_screenheight()-self.height-50}") + self.overrideredirect(True) + self.focus_force() + self.config(background='grey') + self.attributes("-transparentcolor", "grey") + + self.base_canvas = Canvas(self, bg="grey", highlightthickness=0) + self.round_rectangle(0, 0, self.width - 1, self.height - 1, radius=40, width=5, outline="#161616") + + self.title_label = ttk.Label(self.base_canvas, text="AlcasarAuto", font=("Arial", 20), style="TLabel") + + self.credential_frame = Frame(self.base_canvas, bg=self.bg_color) + self.username_label = ttk.Label(self.credential_frame, text="Username", style="TLabel") + self.password_label = ttk.Label(self.credential_frame, text="Password", style="TLabel") + self.username_entry = ttk.Entry(self.credential_frame, style="TEntry") + self.password_entry = ttk.Entry(self.credential_frame, show="●", style="TEntry") + + self.save_button = ttk.Button(self.base_canvas, text="Save", style="TButton") + + def round_rectangle(self, x1, y1, x2, y2, radius=25, **kwargs): # Creating a rounded rectangle + """Draw a rounded rectangle + By IJ_123 on StackOverflow""" + + points = [x1 + radius, y1, x1 + radius, y1, x2 - radius, y1, x2 - radius, y1, + x2, y1, x2, y1 + radius, x2, y1 + radius, x2, y2 - radius, + x2, y2 - radius, x2, y2, x2 - radius, y2, x2 - radius, y2, + x1 + radius, y2, x1 + radius, y2, x1, y2, x1, y2 - radius, x1, y2 - radius, + x1, y1 + radius, x1, y1 + radius, x1, y1] + + return self.base_canvas.create_polygon(points, **kwargs, smooth=True, fill=self.bg_color) + + def setup(self): + self.title_label.pack(expand=True) + + self.username_label.grid(row=0, column=0, pady=4) + self.password_label.grid(row=1, column=0, pady=4) + self.username_entry.grid(row=0, column=1, padx=8) + self.password_entry.grid(row=1, column=1, padx=8) + self.credential_frame.pack(expand=True) + + self.save_button.pack(expand=True, pady=5) + + self.base_canvas.pack(expand=True, fill=BOTH) + + def loop(self): + self.state = "normal" + while self.state == "normal": + self.update() + if self.focus_get() is None: + self.quit() + break + time.sleep(0.05) + + +settings = SettingsWindow() +settings.setup() + +settings.loop()