commit 26

This commit is contained in:
2025-07-30 01:55:45 +02:00
parent 98b16e664b
commit 0b7a85424a
3 changed files with 27 additions and 48 deletions

View File

@@ -238,15 +238,13 @@ class CustomFileDialog(tk.Toplevel):
('selected', "black" if not self.is_dark else "white")])
style.configure("TButton.Borderless.Round", anchor="w")
style.configure("Vertical.TScrollbar", width=10) # Make scrollbar narrower
def create_widgets(self):
# Main container
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(0, weight=0) # Sidebar column
main_frame.grid_columnconfigure(1, weight=1) # Content column
main_frame.grid_columnconfigure(1, weight=1)
# Top bar for navigation and path
top_bar = ttk.Frame(
@@ -311,38 +309,12 @@ class CustomFileDialog(tk.Toplevel):
sidebar_frame = ttk.Frame(
main_frame, style="Sidebar.TFrame", padding=(0, 0, 0, 15))
sidebar_frame.grid(row=2, column=0, sticky="nsw")
sidebar_frame.grid_rowconfigure(0, weight=1) # Allow canvas to expand
sidebar_frame.grid_columnconfigure(0, weight=1)
# Create a canvas for the scrollable sidebar content
sidebar_canvas = tk.Canvas(sidebar_frame, highlightthickness=0, bg=self.sidebar_color)
sidebar_canvas.grid(row=0, column=0, sticky="nsew")
sidebar_scrollbar = ttk.Scrollbar(sidebar_frame, orient="vertical", command=sidebar_canvas.yview, style="Vertical.TScrollbar")
sidebar_scrollbar.grid(row=0, column=1, sticky="ns")
sidebar_canvas.configure(yscrollcommand=sidebar_scrollbar.set)
sidebar_canvas.bind('<Configure>', lambda e: sidebar_canvas.configure(scrollregion = sidebar_canvas.bbox("all")))
# Create a frame inside the canvas to hold all sidebar content
self.sidebar_inner_frame = ttk.Frame(sidebar_canvas, style="Sidebar.TFrame")
sidebar_canvas.create_window((0, 0), window=self.sidebar_inner_frame, anchor="nw")
# Bind mouse wheel to the inner frame
def _on_sidebar_mouse_wheel(event):
sidebar_canvas.yview_scroll(-1*(event.delta//120), "units")
self.sidebar_inner_frame.bind("<MouseWheel>", _on_sidebar_mouse_wheel)
self.sidebar_inner_frame.bind("<Button-4>", lambda e: _on_sidebar_mouse_wheel(e)) # For Linux
self.sidebar_inner_frame.bind("<Button-5>", lambda e: _on_sidebar_mouse_wheel(e)) # For Linux
# Propagate mouse wheel events from children to the inner frame
for child in self.sidebar_inner_frame.winfo_children():
child.bind("<MouseWheel>", _on_sidebar_mouse_wheel)
child.bind("<Button-4>", lambda e: _on_sidebar_mouse_wheel(e))
child.bind("<Button-5>", lambda e: _on_sidebar_mouse_wheel(e))
sidebar_frame.grid_rowconfigure(2, weight=1) # Only the devices frame row expands
sidebar_buttons_frame = ttk.Frame(
self.sidebar_inner_frame, style="Sidebar.TFrame", padding=(0, 15, 0, 0))
sidebar_buttons_frame.pack(fill="x", expand=False)
sidebar_frame, style="Sidebar.TFrame", padding=(0, 15, 0, 0))
sidebar_buttons_frame.grid(
row=0, column=0, sticky="nsew")
sidebar_buttons_config = [
{'name': 'Computer',
'icon': self.icons['computer_small'], 'path': '/'},
@@ -362,14 +334,13 @@ class CustomFileDialog(tk.Toplevel):
compound="left", command=lambda p=config['path']: self.navigate_to(p), style="Dark.TButton.Borderless")
btn.pack(fill="x", pady=1)
ttk.Separator(self.sidebar_inner_frame, orient='horizontal').pack(
fill='x', pady=10, padx=20)
ttk.Separator(sidebar_frame, orient='horizontal').grid(
row=1, column=0, sticky='ew', pady=10, padx=20)
# Mounted devices
mounted_devices_frame = ttk.Frame(
self.sidebar_inner_frame, style="Sidebar.TFrame")
mounted_devices_frame.pack(fill="x", expand=False, padx=10)
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))
@@ -379,12 +350,11 @@ class CustomFileDialog(tk.Toplevel):
compound="left", command=lambda p=mount_point: self.navigate_to(p), style="Dark.TButton.Borderless")
btn.pack(fill="x", pady=1)
# New separator before storage_frame
ttk.Separator(self.sidebar_inner_frame, orient='horizontal').pack(
fill='x', pady=10, padx=20)
ttk.Separator(sidebar_frame, orient='horizontal').grid(
row=3, column=0, sticky='ew', pady=10, padx=20)
storage_frame = ttk.Frame(self.sidebar_inner_frame, style="Sidebar.TFrame")
storage_frame.pack(fill="x", expand=False, padx=10)
storage_frame = ttk.Frame(sidebar_frame, style="Sidebar.TFrame")
storage_frame.grid(row=4, column=0, sticky="ew", padx=10)
self.storage_label = ttk.Label(
storage_frame, text="Freier Speicher:", background=self.freespace_background)
self.storage_label.pack(fill="x", padx=10)
@@ -446,7 +416,16 @@ class CustomFileDialog(tk.Toplevel):
self.resize_job = self.after(200, self.populate_files)
self.last_width = new_width
def _unbind_mouse_wheel_events(self):
# Unbind all mouse wheel events from the root window
self.unbind_all("<MouseWheel>")
self.unbind_all("<Button-4>")
self.unbind_all("<Button-5>")
def populate_files(self):
# Unbind previous global mouse wheel events
self._unbind_mouse_wheel_events()
for widget in self.file_list_frame.winfo_children():
widget.destroy()
self.path_entry.delete(0, tk.END)
@@ -489,12 +468,12 @@ class CustomFileDialog(tk.Toplevel):
scrollregion=canvas.bbox("all")))
def _on_mouse_wheel(event):
delta = -1*(event.delta//120) # Normalize delta for cross-platform consistency
delta = -1 if event.num == 4 else 1
canvas.yview_scroll(delta, "units")
container_frame.bind("<MouseWheel>", _on_mouse_wheel)
container_frame.bind("<Button-4>", lambda e: _on_mouse_wheel(e)) # For Linux
container_frame.bind("<Button-5>", lambda e: _on_mouse_wheel(e)) # For Linux
canvas.bind_all("<MouseWheel>", _on_mouse_wheel)
canvas.bind_all("<Button-4>", _on_mouse_wheel)
canvas.bind_all("<Button-5>", _on_mouse_wheel)
items, error, warning = self._get_sorted_items()
if warning:

View File

@@ -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()