From 6410853d3c78cbf207e7602bf721ac3188e7fff7 Mon Sep 17 00:00:00 2001 From: sroth Date: Tue, 30 Sep 2025 00:23:10 +0200 Subject: [PATCH] added absender to config window --- src/windows.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/windows.py b/src/windows.py index 08821e5..d6b77af 100644 --- a/src/windows.py +++ b/src/windows.py @@ -93,18 +93,23 @@ class EditRecord(Window): class SettingsWindow(Window): def __init__(self, parent, root: tk.Tk, config: Config): super().__init__(parent, root) - self.geometry(f"500x330+{self.root.winfo_x() + 20}+{self.root.winfo_y() + 20}") + width = 500 + height = 630 + self.geometry(f"{width}x{height}+{self.root.winfo_x() + 20}+{self.root.winfo_y() + 20}") self.config = config self.json_file = tk.StringVar() self.csv_file = tk.StringVar() + self.absender_line = [tk.StringVar() for idx in range(4)] title = font.Font(family='Ubuntu Mono', size=20, weight=font.BOLD) tk.Label(self, text="Einstellungen", font=title).pack(pady=20) - path_frame = tk.Frame(self) - path_frame.pack(pady=(10, 40)) - tk.Label(path_frame, text="Datenpfad JSON Datei").grid(row=0, column=0) + tk.Label(self, text="Datenpfad JSON Datei").pack() + + path_frame = tk.Frame(self) + path_frame.pack(pady=(10, 10)) + tk.Entry(path_frame, textvariable=self.json_file, width=50).grid(row=1, column=0) tk.Button(path_frame, text="Pfad", command=lambda: self.set_json_path(self.json_file.get())).grid(row=1, column=1) @@ -113,6 +118,13 @@ class SettingsWindow(Window): tk.Entry(path_frame, textvariable=self.csv_file, width=50).grid(row=3, column=0) tk.Button(path_frame, text="Pfad", command=lambda: self.set_csv_path(self.csv_file.get())).grid(row=3, column=1) + absender_frame = tk.Frame(self) + absender_frame.pack(pady=(10, 40)) + + tk.Label(absender_frame, text="Absender").pack(side=tk.TOP) + for idx in range(4): + tk.Entry(absender_frame, textvariable=self.absender_line[idx], width=50).pack(side=tk.TOP) + bottom_frame = tk.Frame(self) bottom_frame.pack() tk.Button(bottom_frame, text="Ok", command=self.ok).pack(side=tk.LEFT) @@ -149,6 +161,15 @@ class SettingsWindow(Window): except NoOptionError: self.config.set("csv", "path", "") + for idx in range(4): + try: + self.absender_line[idx].set(self.config.get(f"absender", f"{idx}")) + except NoSectionError: + self.config.add_section(f"line") + self.config.set("line", f"{idx}", "") + except NoOptionError: + self.config.set("line", f"{idx}", "") + def ok(self): if self.json_file.get() == "" or self.csv_file.get() == "": show_error(message_title="Fehlerhafte Konfiguration", @@ -157,6 +178,8 @@ class SettingsWindow(Window): return self.config.set("json", "path", self.json_file.get()) self.config.set("csv", "path", self.csv_file.get()) + for i in range(4): + self.config.set("absender", f"{i}", f"{self.absender_line[i].get()}") self.close_window() def cancel(self):