Skip to content

Commit 7e952fb

Browse files
author
marci
committed
refactor: Vereinheitlichung der Layout-Elemente und Verbesserung der Lesbarkeit
- Anpassung der Layout-Elemente in den Dialogen zur Schriftart- und Größenanpassung. - Vereinheitlichung der Button-Definitionen in der Toolbar für bessere Lesbarkeit. - Entfernung überflüssiger Leerzeilen zur Optimierung des Codes. Diese Änderungen verbessern die Struktur und Lesbarkeit des Codes im Bash-Script-Maker.
1 parent 54eaaf2 commit 7e952fb

File tree

2 files changed

+55
-38
lines changed

2 files changed

+55
-38
lines changed

bash_script_maker.py

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def __init__(self, parent, editor):
3737
container.pack(fill=tk.BOTH, expand=True)
3838

3939
# Schriftfamilie
40-
font_frame = ttk.Labelframe(
41-
container, text=_("Schriftart"), padding=10
42-
)
40+
font_frame = ttk.Labelframe(container, text=_("Schriftart"), padding=10)
4341
font_frame.pack(fill=tk.X, pady=5)
4442

4543
# Empfohlene Schriftarten für Code
@@ -52,7 +50,7 @@ def __init__(self, parent, editor):
5250
"Menlo",
5351
"Monaco",
5452
]
55-
53+
5654
try:
5755
# Versuche, System-Schriftarten zu laden
5856
system_fonts = sorted(
@@ -62,7 +60,7 @@ def __init__(self, parent, editor):
6260
except Exception:
6361
# Fallback, falls das Laden fehlschlägt
6462
all_fonts = sorted(preferred_fonts)
65-
63+
6664
if not all_fonts:
6765
# Fallback, falls gar keine Schriftarten gefunden werden
6866
all_fonts = ["Courier New", "Consolas", "Monaco"]
@@ -74,17 +72,14 @@ def __init__(self, parent, editor):
7472
bootstyle="warning",
7573
).pack(pady=5)
7674

77-
7875
self.font_var = tk.StringVar(value=current_font_family)
7976
self.font_combo = ttk.Combobox(
8077
font_frame, textvariable=self.font_var, values=all_fonts
8178
)
8279
self.font_combo.pack(fill=tk.X)
8380

8481
# Schriftgröße
85-
size_frame = ttk.Labelframe(
86-
container, text=_("Schriftgröße"), padding=10
87-
)
82+
size_frame = ttk.Labelframe(container, text=_("Schriftgröße"), padding=10)
8883
size_frame.pack(fill=tk.X, pady=5)
8984

9085
self.size_var = tk.IntVar(value=current_font_size)
@@ -106,7 +101,10 @@ def __init__(self, parent, editor):
106101
apply_btn.pack(side=tk.RIGHT, padx=(5, 0))
107102

108103
close_btn = ttk.Button(
109-
button_frame, text=_("Schließen"), command=self.destroy, bootstyle="secondary"
104+
button_frame,
105+
text=_("Schließen"),
106+
command=self.destroy,
107+
bootstyle="secondary",
110108
)
111109
close_btn.pack(side=tk.RIGHT)
112110

@@ -138,9 +136,7 @@ def __init__(self, parent):
138136
desc_label = ttk.Label(container, text=desc_text, wraplength=400)
139137
desc_label.pack(pady=(0, 20))
140138

141-
features_frame = ttk.Labelframe(
142-
container, text=_("Funktionen"), padding=15
143-
)
139+
features_frame = ttk.Labelframe(container, text=_("Funktionen"), padding=15)
144140
features_frame.pack(fill=tk.BOTH, expand=True, pady=5)
145141

146142
features = [
@@ -358,46 +354,61 @@ def create_main_interface(self):
358354
toolbar.pack(side=tk.TOP, fill=tk.X, padx=5, pady=(5, 0))
359355

360356
# Toolbar-Inhalte - LINKS
361-
btn_new = ttk.Button(toolbar, text=_("Neu"), command=self.new_script, bootstyle="primary")
357+
btn_new = ttk.Button(
358+
toolbar, text=_("Neu"), command=self.new_script, bootstyle="primary"
359+
)
362360
btn_new.pack(side=tk.LEFT, padx=(0, 5), pady=20)
363361
ToolTip(btn_new, text=_("Erstellt ein neues, leeres Script (Ctrl+N)"))
364-
btn_open = ttk.Button(toolbar, text=_("Öffnen"), command=self.open_script, bootstyle="secondary")
362+
btn_open = ttk.Button(
363+
toolbar, text=_("Öffnen"), command=self.open_script, bootstyle="secondary"
364+
)
365365
btn_open.pack(side=tk.LEFT, padx=(5, 0), pady=20)
366366
ToolTip(btn_open, text=_("Öffnet ein vorhandenes Script (Ctrl+O)"))
367-
btn_save = ttk.Button(toolbar, text=_("Speichern"), command=self.save_script, bootstyle="info")
367+
btn_save = ttk.Button(
368+
toolbar, text=_("Speichern"), command=self.save_script, bootstyle="info"
369+
)
368370
btn_save.pack(side=tk.LEFT, padx=(5, 0), pady=20)
369371
ToolTip(btn_save, text=_("Speichert das aktuelle Script (Ctrl+S)"))
370-
btn_exec = ttk.Button(toolbar, text=_("Ausführen"), command=self.execute_script, bootstyle="success")
371-
btn_exec.pack(side=tk.LEFT, padx=(5, 15), pady=20) # Extra Abstand nach dem letzten Button
372+
btn_exec = ttk.Button(
373+
toolbar,
374+
text=_("Ausführen"),
375+
command=self.execute_script,
376+
bootstyle="success",
377+
)
378+
btn_exec.pack(
379+
side=tk.LEFT, padx=(5, 15), pady=20
380+
) # Extra Abstand nach dem letzten Button
372381
ToolTip(btn_exec, text=_("Führt das aktuelle Script aus (F5)"))
373-
382+
374383
# Separator für visuelle Trennung
375384
separator = ttk.Separator(toolbar, orient=tk.VERTICAL)
376-
separator.pack(side=tk.LEFT, fill='y', padx=5, pady=20)
385+
separator.pack(side=tk.LEFT, fill="y", padx=5, pady=20)
377386

378387
# Toolbar-Inhalte - RECHTS
379388
script_name_label = ttk.Label(toolbar, text=_("Script-Name:"))
380389
script_name_label.pack(side=tk.LEFT, padx=(5, 5), pady=20)
381-
390+
382391
self.name_entry = ttk.Entry(toolbar, width=40)
383-
self.name_entry.pack(side=tk.LEFT, padx=(0, 10), fill=tk.X, expand=True, pady=20)
392+
self.name_entry.pack(
393+
side=tk.LEFT, padx=(0, 10), fill=tk.X, expand=True, pady=20
394+
)
384395
self.name_entry.insert(0, self.script_name)
385396
self.name_entry.bind("<KeyRelease>", self.update_script_name)
386397

387398
# Hauptcontainer für linke und rechte Spalte (füllt den Rest des Platzes)
388399
main_container = ttk.Frame(self.root)
389400
main_container.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
390-
401+
391402
main_container.grid_rowconfigure(0, weight=1)
392-
main_container.grid_columnconfigure(1, weight=1) # Rechte Spalte soll wachsen
403+
main_container.grid_columnconfigure(1, weight=1) # Rechte Spalte soll wachsen
393404

394405
return main_container
395406

396407
def create_command_palette(self, parent):
397408
"""Erstellt die Befehlspalette mit verfügbaren Komponenten"""
398409
left_frame = ttk.LabelFrame(parent, text=_("Befehle & Komponenten"), padding=5)
399410
left_frame.grid(row=0, column=0, sticky="nswe")
400-
411+
401412
self.notebook = ttk.Notebook(left_frame, bootstyle="primary")
402413
self.notebook.pack(fill=tk.BOTH, expand=True)
403414

@@ -507,17 +518,19 @@ def create_script_editor(self, parent):
507518
editor_container.grid_rowconfigure(0, weight=1)
508519
editor_container.grid_columnconfigure(0, weight=1)
509520

510-
right_frame = ttk.LabelFrame(editor_container, text=_("Script-Editor"), padding=5)
521+
right_frame = ttk.LabelFrame(
522+
editor_container, text=_("Script-Editor"), padding=5
523+
)
511524
right_frame.grid(row=0, column=0, sticky="nswe")
512-
525+
513526
self.text_editor = EnhancedScriptEditor(
514527
right_frame, wrap=tk.WORD, autohide=True, vbar=True, hbar=True
515528
)
516529
self.text_editor.pack(fill=tk.BOTH, expand=True)
517530

518531
# Support-Bereich unter dem Editor
519532
self.create_support_area(editor_container)
520-
533+
521534
def create_support_area(self, parent):
522535
"""Erstellt den Bereich für die Support-Buttons."""
523536
support_frame = ttk.LabelFrame(
@@ -533,9 +546,7 @@ def create_support_area(self, parent):
533546
support_frame,
534547
text="GitHub Sponsors",
535548
bootstyle="success-outline",
536-
command=lambda: self.open_link(
537-
"https://github.com/sponsors/securebitsorg"
538-
),
549+
command=lambda: self.open_link("https://github.com/sponsors/securebitsorg"),
539550
)
540551
github_btn.grid(row=0, column=0, padx=10, pady=10, sticky="ew")
541552
ToolTip(github_btn, text=_("Unterstütze das Projekt auf GitHub Sponsors"))
@@ -628,7 +639,9 @@ def save_script(self):
628639
file.write(content)
629640
self.status_var.set(_("Script gespeichert: {}").format(file_path))
630641
except Exception as e:
631-
messagebox.showerror(_("Fehler"), _("Fehler beim Speichern: {}").format(str(e)))
642+
messagebox.showerror(
643+
_("Fehler"), _("Fehler beim Speichern: {}").format(str(e))
644+
)
632645

633646
def save_script_as(self):
634647
"""Speichert das Script unter einem neuen Namen"""

syntax_highlighter.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,12 @@ def configure_tags(self):
579579
"""Konfiguriert die Text-Tags für das Solarized Dark Theme"""
580580
# Solarized Dark Palette
581581
sol_base01 = "#586e75" # Comments
582-
sol_cyan = "#2aa198" # Shebang
582+
sol_cyan = "#2aa198" # Shebang
583583
sol_orange = "#cb4b16" # Strings, Numbers
584-
sol_blue = "#268bd2" # Variables
585-
sol_green = "#859900" # Commands, Keywords
586-
sol_magenta = "#d33682" # Operators
587-
sol_base0 = "#839496" # Brackets
584+
sol_blue = "#268bd2" # Variables
585+
sol_green = "#859900" # Commands, Keywords
586+
sol_magenta = "#d33682" # Operators
587+
sol_base0 = "#839496" # Brackets
588588

589589
# Kommentare
590590
self.tag_configs["comments"] = {
@@ -777,7 +777,11 @@ def update_font(self, font_family, font_size):
777777
# Sorge dafür, dass die Syntax-Tags die neue Schriftgröße übernehmen, aber ihre Stile beibehalten
778778
for tag_name, config in self.highlighter.tag_configs.items():
779779
font_config = config.get("font")
780-
if font_config and isinstance(font_config, (list, tuple)) and len(font_config) == 3:
780+
if (
781+
font_config
782+
and isinstance(font_config, (list, tuple))
783+
and len(font_config) == 3
784+
):
781785
# Behält den Stil (italic, bold) bei
782786
style = font_config[2]
783787
self.text.tag_configure(tag_name, font=(font_family, font_size, style))

0 commit comments

Comments
 (0)