diff --git a/__pycache__/cfd_ui_setup.cpython-312.pyc b/__pycache__/cfd_ui_setup.cpython-312.pyc index 8824576..887b632 100644 Binary files a/__pycache__/cfd_ui_setup.cpython-312.pyc and b/__pycache__/cfd_ui_setup.cpython-312.pyc differ diff --git a/cfd_ui_setup.py b/cfd_ui_setup.py index 8aa7fa2..9b97002 100644 --- a/cfd_ui_setup.py +++ b/cfd_ui_setup.py @@ -383,10 +383,12 @@ class WidgetManager: action_buttons_sticky = "w" if button_box_pos == 'left' else "e" action_buttons_frame = ttk.Frame(bottom_controls_frame, style="AccentBottom.TFrame") - action_buttons_frame.grid(row=0, column=action_buttons_col, sticky=action_buttons_sticky, pady=(5, 10)) + action_buttons_frame.grid(row=0, column=action_buttons_col, rowspan=2, sticky="nsew", pady=(5, 10)) self.status_bar = ttk.Label(bottom_controls_frame, text="", anchor="w", style="AccentBottom.TLabel") - self.status_bar.grid(row=0, column=1, sticky="ew", padx=10) + status_bar_col = 1 if button_box_pos == 'left' else 1 + status_bar_sticky = "w" if button_box_pos == 'left' else "e" + self.status_bar.grid(row=0, column=status_bar_col, sticky=status_bar_sticky, padx=10) self.settings_button = ttk.Button(bottom_controls_frame, image=self.dialog.icon_manager.get_icon( 'settings-2_small'), command=self.dialog.open_settings_dialog, style="Bottom.TButton.Borderless.Round") @@ -394,47 +396,41 @@ class WidgetManager: Tooltip(self.settings_button, "Einstellungen") if self.dialog.dialog_mode == "save": - # Create a container for the top row (entry and save button) - top_row = ttk.Frame(action_buttons_frame, style="AccentBottom.TFrame") - top_row.pack(fill="x", expand=True) + self.filename_entry = ttk.Entry(action_buttons_frame) + save_button = ttk.Button(action_buttons_frame, text="Speichern", command=self.dialog.on_save) + cancel_button = ttk.Button(action_buttons_frame, text="Abbrechen", command=self.dialog.on_cancel) + self.filter_combobox = ttk.Combobox(action_buttons_frame, values=[ft[0] for ft in self.dialog.filetypes], state="readonly") - self.filename_entry = ttk.Entry(top_row) - self.filename_entry.pack(side="left", fill="x", expand=True, padx=(10, 5)) - # Limit max width of the entry field - self.filename_entry.bind("", lambda e: e.widget.config(width=min(80, int(e.width/8)))) + if button_box_pos == 'left': + action_buttons_frame.grid_columnconfigure(0, weight=1) + self.filename_entry.grid(row=0, column=0, sticky="ew", padx=(10,5)) + save_button.grid(row=0, column=1, sticky="e", padx=(0,10)) + cancel_button.grid(row=1, column=0, sticky="w", padx=(10,5), pady=(5,0)) + self.filter_combobox.grid(row=1, column=1, sticky="w", padx=(0,10), pady=(5,0)) + else: # right + action_buttons_frame.grid_columnconfigure(1, weight=1) + save_button.grid(row=0, column=0, sticky="w", padx=(10,5)) + self.filename_entry.grid(row=0, column=1, sticky="ew", padx=(0,10)) + self.filter_combobox.grid(row=1, column=0, sticky="e", padx=(10,5), pady=(5,0)) + cancel_button.grid(row=1, column=1, sticky="e", padx=(0,10), pady=(5,0)) - save_button = ttk.Button(top_row, text="Speichern", command=self.dialog.on_save) - save_button.pack(side="left", padx=(0, 10)) - - # Create a container for the bottom row (cancel button and combobox) - bottom_row = ttk.Frame(action_buttons_frame, style="AccentBottom.TFrame") - bottom_row.pack(fill="x", expand=True, pady=(5,0)) - - cancel_button = ttk.Button(bottom_row, text="Abbrechen", command=self.dialog.on_cancel) - cancel_button.pack(side="left", padx=(10, 5)) - - self.filter_combobox = ttk.Combobox(bottom_row, values=[ - ft[0] for ft in self.dialog.filetypes], state="readonly") - self.filter_combobox.pack(side="left", padx=(0, 10)) self.filter_combobox.bind("<>", self.dialog.on_filter_change) self.filter_combobox.set(self.dialog.filetypes[0][0]) - else: # Open mode - top_row = ttk.Frame(action_buttons_frame, style="AccentBottom.TFrame") - top_row.pack(fill="x", expand=True) - - open_button = ttk.Button(top_row, text="Öffnen", command=self.dialog.on_open) - open_button.pack(side="left", padx=(10, 5)) + else: # Open mode + open_button = ttk.Button(action_buttons_frame, text="Öffnen", command=self.dialog.on_open) + cancel_button = ttk.Button(action_buttons_frame, text="Abbrechen", command=self.dialog.on_cancel) + self.filter_combobox = ttk.Combobox(action_buttons_frame, values=[ft[0] for ft in self.dialog.filetypes], state="readonly") - bottom_row = ttk.Frame(action_buttons_frame, style="AccentBottom.TFrame") - bottom_row.pack(fill="x", expand=True, pady=(5,0)) + if button_box_pos == 'left': + open_button.grid(row=0, column=0, sticky="w", padx=(10,5)) + cancel_button.grid(row=1, column=0, sticky="w", padx=(10,5), pady=(5,0)) + self.filter_combobox.grid(row=1, column=1, sticky="w", padx=(0,10), pady=(5,0)) + else: # right + open_button.grid(row=0, column=1, sticky="e", padx=(10,5)) + cancel_button.grid(row=1, column=1, sticky="e", padx=(0,10), pady=(5,0)) + self.filter_combobox.grid(row=1, column=0, sticky="e", padx=(10,5), pady=(5,0)) - cancel_button = ttk.Button(bottom_row, text="Abbrechen", command=self.dialog.on_cancel) - cancel_button.pack(side="left", padx=(10, 5)) - - self.filter_combobox = ttk.Combobox(bottom_row, values=[ - ft[0] for ft in self.dialog.filetypes], state="readonly") - self.filter_combobox.pack(side="left", padx=(0, 10)) self.filter_combobox.bind("<>", self.dialog.on_filter_change) self.filter_combobox.set(self.dialog.filetypes[0][0]) diff --git a/mainwindow.py b/mainwindow.py index 65766ee..3368df5 100755 --- a/mainwindow.py +++ b/mainwindow.py @@ -33,7 +33,7 @@ class GlotzMol(tk.Tk): dialog = CustomFileDialog(self, initial_dir=os.path.expanduser("~"), filetypes=[("All Files", "*.*") - ], dialog_mode="save") + ]) # This is the crucial part: wait for the dialog to be closed self.wait_window(dialog)