instead of hiding main window, force settings on top
This commit is contained in:
@@ -20,7 +20,7 @@ def show_error(message_title: str, message: str, parent: tk.Tk | tk.Toplevel):
|
||||
|
||||
class SettingsWindow(tk.Toplevel):
|
||||
def __init__(self, root: tk.Tk):
|
||||
super().__init__()
|
||||
super().__init__(root)
|
||||
self.root = root
|
||||
self.protocol("WM_DELETE_WINDOW", self.close_window)
|
||||
self.geometry(f"500x330+{self.root.winfo_x() + 20}+{self.root.winfo_y() + 20}")
|
||||
@@ -84,8 +84,8 @@ class SettingsWindow(tk.Toplevel):
|
||||
def ok(self):
|
||||
if self.json_file.get() == "" or self.csv_file.get() == "":
|
||||
show_error(message_title="Fehlerhafte Konfiguration",
|
||||
message="Pfad für JSON oder CSV Datei fehlt",
|
||||
parent=self)
|
||||
message="Pfad für JSON oder CSV Datei fehlt",
|
||||
parent=self)
|
||||
return
|
||||
self.config.set("json", "path", self.json_file.get())
|
||||
self.config.set("csv", "path", self.csv_file.get())
|
||||
@@ -177,9 +177,9 @@ class Application:
|
||||
# leave application if settings are bad
|
||||
if not self.config_good:
|
||||
show_error(message_title="Fehler Konfiguration",
|
||||
message="Die Konfiguration ist fehlerhaft, bitte prüfe deine config.ini",
|
||||
parent=self.root
|
||||
)
|
||||
message="Die Konfiguration ist fehlerhaft, bitte prüfe deine config.ini",
|
||||
parent=self.root
|
||||
)
|
||||
sys.exit()
|
||||
|
||||
top_frame = tk.Frame(self.root)
|
||||
@@ -253,15 +253,16 @@ class Application:
|
||||
|
||||
def show_config_error(self):
|
||||
show_error(message_title="Fehlerhafte Konfiguration",
|
||||
message="Konnte benötigte Parameter in config.ini nicht finden",
|
||||
parent=self.root)
|
||||
message="Konnte benötigte Parameter in config.ini nicht finden",
|
||||
parent=self.root)
|
||||
|
||||
def on_close(self):
|
||||
self.root.destroy()
|
||||
|
||||
def show_settings(self):
|
||||
self.root.withdraw()
|
||||
settings = SettingsWindow(self.root)
|
||||
settings.wm_transient(self.root)
|
||||
settings.grab_set()
|
||||
settings.wait_window()
|
||||
|
||||
def insert_record(self):
|
||||
@@ -410,9 +411,9 @@ class Application:
|
||||
writer.writerow(address)
|
||||
except FileNotFoundError:
|
||||
show_error(message_title="Unexpected error",
|
||||
message=f"Could not write file {self.csv_file}",
|
||||
parent=self.root
|
||||
)
|
||||
message=f"Could not write file {self.csv_file}",
|
||||
parent=self.root
|
||||
)
|
||||
|
||||
def populate_table(self):
|
||||
self.delete_all_table_items()
|
||||
|
||||
Reference in New Issue
Block a user