commit 34
This commit is contained in:
Binary file not shown.
@@ -245,7 +245,7 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
main_frame = ttk.Frame(self, style='Accent.TFrame')
|
main_frame = ttk.Frame(self, style='Accent.TFrame')
|
||||||
main_frame.pack(fill="both", expand=True)
|
main_frame.pack(fill="both", expand=True)
|
||||||
main_frame.grid_rowconfigure(2, weight=1)
|
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 for navigation and path
|
||||||
top_bar = ttk.Frame(
|
top_bar = ttk.Frame(
|
||||||
@@ -306,11 +306,18 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
tk.Frame(main_frame, height=1, bg=separator_color).grid(
|
tk.Frame(main_frame, height=1, bg=separator_color).grid(
|
||||||
row=1, column=0, columnspan=2, sticky="ew")
|
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
|
||||||
sidebar_frame = ttk.Frame(
|
sidebar_frame = ttk.Frame(
|
||||||
main_frame, style="Sidebar.TFrame", padding=(0, 0, 0, 15))
|
paned_window, style="Sidebar.TFrame", padding=(0, 0, 0, 15), width=200)
|
||||||
sidebar_frame.grid(row=2, column=0, sticky="nsw")
|
# Prevent content from resizing the frame
|
||||||
# Only the devices frame row expands
|
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_frame.grid_rowconfigure(2, weight=1)
|
||||||
|
|
||||||
sidebar_buttons_frame = ttk.Frame(
|
sidebar_buttons_frame = ttk.Frame(
|
||||||
@@ -342,70 +349,31 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
row=1, column=0, sticky="ew", padx=20, pady=15)
|
row=1, column=0, sticky="ew", padx=20, pady=15)
|
||||||
|
|
||||||
# Mounted devices
|
# Mounted devices
|
||||||
devices_outer_frame = ttk.Frame(sidebar_frame, style="Sidebar.TFrame")
|
mounted_devices_frame = ttk.Frame(
|
||||||
devices_outer_frame.grid(row=2, column=0, sticky="nsw", padx=10)
|
sidebar_frame, style="Sidebar.TFrame")
|
||||||
devices_outer_frame.grid_rowconfigure(0, weight=1)
|
mounted_devices_frame.grid(row=2, column=0, sticky="nsew", padx=10)
|
||||||
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,
|
ttk.Label(mounted_devices_frame, text="Geräte:", background=self.sidebar_color,
|
||||||
foreground=self.color_foreground).pack(fill="x", padx=10, pady=(5, 0))
|
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():
|
for device_name, mount_point, removable in self._get_mounted_devices():
|
||||||
icon = self.icons['usb_small'] if removable else self.icons['device_small']
|
icon = self.icons['usb_small'] if removable else self.icons['device_small']
|
||||||
button_text = f" {device_name}"
|
button_text = f" {device_name}"
|
||||||
if len(device_name) > 13:
|
if len(device_name) > 15: # Static wrapping for long names
|
||||||
button_text = f" {device_name[:13]}\n{device_name[13:]}"
|
button_text = f" {device_name[:15]}\n{device_name[15:]}"
|
||||||
|
|
||||||
btn = ttk.Button(mounted_devices_frame, text=button_text, image=icon,
|
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")
|
compound="left", command=lambda p=mount_point: self.navigate_to(p), style="Dark.TButton.Borderless")
|
||||||
btn.pack(fill="x", pady=1)
|
btn.pack(fill="x", pady=1)
|
||||||
device_widgets.append(btn)
|
|
||||||
try:
|
try:
|
||||||
total, used, _ = shutil.disk_usage(mount_point)
|
total, used, _ = shutil.disk_usage(mount_point)
|
||||||
progress_bar = ttk.Progressbar(
|
progress_bar = ttk.Progressbar(
|
||||||
mounted_devices_frame, orient="horizontal", length=100, mode="determinate", style='Small.Horizontal.TProgressbar')
|
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.pack(fill="x", pady=(2, 8), padx=25)
|
||||||
progress_bar['value'] = (used / total) * 100
|
progress_bar['value'] = (used / total) * 100
|
||||||
device_widgets.append(progress_bar)
|
|
||||||
except (FileNotFoundError, PermissionError):
|
except (FileNotFoundError, PermissionError):
|
||||||
|
# In case of errors (e.g., unreadable drive), just skip the progress bar
|
||||||
pass
|
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(
|
tk.Frame(sidebar_frame, height=1, bg=separator_color).grid(
|
||||||
row=3, column=0, sticky="ew", padx=20, pady=15)
|
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)
|
self.storage_bar.pack(fill="x", pady=(2, 5), padx=15)
|
||||||
|
|
||||||
# Content area
|
# Content area
|
||||||
content_frame = ttk.Frame(main_frame, padding=(
|
content_frame = ttk.Frame(paned_window, padding=(
|
||||||
0, 0, 0, 0), style="AccentBottom.TFrame")
|
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_rowconfigure(0, weight=1)
|
||||||
content_frame.grid_columnconfigure(0, weight=1)
|
content_frame.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ if __name__ == "__main__":
|
|||||||
style = ttk.Style(root)
|
style = ttk.Style(root)
|
||||||
root.tk.call('source', f"{theme_path}/water.tcl")
|
root.tk.call('source', f"{theme_path}/water.tcl")
|
||||||
try:
|
try:
|
||||||
root.tk.call('set_theme', 'dark')
|
root.tk.call('set_theme', 'light')
|
||||||
except tk.TclError:
|
except tk.TclError:
|
||||||
pass
|
pass
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
Reference in New Issue
Block a user