commit 33

This commit is contained in:
2025-07-31 11:01:22 +02:00
parent 78b93f66be
commit 8536e2c463
3 changed files with 45 additions and 5 deletions

View File

@@ -238,6 +238,7 @@ class CustomFileDialog(tk.Toplevel):
('selected', "black" if not self.is_dark else "white")])
style.configure("TButton.Borderless.Round", anchor="w")
style.configure("Small.Horizontal.TProgressbar", thickness=8)
def create_widgets(self):
# Main container
@@ -341,12 +342,44 @@ class CustomFileDialog(tk.Toplevel):
row=1, column=0, sticky="ew", padx=20, pady=15)
# Mounted devices
mounted_devices_frame = ttk.Frame(
sidebar_frame, style="Sidebar.TFrame")
mounted_devices_frame.grid(row=2, column=0, sticky="nsew", padx=10)
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("<Configure>", 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("<Enter>", show_scrollbar)
devices_outer_frame.bind("<Leave>", hide_scrollbar)
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}"
@@ -356,16 +389,23 @@ class CustomFileDialog(tk.Toplevel):
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("<MouseWheel>", _on_devices_mouse_wheel)
widget.bind("<Button-4>", _on_devices_mouse_wheel)
widget.bind("<Button-5>", _on_devices_mouse_wheel)
tk.Frame(sidebar_frame, height=1, bg=separator_color).grid(
row=3, column=0, sticky="ew", padx=20, pady=15)

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', 'light')
root.tk.call('set_theme', 'dark')
except tk.TclError:
pass
root.mainloop()