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