add new interface for setting keyboard shortcuts

This commit is contained in:
Andrew Ward
2025-03-21 12:49:05 +00:00
parent ece9d883cf
commit 8a5f92b3cd
2 changed files with 27 additions and 27 deletions

View File

@@ -31,17 +31,17 @@ class TonePresetsManager:
"""Configure ttk styles for a clean, modern appearance""" """Configure ttk styles for a clean, modern appearance"""
style = ttk.Style() style = ttk.Style()
# Clean frame style without the yellow tint # Use namespaced styles with "TonePresets." prefix to avoid affecting global styles
style.configure("TLabelframe", borderwidth=1, relief="solid", background="#ffffff") style.configure("TonePresets.TLabelframe", borderwidth=1, relief="solid", background="#ffffff")
style.configure("TLabelframe.Label", foreground="#333333", background="#ffffff", font=("Arial", 10)) style.configure("TonePresets.TLabelframe.Label", foreground="#333333", background="#ffffff", font=("Arial", 10))
# Clean button style # Namespaced button style
style.configure("TButton", foreground="#333333", background="#f0f0f0", font=("Arial", 10)) style.configure("TonePresets.TButton", foreground="#333333", background="#f0f0f0", font=("Arial", 10))
style.map("TButton", style.map("TonePresets.TButton",
background=[("active", "#e0e0e0"), ("pressed", "#d0d0d0")]) background=[("active", "#e0e0e0"), ("pressed", "#d0d0d0")])
# Label style # Namespaced label style
style.configure("TLabel", foreground="#333333", background="#ffffff", font=("Arial", 10)) style.configure("TonePresets.TLabel", foreground="#333333", background="#ffffff", font=("Arial", 10))
# Listbox and Text widget styling will be applied directly to those widgets # Listbox and Text widget styling will be applied directly to those widgets
@@ -63,7 +63,7 @@ class TonePresetsManager:
def create_dialog(self): def create_dialog(self):
# Main container frame with padding # Main container frame with padding
main_frame = ttk.Frame(self.dialog, padding="10") main_frame = ttk.Frame(self.dialog, padding="10", style="TonePresets.TFrame")
main_frame.pack(fill=tk.BOTH, expand=True) main_frame.pack(fill=tk.BOTH, expand=True)
# Create left panel (tone selection) # Create left panel (tone selection)
@@ -76,11 +76,11 @@ class TonePresetsManager:
self.create_bottom_frame() self.create_bottom_frame()
def create_left_panel(self, main_frame): def create_left_panel(self, main_frame):
left_panel = ttk.Frame(main_frame, width=200) left_panel = ttk.Frame(main_frame, width=200, style="TonePresets.TFrame")
left_panel.pack(side=tk.LEFT, fill=tk.Y, padx=(0, 10)) left_panel.pack(side=tk.LEFT, fill=tk.Y, padx=(0, 10))
left_panel.pack_propagate(False) left_panel.pack_propagate(False)
select_frame = ttk.LabelFrame(left_panel, text="Tone Selection", padding="5") select_frame = ttk.LabelFrame(left_panel, text="Tone Selection", padding="5", style="TonePresets.TLabelframe")
select_frame.pack(fill=tk.BOTH, expand=True) select_frame.pack(fill=tk.BOTH, expand=True)
# Listbox for tones with scrollbar # Listbox for tones with scrollbar
@@ -102,12 +102,12 @@ class TonePresetsManager:
self.tone_list.selection_set(all_tones.index(tone)) self.tone_list.selection_set(all_tones.index(tone))
# Button frame # Button frame
button_frame = ttk.Frame(left_panel) button_frame = ttk.Frame(left_panel, style="TonePresets.TFrame")
button_frame.pack(fill=tk.X, pady=5) button_frame.pack(fill=tk.X, pady=5)
# Action buttons # Action buttons
self.new_button = ttk.Button(button_frame, text="New Tone", command=self.create_new_tone) self.new_button = ttk.Button(button_frame, text="New Tone", command=self.create_new_tone, style="TonePresets.TButton")
self.delete_button = ttk.Button(button_frame, text="Delete", command=self.delete_current_tone) self.delete_button = ttk.Button(button_frame, text="Delete", command=self.delete_current_tone, style="TonePresets.TButton")
self.new_button.pack(side=tk.LEFT, padx=2) self.new_button.pack(side=tk.LEFT, padx=2)
self.delete_button.pack(side=tk.LEFT, padx=2) self.delete_button.pack(side=tk.LEFT, padx=2)
@@ -123,17 +123,17 @@ class TonePresetsManager:
self.update_content() self.update_content()
def create_right_panel(self, main_frame): def create_right_panel(self, main_frame):
self.right_panel = ttk.Frame(main_frame) self.right_panel = ttk.Frame(main_frame, style="TonePresets.TFrame")
self.right_panel.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.right_panel.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
content_frame = ttk.LabelFrame(self.right_panel, text="Tone Description", padding="5") content_frame = ttk.LabelFrame(self.right_panel, text="Tone Description", padding="5", style="TonePresets.TLabelframe")
content_frame.pack(fill=tk.BOTH, expand=True) content_frame.pack(fill=tk.BOTH, expand=True)
self.edit_status_label = ttk.Label(content_frame, foreground="blue") self.edit_status_label = ttk.Label(content_frame, foreground="blue", style="TonePresets.TLabel")
self.edit_status_label.pack(anchor=tk.W, padx=5, pady=(5,0)) self.edit_status_label.pack(anchor=tk.W, padx=5, pady=(5,0))
# Create a frame to contain the text widget and scrollbar # Create a frame to contain the text widget and scrollbar
text_frame = ttk.Frame(content_frame) text_frame = ttk.Frame(content_frame, style="TonePresets.TFrame")
text_frame.pack(fill=tk.BOTH, expand=True, pady=5) text_frame.pack(fill=tk.BOTH, expand=True, pady=5)
# Create vertical scrollbar only # Create vertical scrollbar only
@@ -152,11 +152,11 @@ class TonePresetsManager:
v_scrollbar.config(command=self.content_text.yview) v_scrollbar.config(command=self.content_text.yview)
self.save_changes_button = ttk.Button(self.right_panel, text="Save Changes", self.save_changes_button = ttk.Button(self.right_panel, text="Save Changes",
command=self.save_content_changes, state='disabled') command=self.save_content_changes, state='disabled', style="TonePresets.TButton")
self.save_changes_button.pack(pady=(5, 0), anchor=tk.E) self.save_changes_button.pack(pady=(5, 0), anchor=tk.E)
def create_bottom_frame(self): def create_bottom_frame(self):
bottom_frame = ttk.Frame(self.dialog) bottom_frame = ttk.Frame(self.dialog, style="TonePresets.TFrame")
bottom_frame.pack(side=tk.BOTTOM, fill=tk.X, pady=10, padx=10) bottom_frame.pack(side=tk.BOTTOM, fill=tk.X, pady=10, padx=10)
save_button = ctk.CTkButton( save_button = ctk.CTkButton(
@@ -236,18 +236,18 @@ class TonePresetsManager:
tone_dialog.geometry(f"{dialog_width}x{dialog_height}+{position_x}+{position_y}") tone_dialog.geometry(f"{dialog_width}x{dialog_height}+{position_x}+{position_y}")
# Name entry # Name entry
name_frame = ttk.Frame(tone_dialog, padding="10") name_frame = ttk.Frame(tone_dialog, padding="10", style="TonePresets.TFrame")
name_frame.pack(fill=tk.X) name_frame.pack(fill=tk.X)
ttk.Label(name_frame, text="Tone Name:").pack(side=tk.LEFT) ttk.Label(name_frame, text="Tone Name:", style="TonePresets.TLabel").pack(side=tk.LEFT)
name_entry = ttk.Entry(name_frame) name_entry = ttk.Entry(name_frame)
name_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(5, 0)) name_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(5, 0))
# Tone description # Tone description
desc_frame = ttk.LabelFrame(tone_dialog, text="Tone Description", padding="10") desc_frame = ttk.LabelFrame(tone_dialog, text="Tone Description", padding="10", style="TonePresets.TLabelframe")
desc_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=5) desc_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=5)
# Create a frame for the text widget and scrollbar # Create a frame for the text widget and scrollbar
text_frame = ttk.Frame(desc_frame) text_frame = ttk.Frame(desc_frame, style="TonePresets.TFrame")
text_frame.pack(fill=tk.BOTH, expand=True) text_frame.pack(fill=tk.BOTH, expand=True)
# Create vertical scrollbar only # Create vertical scrollbar only
@@ -302,12 +302,12 @@ class TonePresetsManager:
tone_dialog.destroy() tone_dialog.destroy()
# Buttons # Buttons
button_frame = ttk.Frame(tone_dialog) button_frame = ttk.Frame(tone_dialog, style="TonePresets.TFrame")
button_frame.pack(fill=tk.X, pady=10, padx=10) button_frame.pack(fill=tk.X, pady=10, padx=10)
ttk.Button(button_frame, text="Save", ttk.Button(button_frame, text="Save",
command=save_new_tone).pack(side=tk.RIGHT, padx=5) command=save_new_tone, style="TonePresets.TButton").pack(side=tk.RIGHT, padx=5)
ttk.Button(button_frame, text="Cancel", ttk.Button(button_frame, text="Cancel",
command=tone_dialog.destroy).pack(side=tk.RIGHT) command=tone_dialog.destroy, style="TonePresets.TButton").pack(side=tk.RIGHT)
def delete_current_tone(self): def delete_current_tone(self):
"""Delete the currently selected tone.""" """Delete the currently selected tone."""