diff --git a/__pycache__/custom_file_dialog.cpython-312.pyc b/__pycache__/custom_file_dialog.cpython-312.pyc index 93f80c2..bac43a9 100644 Binary files a/__pycache__/custom_file_dialog.cpython-312.pyc and b/__pycache__/custom_file_dialog.cpython-312.pyc differ diff --git a/custom_file_dialog.py b/custom_file_dialog.py index d2ef961..f799b0f 100644 --- a/custom_file_dialog.py +++ b/custom_file_dialog.py @@ -245,7 +245,7 @@ class CustomFileDialog(tk.Toplevel): main_frame = ttk.Frame(self, style='Accent.TFrame') main_frame.pack(fill="both", expand=True) main_frame.grid_rowconfigure(2, weight=1) - main_frame.grid_columnconfigure(1, weight=1) + main_frame.grid_columnconfigure(0, weight=1) # Top bar for navigation and path top_bar = ttk.Frame( @@ -306,11 +306,18 @@ class CustomFileDialog(tk.Toplevel): tk.Frame(main_frame, height=1, bg=separator_color).grid( row=1, column=0, columnspan=2, sticky="ew") + # PanedWindow for resizable sidebar and content + paned_window = ttk.PanedWindow(main_frame, orient=tk.HORIZONTAL) + paned_window.grid(row=2, column=0, columnspan=2, sticky="nsew") + # Sidebar sidebar_frame = ttk.Frame( - main_frame, style="Sidebar.TFrame", padding=(0, 0, 0, 15)) - sidebar_frame.grid(row=2, column=0, sticky="nsw") - # Only the devices frame row expands + paned_window, style="Sidebar.TFrame", padding=(0, 0, 0, 15), width=200) + # Prevent content from resizing the frame + sidebar_frame.grid_propagate(False) + # Use weight=0 to give it a fixed size + paned_window.add(sidebar_frame, weight=0) + sidebar_frame.grid_rowconfigure(2, weight=1) sidebar_buttons_frame = ttk.Frame( @@ -342,70 +349,31 @@ class CustomFileDialog(tk.Toplevel): row=1, column=0, sticky="ew", padx=20, pady=15) # Mounted devices - devices_outer_frame = ttk.Frame(sidebar_frame, style="Sidebar.TFrame") - devices_outer_frame.grid(row=2, column=0, sticky="nsw", padx=10) - devices_outer_frame.grid_rowconfigure(0, weight=1) - devices_outer_frame.grid_columnconfigure(0, weight=1) - - devices_canvas = tk.Canvas(devices_outer_frame, highlightthickness=0, bg=self.sidebar_color) - devices_scrollbar = ttk.Scrollbar(devices_outer_frame, orient="vertical", command=devices_canvas.yview) - devices_canvas.configure(yscrollcommand=devices_scrollbar.set) - - mounted_devices_frame = ttk.Frame(devices_canvas, style="Sidebar.TFrame") - canvas_window = devices_canvas.create_window((0, 0), window=mounted_devices_frame, anchor="nw") - - def on_devices_configure(event): - devices_canvas.configure(scrollregion=devices_canvas.bbox("all")) - devices_canvas.itemconfig(canvas_window, width=event.width) - - mounted_devices_frame.bind("", on_devices_configure) - - def _on_devices_mouse_wheel(event): - if event.num == 4: delta = -1 - elif event.num == 5: delta = 1 - else: delta = -1 * int(event.delta / 120) - devices_canvas.yview_scroll(delta, "units") - - def show_scrollbar(event): - devices_scrollbar.place(relx=1.0, rely=0, relheight=1.0, anchor='ne') - - def hide_scrollbar(event): - devices_scrollbar.place_forget() - - devices_canvas.grid(row=0, column=0, sticky='nsew') - devices_outer_frame.bind("", show_scrollbar) - devices_outer_frame.bind("", hide_scrollbar) - + mounted_devices_frame = ttk.Frame( + sidebar_frame, style="Sidebar.TFrame") + mounted_devices_frame.grid(row=2, column=0, sticky="nsew", padx=10) ttk.Label(mounted_devices_frame, text="Geräte:", background=self.sidebar_color, foreground=self.color_foreground).pack(fill="x", padx=10, pady=(5, 0)) - device_widgets = [] for device_name, mount_point, removable in self._get_mounted_devices(): icon = self.icons['usb_small'] if removable else self.icons['device_small'] button_text = f" {device_name}" - if len(device_name) > 13: - button_text = f" {device_name[:13]}\n{device_name[13:]}" + if len(device_name) > 15: # Static wrapping for long names + button_text = f" {device_name[:15]}\n{device_name[15:]}" btn = ttk.Button(mounted_devices_frame, text=button_text, image=icon, compound="left", command=lambda p=mount_point: self.navigate_to(p), style="Dark.TButton.Borderless") btn.pack(fill="x", pady=1) - device_widgets.append(btn) try: total, used, _ = shutil.disk_usage(mount_point) progress_bar = ttk.Progressbar( mounted_devices_frame, orient="horizontal", length=100, mode="determinate", style='Small.Horizontal.TProgressbar') progress_bar.pack(fill="x", pady=(2, 8), padx=25) progress_bar['value'] = (used / total) * 100 - device_widgets.append(progress_bar) except (FileNotFoundError, PermissionError): + # In case of errors (e.g., unreadable drive), just skip the progress bar pass - all_widgets_to_bind = [devices_canvas, mounted_devices_frame] + device_widgets - for widget in all_widgets_to_bind: - widget.bind("", _on_devices_mouse_wheel) - widget.bind("", _on_devices_mouse_wheel) - widget.bind("", _on_devices_mouse_wheel) - tk.Frame(sidebar_frame, height=1, bg=separator_color).grid( row=3, column=0, sticky="ew", padx=20, pady=15) @@ -419,9 +387,10 @@ class CustomFileDialog(tk.Toplevel): self.storage_bar.pack(fill="x", pady=(2, 5), padx=15) # Content area - content_frame = ttk.Frame(main_frame, padding=( + content_frame = ttk.Frame(paned_window, padding=( 0, 0, 0, 0), style="AccentBottom.TFrame") - content_frame.grid(row=2, column=1, sticky="nsew") + paned_window.add(content_frame, weight=1) + content_frame.grid_rowconfigure(0, weight=1) content_frame.grid_columnconfigure(0, weight=1) diff --git a/mainwindow.py b/mainwindow.py index 1bd756d..0610908 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -58,7 +58,7 @@ if __name__ == "__main__": style = ttk.Style(root) root.tk.call('source', f"{theme_path}/water.tcl") try: - root.tk.call('set_theme', 'dark') + root.tk.call('set_theme', 'light') except tk.TclError: pass root.mainloop()