commit 16

This commit is contained in:
2025-07-29 08:47:51 +02:00
parent dfa9b033e8
commit 0d82a91e69
3 changed files with 111 additions and 104 deletions

View File

@@ -171,27 +171,43 @@ class CustomFileDialog(tk.Toplevel):
if is_dark:
self.selection_color = "#4a6984" # Darker blue for selection
self.sidebar_color = "#2c2c2c" # Slightly lighter dark grey for sidebar
self.icon_bg_color = "#3c3c3c" # Lighter background for content
self.accent_color = "#2a2a2a" # Darker accent for the bottom
self.header = "#2b2b2b" # Dark Color for Header and round buttons in Header
self.hover_extrastyle = "#4a4a4a" # Hover Color for Buttons in header and Sidebar
self.hover_extrastyle2 = "#494949"
self.sidebar_color = "#333333"
self.color_foreground = "#ffffff"
else:
self.selection_color = "#cce5ff" # Light blue for selection
self.sidebar_color = "#f0f0f0" # Light grey for sidebar
self.icon_bg_color = base_bg # Main background for content
self.accent_color = "#e0e0e0"
# Light Color for Header and round buttons in Header
self.header = "#ffffff"
# Hover Color for Buttons in header and Sidebar
self.hover_extrastyle = "#f5f5f5"
self.hover_extrastyle2 = "#494949" # Hover Color for Buttons in Sidebar
self.sidebar_color = "#d9d9d9"
self.color_foreground = "#000000"
style.configure("Accent.TFrame", background=self.accent_color)
style.configure("Accent.TLabel", background=self.accent_color)
style.configure("Header.TButton.Borderless.Round",
background=self.header)
style.map("Header.TButton.Borderless.Round", background=[
('active', self.hover_extrastyle)])
style.configure("Dark.TButton.Borderless", anchor="w",
background=self.sidebar_color, foreground=self.color_foreground)
style.map("Dark.TButton.Borderless", background=[
('active', self.hover_extrastyle2)])
style.configure("Accent.TFrame", background=self.header)
style.configure("Accent.TLabel", background=self.header)
style.configure("Sidebar.TFrame", background=self.sidebar_color)
style.configure("Sidebar.TButton", background=self.sidebar_color,
# Reverted border settings
anchor="center", padding=(5, 5, 5, 5))
style.map("Sidebar.TButton", background=[
('active', self.selection_color)])
style.configure("Sidebar.TLabel", background=self.sidebar_color,
foreground="black" if not is_dark else "white")
style.configure("Content.TFrame", background=self.icon_bg_color)
style.configure("Item.TFrame", background=self.icon_bg_color)
style.map('Item.TFrame', background=[
@@ -206,75 +222,92 @@ class CustomFileDialog(tk.Toplevel):
style.configure("Treeview.Heading", relief="flat",
borderwidth=0, font=('TkDefaultFont', 10, 'bold'))
style.configure("Treeview", rowheight=28,
background=self.icon_bg_color, fieldbackground=self.icon_bg_color)
background=self.icon_bg_color, fieldbackground=self.icon_bg_color, borderwidth=0)
style.map("Treeview", background=[('selected', self.selection_color)], foreground=[
('selected', "black" if not is_dark else "white")])
style.configure("Toolbutton.TCheckbutton", padding=5,
relief="flat", background=self.icon_bg_color)
style.map("Toolbutton.TCheckbutton",
background=[('active', self.selection_color)],
)
style.configure("Toolbutton.TRadiobutton", padding=5,
relief="flat", background=self.icon_bg_color)
style.map("Toolbutton.TRadiobutton",
background=[('active', self.selection_color)],
)
style.configure("Toolbutton.TButton", padding=0,
relief="flat")
style.map("Toolbutton.TButton",
background=[('active', self.selection_color)],
)
style.configure("Toolbutton_right.TButton", padding=0,
relief="flat", background=self.sidebar_color)
style.map("Toolbutton_right.TButton",
background=[('active', self.selection_color)],
)
style.configure("TButton.Borderless.Round", anchor="w")
def create_widgets(self):
main_frame = ttk.Frame(self, padding=(
0, 0, 10, 0), style='Accent.TFrame')
# 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=1)
paned_window = ttk.PanedWindow(
main_frame, orient=tk.HORIZONTAL, style='Accent.TFrame')
paned_window.pack(fill="both", expand=True)
# Top bar for navigation and path
top_bar = ttk.Frame(
main_frame, style='Accent.TFrame', padding=(0, 5, 0, 5))
top_bar.grid(row=0, column=0, sticky="ew")
top_bar.grid_columnconfigure(1, weight=1)
sidebar_frame = ttk.Frame(paned_window, padding=(
15, 10, 15, 15))
paned_window.add(sidebar_frame, weight=0)
paned_window.pane(0, weight=0)
sidebar_frame.grid_rowconfigure(2, weight=1)
sidebar_nav_frame = ttk.Frame(sidebar_frame)
sidebar_nav_frame.grid(row=0, column=0, sticky="ew")
nav_buttons_container = ttk.Frame(
sidebar_nav_frame)
nav_buttons_container.pack(expand=True)
# Navigation buttons
nav_buttons_container = ttk.Frame(top_bar, style='Accent.TFrame')
nav_buttons_container.grid(row=0, column=0, sticky="w")
self.back_button = ttk.Button(
nav_buttons_container, image=self.icons['back'], command=self.go_back, state=tk.DISABLED, style="TButton.Borderless.Round")
self.back_button.pack(side="left")
nav_buttons_container, image=self.icons['back'], command=self.go_back, state=tk.DISABLED, style="Header.TButton.Borderless.Round")
self.back_button.pack(side="left", padx=10)
Tooltip(self.back_button, "Zurück")
self.home_button = ttk.Button(nav_buttons_container, image=self.icons['home'], command=lambda: self.navigate_to(
os.path.expanduser("~")), style="TButton.Borderless.Round")
self.home_button.pack(side="left", padx=2)
Tooltip(self.home_button, "Home")
self.forward_button = ttk.Button(
nav_buttons_container, image=self.icons['forward'], command=self.go_forward, state=tk.DISABLED, style="TButton.Borderless.Round")
self.forward_button.pack(side="left")
ttk.Separator(sidebar_frame, orient='horizontal').grid(
row=1, column=0, sticky="ew", pady=5)
self.forward_button = ttk.Button(
nav_buttons_container, image=self.icons['forward'], command=self.go_forward, state=tk.DISABLED, style="Header.TButton.Borderless.Round")
self.forward_button.pack(side="left")
Tooltip(self.forward_button, "Vorwärts")
self.home_button = ttk.Button(nav_buttons_container, image=self.icons['home'], command=lambda: self.navigate_to(
os.path.expanduser("~")), style="Header.TButton.Borderless.Round")
self.home_button.pack(side="left", padx=10)
Tooltip(self.home_button, "Home")
# Path entry
self.path_entry = ttk.Entry(top_bar)
self.path_entry.grid(row=0, column=1, sticky="ew")
self.path_entry.bind(
"<Return>", lambda e: self.navigate_to(self.path_entry.get()))
# View switch and hidden files button
right_top_bar_frame = ttk.Frame(top_bar, style='Accent.TFrame')
right_top_bar_frame.grid(row=0, column=2, sticky="e")
view_switch = ttk.Frame(right_top_bar_frame,
padding=(5, 0), style='Accent.TFrame')
view_switch.pack(side="left")
self.icon_view_button = ttk.Button(view_switch, image=self.icons['icon_view'], command=lambda: (
self.view_mode.set("icons"), self.populate_files()), style="Header.TButton.Borderless.Round")
self.icon_view_button.pack(side="left", padx=(50, 10))
Tooltip(self.icon_view_button, "Kachelansicht")
self.list_view_button = ttk.Button(view_switch, image=self.icons['list_view'], command=lambda: (
self.view_mode.set("list"), self.populate_files()), style="Header.TButton.Borderless.Round")
self.list_view_button.pack(side="left")
Tooltip(self.list_view_button, "Listenansicht")
self.hidden_files_button = ttk.Button(
right_top_bar_frame, image=self.icons['hide'], command=self.toggle_hidden_files, style="Header.TButton.Borderless.Round")
self.hidden_files_button.pack(side="left", padx=10)
Tooltip(self.hidden_files_button, "Versteckte Dateien anzeigen")
# Horizontal separator
ttk.Separator(main_frame, orient='horizontal').grid(
row=1, column=0, sticky="ew")
# Paned window for sidebar and content
paned_window = ttk.PanedWindow(
main_frame, orient=tk.HORIZONTAL)
paned_window.grid(row=2, column=0, sticky="nsew")
# Sidebar
sidebar_frame = ttk.Frame(
paned_window, style="Sidebar.TFrame", padding=(0, 0, 0, 15))
paned_window.add(sidebar_frame, weight=0)
sidebar_frame.grid_rowconfigure(0, weight=1)
sidebar_buttons_frame = ttk.Frame(
sidebar_frame)
sidebar_buttons_frame.grid(row=2, column=0, sticky="nsew")
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': '/'},
@@ -291,57 +324,31 @@ class CustomFileDialog(tk.Toplevel):
]
for config in sidebar_buttons_config:
btn = ttk.Button(sidebar_buttons_frame, text=f" {config['name']}", image=config['icon'],
compound="top", command=lambda p=config['path']: self.navigate_to(p), style="TButton.Borderless")
compound="left", command=lambda p=config['path']: self.navigate_to(p), style="Dark.TButton.Borderless")
btn.pack(fill="x", pady=1)
storage_frame = ttk.Frame(sidebar_frame)
storage_frame.grid(row=3, column=0, sticky="ew", padx=10)
self.storage_label = ttk.Label(
storage_frame, text="Freier Speicher:")
storage_frame = ttk.Frame(sidebar_frame, style="Sidebar.TFrame")
storage_frame.grid(row=1, column=0, sticky="ew", padx=10)
self.storage_label = ttk.Label(storage_frame, text="Freier Speicher:")
self.storage_label.pack(fill="x")
self.storage_bar = ttk.Progressbar(
storage_frame, orient="horizontal", length=100, mode="determinate")
self.storage_bar.pack(fill="x", pady=(2, 5))
# Content area
content_frame = ttk.Frame(paned_window, padding=(
5, 0, 0, 0), style='Accent.TFrame')
0, 0, 0, 0), style='Content.TFrame')
paned_window.add(content_frame, weight=1)
content_frame.grid_rowconfigure(2, weight=1)
content_frame.grid_rowconfigure(0, weight=1)
content_frame.grid_columnconfigure(0, weight=1)
top_bar = ttk.Frame(content_frame, style='Accent.TFrame')
top_bar.grid(row=0, column=0, sticky="ew", pady=(10, 0))
top_bar.grid_columnconfigure(0, weight=1)
self.path_entry = ttk.Entry(top_bar)
self.path_entry.grid(row=0, column=0, sticky="ew")
self.path_entry.bind(
"<Return>", lambda e: self.navigate_to(self.path_entry.get()))
view_switch = ttk.Frame(top_bar, padding=(5, 0), style='Accent.TFrame')
view_switch.grid(row=0, column=1)
self.icon_view_button = ttk.Button(view_switch, image=self.icons['icon_view'], command=lambda: (
self.view_mode.set("icons"), self.populate_files()), style="TButton.Borderless.Round")
self.icon_view_button.pack(side="left")
Tooltip(self.icon_view_button, "Kachelansicht")
self.list_view_button = ttk.Button(view_switch, image=self.icons['list_view'], command=lambda: (
self.view_mode.set("list"), self.populate_files()), style="TButton.Borderless.Round")
self.list_view_button.pack(side="left")
Tooltip(self.list_view_button, "Listenansicht")
self.hidden_files_button = ttk.Button(
top_bar, image=self.icons['hide'], command=self.toggle_hidden_files, style="TButton.Borderless.Round")
self.hidden_files_button.grid(row=0, column=2, padx=5)
Tooltip(self.hidden_files_button, "Versteckte Dateien anzeigen")
ttk.Separator(content_frame, orient='horizontal').grid(
row=1, column=0, sticky="ew", pady=5)
self.file_list_frame = ttk.Frame(content_frame, style="Content.TFrame")
self.file_list_frame.grid(row=2, column=0, sticky="nsew")
self.file_list_frame.grid(row=0, column=0, sticky="nsew")
self.bind("<Configure>", self.on_window_resize)
# Bottom controls
bottom_controls_frame = ttk.Frame(content_frame, style="Accent.TFrame")
bottom_controls_frame.grid(row=3, column=0, sticky="ew", pady=(5, 0))
bottom_controls_frame.grid(row=1, column=0, sticky="ew", pady=(5, 0))
bottom_controls_frame.grid_columnconfigure(0, weight=1)
self.status_bar = ttk.Label(
@@ -354,7 +361,7 @@ class CustomFileDialog(tk.Toplevel):
self.filter_combobox = ttk.Combobox(
right_side_buttons_frame, values=[ft[0] for ft in self.filetypes], state="readonly", width=20)
self.filter_combobox.pack(anchor="e", pady=(0, 5))
self.filter_combobox.pack(anchor="e", pady=10)
self.filter_combobox.bind(
"<<ComboboxSelected>>", self.on_filter_change)
self.filter_combobox.set(self.filetypes[0][0])

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