-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffice_gui.py
More file actions
1096 lines (956 loc) · 36.1 KB
/
Copy pathoffice_gui.py
File metadata and controls
1096 lines (956 loc) · 36.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import subprocess
import sys
import threading
import webbrowser
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List
import tkinter as tk
from tkinter import messagebox
import customtkinter as ctk
from PIL import Image
try:
from CTkMessagebox import CTkMessagebox
except ImportError: # Fallback, falls Paket nicht vorhanden
CTkMessagebox = None
# ---------------------------------------------------------------------------
# Helper für Messagebox
# ---------------------------------------------------------------------------
def show_message(title: str, message: str, icon: str = "info"):
if CTkMessagebox is not None:
CTkMessagebox(title=title, message=message, icon=icon)
else:
if icon == "cancel":
messagebox.showerror(title, message)
elif icon == "check":
messagebox.showinfo(title, message)
else:
messagebox.showinfo(title, message)
# ---------------------------------------------------------------------------
# Pfade & Branding
# ---------------------------------------------------------------------------
if getattr(sys, "frozen", False):
APP_DIR = Path(sys.executable).resolve().parent
BUNDLE_DIR = Path(sys._MEIPASS)
else:
APP_DIR = Path(__file__).resolve().parent
BUNDLE_DIR = APP_DIR
# PS-Script liegt im Bundle (mit --add-data eingebunden)
OFFICE_PS = BUNDLE_DIR / "office_installer.ps1"
# Logo kann ebenfalls aus dem Bundle geladen werden
LOGO_PATH = BUNDLE_DIR / "sditlab_logo.png"
ICON_PATH = BUNDLE_DIR / "sditlab.ico"
APP_NAME = "SD-ITLab Office Installer"
BRAND_TEXT = "© 2026 SD-ITLab – MIT licensed"
BRAND_URL = "https://sd-itlab.de"
LOGO_URL = BRAND_URL
README_URL = "https://github.com/SD-ITLab/SD-OfficeDeploy"
ACCENT = "#3B82F6"
# ---------------------------------------------------------------------------
# Sprach-Optionen (Anzeigename -> Code)
# ---------------------------------------------------------------------------
LANG_OPTIONS = [
("Deutsch (de-de)", "de-de"),
("English (en-us)", "en-us"),
("Polnisch (pl-pl)", "pl-pl"),
("Italienisch (it-it)", "it-it"),
("Französisch (fr-fr)", "fr-fr"),
("Kroatisch (hr-hr)", "hr-hr"),
("Türkisch (tr-tr)", "tr-tr"),
("Russisch (ru-ru)", "ru-ru"),
]
LANG_DISPLAY_VALUES = [label for label, _ in LANG_OPTIONS]
LANG_MAP = {label: code for label, code in LANG_OPTIONS}
# ---------------------------------------------------------------------------
# Office-Presets (Retail und LTSC/Volume)
# ---------------------------------------------------------------------------
@dataclass(frozen=True)
class OfficePreset:
key: str
label: str
product_id: str
channel: str
shortcut_apps: List[str]
exclude_apps: List[str]
OFFICE_PRODUCTS: Dict[str, OfficePreset] = {
# --- Microsoft 365 (eigene Gruppe) -------------------------------------
"m365_family": OfficePreset(
key="m365_family",
label="Microsoft 365 Family",
product_id="O365HomePremRetail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
"m365_single": OfficePreset(
key="m365_single",
label="Microsoft 365 Single",
product_id="O365HomePremRetail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
# --- 2024 ---------------------------------------------------------------
"2024_home_student": OfficePreset( # Key bleibt, Label geändert
key="2024_home_student",
label="Office 2024 Home",
product_id="Home2024Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint"],
exclude_apps=["Outlook", "Access", "Publisher", "Teams"],
),
"2024_business": OfficePreset(
key="2024_business",
label="Office 2024 Home & Business",
product_id="HomeBusiness2024Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
"2024_professional": OfficePreset(
key="2024_professional",
label="Office 2024 Professional Plus",
product_id="ProPlus2024Retail",
channel="Current",
shortcut_apps=[
"Word",
"Excel",
"PowerPoint",
"Outlook",
"Access",
"Publisher",
],
exclude_apps=["Teams"],
),
# --- 2021 ---------------------------------------------------------------
"2021_home_student": OfficePreset(
key="2021_home_student",
label="Office 2021 Home & Student",
product_id="HomeStudent2021Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint"],
exclude_apps=["Outlook", "Access", "Publisher", "Teams"],
),
"2021_business": OfficePreset(
key="2021_business",
label="Office 2021 Home & Business",
product_id="HomeBusiness2021Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
"2021_professional": OfficePreset(
key="2021_professional",
label="Office 2021 Professional Plus",
product_id="ProPlus2021Retail",
channel="Current",
shortcut_apps=[
"Word",
"Excel",
"PowerPoint",
"Outlook",
"Access",
"Publisher",
],
exclude_apps=["Teams"],
),
# --- 2019 ---------------------------------------------------------------
"2019_home_student": OfficePreset(
key="2019_home_student",
label="Office 2019 Home & Student",
product_id="HomeStudent2019Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint"],
exclude_apps=["Outlook", "Access", "Publisher", "Teams"],
),
"2019_business": OfficePreset(
key="2019_business",
label="Office 2019 Home & Business",
product_id="HomeBusiness2019Retail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
"2019_professional": OfficePreset(
key="2019_professional",
label="Office 2019 Professional Plus",
product_id="ProPlus2019Retail",
channel="Current",
shortcut_apps=[
"Word",
"Excel",
"PowerPoint",
"Outlook",
"Access",
"Publisher",
],
exclude_apps=["Teams"],
),
# --- 2016 ---------------------------------------------------------------
"2016_home_student": OfficePreset(
key="2016_home_student",
label="Office 2016 Home & Student",
product_id="HomeStudentRetail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint"],
exclude_apps=["Outlook", "Access", "Publisher", "Teams"],
),
"2016_business": OfficePreset(
key="2016_business",
label="Office 2016 Home & Business",
product_id="HomeBusinessRetail",
channel="Current",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook"],
exclude_apps=["Access", "Publisher", "Teams"],
),
"2016_professional": OfficePreset(
key="2016_professional",
label="Office 2016 Professional",
product_id="ProfessionalRetail",
channel="Current",
shortcut_apps=[
"Word",
"Excel",
"PowerPoint",
"Outlook",
"Access",
"Publisher",
],
exclude_apps=["Teams"],
),
# --- LTSC / Volumenlizenz -----------------------------------------------
"2024_ltsc_standard": OfficePreset(
key="2024_ltsc_standard",
label="Office LTSC 2024 Standard",
product_id="Standard2024Volume",
channel="PerpetualVL2024",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Publisher"],
exclude_apps=["Access", "Teams"],
),
"2024_ltsc_professional": OfficePreset(
key="2024_ltsc_professional",
label="Office LTSC 2024 Professional Plus",
product_id="ProPlus2024Volume",
channel="PerpetualVL2024",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Access", "Publisher"],
exclude_apps=["Teams"],
),
"2021_ltsc_standard": OfficePreset(
key="2021_ltsc_standard",
label="Office LTSC 2021 Standard",
product_id="Standard2021Volume",
channel="PerpetualVL2021",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Publisher"],
exclude_apps=["Access", "Teams"],
),
"2021_ltsc_professional": OfficePreset(
key="2021_ltsc_professional",
label="Office LTSC 2021 Professional Plus",
product_id="ProPlus2021Volume",
channel="PerpetualVL2021",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Access", "Publisher"],
exclude_apps=["Teams"],
),
"2019_ltsc_standard": OfficePreset(
key="2019_ltsc_standard",
label="Office 2019 Standard (Volume)",
product_id="Standard2019Volume",
channel="PerpetualVL2019",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Publisher"],
exclude_apps=["Access", "Teams"],
),
"2019_ltsc_professional": OfficePreset(
key="2019_ltsc_professional",
label="Office 2019 Professional Plus (Volume)",
product_id="ProPlus2019Volume",
channel="PerpetualVL2019",
shortcut_apps=["Word", "Excel", "PowerPoint", "Outlook", "Access", "Publisher"],
exclude_apps=["Teams"],
),}
# Seitenleiste: (Label, interner Key)
OFFICE_VERSIONS = [
("Microsoft 365", "m365"),
("2024 - Retail", "2024_retail"),
("2021 - Retail", "2021_retail"),
("2019 - Retail", "2019_retail"),
("2016 - Retail", "2016_retail"),
("2024 - LTSC", "2024_ltsc"),
("2021 - LTSC", "2021_ltsc"),
("2019 - LTSC", "2019_ltsc"),
]
# ---------------------------------------------------------------------------
# GUI-Komponenten
# ---------------------------------------------------------------------------
class EditionCard(ctk.CTkFrame):
def __init__(
self,
master,
title: str,
description: str,
variable: ctk.StringVar,
value: str,
on_select=None,
**kwargs,
):
super().__init__(master, **kwargs)
self.variable = variable
self.value = value
self.on_select = on_select
self._trace_id = None # wird gleich gesetzt
self.configure(corner_radius=12, fg_color="#F9FAFB")
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
self.title_label = ctk.CTkLabel(
self,
text=title,
font=ctk.CTkFont(size=14, weight="bold"),
anchor="w",
)
self.title_label.grid(row=0, column=0, sticky="ew", padx=16, pady=(10, 2))
self.desc_label = ctk.CTkLabel(
self,
text=description,
font=ctk.CTkFont(size=11),
text_color="#6B7280",
anchor="w",
justify="left",
wraplength=420,
)
self.desc_label.grid(row=1, column=0, sticky="ew", padx=16, pady=(0, 10))
# Klickbar machen
for w in (self, self.title_label, self.desc_label):
w.bind("<Button-1>", self._on_click)
# Style initial
self._update_style(self.variable.get() == self.value)
# Trace registrieren und ID merken, damit wir ihn später entfernen können
self._trace_id = self.variable.trace_add("write", self._on_variable_changed)
def _on_click(self, _event=None):
self.variable.set(self.value)
if callable(self.on_select):
self.on_select()
def _on_variable_changed(self, *args):
"""Wird von trace_add aufgerufen, wenn sich der StringVar-Wert ändert."""
# Wenn das Widget bereits zerstört ist: nichts tun
if not self.winfo_exists():
return
self._update_style(self.variable.get() == self.value)
def _update_style(self, selected: bool):
"""Optik je nach Auswahlzustand anpassen."""
try:
if selected:
self.configure(fg_color="#DBEAFE")
self.title_label.configure(text_color="#1D4ED8")
else:
self.configure(fg_color="#F9FAFB")
self.title_label.configure(text_color="#111827")
except tk.TclError:
# Falls Tk zwischenzeitlich schon zerstört wurde, Fehler ignorieren
pass
def destroy(self):
"""Beim Zerstören den trace wieder deregistrieren, damit keine Ghost-Callbacks bleiben."""
try:
if self._trace_id is not None:
self.variable.trace_remove("write", self._trace_id)
except Exception:
pass
super().destroy()
# ---------------------------------------------------------------------------
# Hauptfenster
# ---------------------------------------------------------------------------
class OfficeInstallerApp(ctk.CTk):
def __init__(self):
super().__init__()
ctk.set_appearance_mode("light")
ctk.set_default_color_theme("blue")
self.title(APP_NAME)
# Fenster-Icon setzen
if ICON_PATH.exists():
try:
self.iconbitmap(str(ICON_PATH))
except Exception:
pass
# Feste Größe, mittig
width, height = 1000, 540
self.geometry(f"{width}x{height}")
self.resizable(False, False)
self.update_idletasks()
screen_w = self.winfo_screenwidth()
screen_h = self.winfo_screenheight()
x = (screen_w // 2) - (width // 2)
y = (screen_h // 2) - (height // 2)
self.geometry(f"{width}x{height}+{x}+{y}")
self._installing = False
self._logo_img = None
# State
# Default: 2024 Home
self.selected_year = ctk.StringVar(value="2024_retail")
self.selected_preset = ctk.StringVar(value="2024_home_student")
# Sprache als Anzeige- und Code-Var getrennt
self.selected_lang_display = ctk.StringVar(value=LANG_DISPLAY_VALUES[0])
self.selected_lang_code = ctk.StringVar(value=LANG_OPTIONS[0][1])
self.selected_arch = ctk.StringVar(value="64")
# Grid: Sidebar | Main | RightPanel + Bottombar
self.grid_rowconfigure(0, weight=1)
self.grid_rowconfigure(1, weight=0)
self.grid_columnconfigure(0, weight=0)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure(2, weight=0)
self._build_sidebar()
self._build_main()
self._build_right_panel()
self._build_bottom()
self._update_edition_cards()
self.bind_all("<Up>", self._on_key_up)
self.bind_all("<Down>", self._on_key_down)
self.bind_all("<Left>", self._on_key_left)
self.bind_all("<Right>", self._on_key_right)
self.bind_all("<Return>", self._on_key_activate)
self.bind_all("<space>", self._on_key_activate)
# ------------------------------------------------------------------ Tastatur-Navigation
def _set_cards_focus(self, state: bool):
"""Aktiviert/deaktiviert den 'Editionsbereich ist im Fokus'-Modus."""
self._cards_focus = bool(state)
def _get_current_card_index(self) -> int:
"""Index der aktuell gewählten EditionCard anhand selected_preset."""
current_key = self.selected_preset.get()
for idx, card in enumerate(self.edition_cards):
if card.value == current_key:
return idx
return 0
def _select_card_by_index(self, idx: int):
"""Hilfsfunktion: Edition per Index auswählen."""
if not self.edition_cards:
return
idx = idx % len(self.edition_cards)
self.selected_preset.set(self.edition_cards[idx].value)
def _change_year_by_offset(self, delta: int):
"""Wechselt das Jahr in der linken Leiste relativ (nur im Cards-Fokus)."""
year_keys = [key for (_label, key) in OFFICE_VERSIONS]
current = self.selected_year.get()
if current not in year_keys:
return
idx = year_keys.index(current)
idx = (idx + delta) % len(year_keys)
new_year = year_keys[idx]
self._on_year_selected(new_year)
def _on_key_up(self, event):
# Nur reagieren, wenn wir im Editions-Fokus sind und keine Installation läuft
if not self._cards_focus or self._installing:
return # Standard-Verhalten beibehalten
idx = self._get_current_card_index()
self._select_card_by_index(idx - 1)
return "break"
def _on_key_down(self, event):
if not self._cards_focus or self._installing:
return
idx = self._get_current_card_index()
self._select_card_by_index(idx + 1)
return "break"
def _on_key_left(self, event):
if not self._cards_focus or self._installing:
return
self._change_year_by_offset(-1)
return "break"
def _on_key_right(self, event):
if not self._cards_focus or self._installing:
return
self._change_year_by_offset(+1)
return "break"
def _on_key_activate(self, event):
"""
Enter/Space:
- Wenn wir im Editions-Fokus sind -> Installation starten.
- Sonst: nichts tun (Buttons/Combos verhalten sich normal).
"""
if not self._cards_focus or self._installing:
return # Standard-Verhalten für Buttons/Combos beibehalten
self._on_install_clicked()
return "break"
def _cycle_combobox(self, combobox: ctk.CTkComboBox, direction: int):
"""Wechselt den Wert der Combobox per Pfeiltaste."""
values = list(combobox.cget("values"))
if not values:
return
current = combobox.get()
try:
idx = values.index(current)
except ValueError:
idx = 0
idx = (idx + direction) % len(values)
combobox.set(values[idx])
# ------------------------------------------------------------------ UI --
def _build_sidebar(self):
sidebar = ctk.CTkFrame(self, fg_color="#F3F4F6")
sidebar.grid(row=0, column=0, sticky="nsw")
sidebar.grid_columnconfigure(0, weight=1)
header = ctk.CTkLabel(
sidebar,
text="Office-Version",
font=ctk.CTkFont(size=14, weight="bold"),
)
header.grid(row=0, column=0, padx=12, pady=(10, 6), sticky="w")
self.year_buttons: Dict[str, ctk.CTkButton] = {}
row = 1
for label, key in OFFICE_VERSIONS:
if key == "2024_ltsc":
separator = ctk.CTkFrame(sidebar, height=1, fg_color="#D1D5DB")
separator.grid(row=row, column=0, padx=12, pady=(8, 8), sticky="ew")
row += 1
btn = ctk.CTkButton(
sidebar,
text=label,
command=lambda k=key: self._on_year_selected(k),
fg_color="#E5E7EB",
text_color="#111827",
hover_color="#D1D5DB",
corner_radius=8,
height=32,
)
btn.grid(row=row, column=0, padx=12, pady=3, sticky="ew")
self.year_buttons[key] = btn
row += 1
sidebar.grid_rowconfigure(row, weight=1)
self._update_year_buttons()
def _build_main(self):
main = ctk.CTkFrame(self, fg_color="white")
main.grid(row=0, column=1, sticky="nsew", padx=(12, 8), pady=(12, 0))
main.grid_columnconfigure(0, weight=1)
main.grid_rowconfigure(0, weight=0)
main.grid_rowconfigure(1, weight=0)
main.grid_rowconfigure(2, weight=1)
title = ctk.CTkLabel(
main,
text="SD-ITLab Office Installer",
font=ctk.CTkFont(size=20, weight="bold"),
anchor="w",
)
title.grid(row=0, column=0, sticky="ew", padx=8, pady=(6, 2))
subtitle = ctk.CTkLabel(
main,
text=(
"Wähle Office-Version und Edition. Die Installation läuft "
"unbeaufsichtigt im Hintergrund."
),
font=ctk.CTkFont(size=11),
text_color="#6B7280",
anchor="w",
)
subtitle.grid(row=1, column=0, sticky="ew", padx=8, pady=(0, 10))
cards_frame = ctk.CTkFrame(main, fg_color="white")
cards_frame.grid(row=2, column=0, sticky="nsew", padx=4, pady=(0, 8))
cards_frame.grid_columnconfigure(0, weight=1)
self.cards_frame = cards_frame
self.edition_cards: List[EditionCard] = []
# Fokus-Anker für Keyboard-Navigation der Editionen
self.cards_focus = tk.Frame(cards_frame, takefocus=1, width=1, height=1)
self.cards_focus.grid(row=0, column=0, sticky="w")
# Wenn dieser Frame den Fokus bekommt / verliert, schalten wir den "Card-Fokus"-Modus
self._cards_focus = False
self.cards_focus.bind("<FocusIn>", lambda e: self._set_cards_focus(True))
self.cards_focus.bind("<FocusOut>", lambda e: self._set_cards_focus(False))
def _build_right_panel(self):
right = ctk.CTkFrame(self, fg_color="#F3F4F6")
right.grid(row=0, column=2, sticky="nse", padx=(8, 12), pady=(12, 0))
right.grid_columnconfigure(0, weight=1)
# Logo-Box
logo_box = ctk.CTkFrame(
right,
fg_color="#EFF4FF",
corner_radius=18,
width=240,
height=140,
border_width=1,
border_color="#E5E7EB",
)
logo_box.grid(row=0, column=0, sticky="n", padx=4, pady=(4, 6))
logo_box.grid_propagate(False)
self.logo_label = ctk.CTkLabel(logo_box, text="")
self.logo_label.place(relx=0.5, rely=0.5, anchor="center")
self.logo_label.configure(cursor="hand2")
self.logo_label.bind("<Button-1>", lambda e: self._open_url(LOGO_URL))
self._load_logo()
# Installationsoptionen (Architektur / Language)
opt_title = ctk.CTkLabel(
right,
text="Installationsoptionen",
font=ctk.CTkFont(size=13, weight="bold"),
)
opt_title.grid(row=1, column=0, sticky="w", padx=6, pady=(8, 2))
opt_frame = ctk.CTkFrame(right, fg_color="transparent")
opt_frame.grid(row=2, column=0, sticky="w", padx=6, pady=(0, 6))
# Architektur zuerst
arch_label = ctk.CTkLabel(
opt_frame,
text="Architektur:",
font=ctk.CTkFont(size=11),
anchor="w",
)
arch_label.grid(row=0, column=0, sticky="w", pady=(0, 2))
arch_box = ctk.CTkComboBox(
opt_frame,
values=["64", "32", "ARM64"],
variable=self.selected_arch,
width=100,
state="readonly",
)
arch_box.grid(row=0, column=1, sticky="w", padx=(4, 0))
# ↑ / ↓ für Architektur
arch_box.bind(
"<Up>",
lambda e, cb=arch_box: (
self._cycle_combobox(cb, -1),
"break",
)[-1],
)
arch_box.bind(
"<Down>",
lambda e, cb=arch_box: (
self._cycle_combobox(cb, +1),
"break",
)[-1],
)
# Language danach (mit ausgeschriebenem Namen)
lang_label = ctk.CTkLabel(
opt_frame,
text="Language:",
font=ctk.CTkFont(size=11),
anchor="w",
)
lang_label.grid(row=1, column=0, sticky="w", pady=(6, 2))
lang_box = ctk.CTkComboBox(
opt_frame,
values=LANG_DISPLAY_VALUES,
variable=self.selected_lang_display,
width=160,
command=self._on_language_changed,
state="readonly",
)
lang_box.grid(row=1, column=1, sticky="w", padx=(4, 0))
lang_box.bind(
"<Up>",
lambda e, cb=lang_box: (
self._cycle_combobox(cb, -1),
"break",
)[-1],
)
lang_box.bind(
"<Down>",
lambda e, cb=lang_box: (
self._cycle_combobox(cb, +1),
"break",
)[-1],
)
def _build_bottom(self):
# Untere Leiste
bottom = ctk.CTkFrame(self, fg_color="#F9FAFB")
bottom.grid(
row=1,
column=0,
columnspan=3,
sticky="ew",
padx=2,
pady=(0, 0),
)
# Fixe Mindesthöhe, damit es nicht so gequetscht aussieht
bottom.configure(height=72)
bottom.grid_propagate(False) # Frame behält die gesetzte Höhe
# Spalten: 0 = Progress/Status (streckt), 1 = Brand, 2–4 = Buttons
bottom.grid_columnconfigure(0, weight=1)
for col in (1, 2, 3, 4):
bottom.grid_columnconfigure(col, weight=0)
bottom.grid_rowconfigure(0, weight=0)
bottom.grid_rowconfigure(1, weight=0)
# Progressbar oben in der Leiste, über komplette Breite
self.progress = ctk.CTkProgressBar(
bottom,
progress_color=ACCENT,
fg_color="#E5E7EB",
height=10,
corner_radius=6,
)
self.progress.set(0.0)
self.progress.grid(
row=0,
column=0,
columnspan=5,
sticky="ew",
padx=(4, 4), # minimal Luft damit der Punkt nicht am Rand klebt
pady=(10, 4),
)
# Status links
self.status_label = ctk.CTkLabel(
bottom,
text="Bereit.",
text_color="#6B7280",
)
self.status_label.grid(
row=1,
column=0,
sticky="w",
padx=(4, 0),
pady=(4, 10),
)
# Branding mittig
self.footer_brand = ctk.CTkLabel(
bottom,
text=BRAND_TEXT,
font=ctk.CTkFont(size=10),
text_color="#6B7280",
cursor="hand2",
)
self.footer_brand.grid(
row=1,
column=1,
sticky="e",
padx=(0, 12),
pady=(4, 10),
)
self.footer_brand.bind("<Button-1>", lambda e: self._open_url(BRAND_URL))
self.footer_brand.bind(
"<Enter>",
lambda e: self.footer_brand.configure(text_color=ACCENT),
)
self.footer_brand.bind(
"<Leave>",
lambda e: self.footer_brand.configure(text_color="#6B7280"),
)
# Buttons rechts
self.btn_readme = ctk.CTkButton(
bottom,
text="Readme",
width=100,
command=lambda: self._open_url(README_URL),
)
self.btn_readme.grid(row=1, column=2, padx=(0, 6), pady=(4, 10))
self.btn_install = ctk.CTkButton(
bottom,
text="Installieren",
width=110,
command=self._on_install_clicked,
)
self.btn_install.grid(row=1, column=3, padx=6, pady=(4, 10))
self.btn_cancel = ctk.CTkButton(
bottom,
text="Abbrechen",
width=110,
fg_color="#E5E7EB",
text_color="#111827",
hover_color="#D1D5DB",
command=self._on_cancel_clicked,
)
self.btn_cancel.grid(row=1, column=4, padx=(0, 4), pady=(4, 10))
# ------------------------------------------------------------------ Helper
def _open_url(self, url: str):
try:
webbrowser.open(url, new=2)
except Exception:
pass
def _load_logo(self):
"""Versucht logo.png zu laden, sonst Text-Fallback."""
if LOGO_PATH.exists():
try:
img = Image.open(LOGO_PATH)
max_width, max_height = 220, 90
img_ratio = img.width / img.height
box_ratio = max_width / max_height
if img_ratio > box_ratio:
new_w = max_width
new_h = int(max_width / img_ratio)
else:
new_h = max_height
new_w = int(max_height * img_ratio)
img = img.resize((new_w, new_h), Image.LANCZOS)
self._logo_img = ctk.CTkImage(
light_image=img,
dark_image=img,
size=(new_w, new_h),
)
self.logo_label.configure(image=self._logo_img, text="")
return
except Exception:
pass
self.logo_label.configure(
text="SD-ITLab",
justify="center",
text_color="#6B7280",
)
def _on_language_changed(self, choice: str):
"""Callback, wenn im Language-Combo etwas gewählt wird."""
code = LANG_MAP.get(choice, "de-de")
self.selected_lang_code.set(code)
# ------------------------------------------------------------------ State/Updates
def _update_year_buttons(self):
for key, btn in self.year_buttons.items():
if self.selected_year.get() == key:
btn.configure(
fg_color="#2563EB",
text_color="white",
hover_color="#1D4ED8",
)
else:
btn.configure(
fg_color="#E5E7EB",
text_color="#111827",
hover_color="#D1D5DB",
)
def _on_year_selected(self, year_key: str):
if self._installing:
return
self.selected_year.set(year_key)
if year_key == "m365":
self.selected_preset.set("m365_single")
elif year_key.endswith("_retail"):
calendar_year = year_key.split("_", 1)[0]
self.selected_preset.set(f"{calendar_year}_home_student")
else:
self.selected_preset.set(f"{year_key}_standard")
self._update_year_buttons()
self._update_edition_cards()
def _update_edition_cards(self):
for card in self.edition_cards:
card.destroy()
self.edition_cards.clear()
version_key = self.selected_year.get()
if version_key == "m365":
presets_for_version = ["m365_single", "m365_family"]
elif version_key.endswith("_retail"):
calendar_year = version_key.split("_", 1)[0]
presets_for_version = [
f"{calendar_year}_home_student",
f"{calendar_year}_business",
f"{calendar_year}_professional",
]
else:
presets_for_version = [
f"{version_key}_standard",
f"{version_key}_professional",
]
descriptions = {
"home_student": "Enthält Word, Excel und PowerPoint – ideal für Privat und Schule.",
"business": "Home & Business: zusätzlich Outlook – ideal für Office-Arbeitsplätze.",
"standard": "Volumenlizenz mit Word, Excel, PowerPoint, Outlook und Publisher.",
"professional": "Professional Plus: inklusive Access und Publisher.",
"single": "Abonnement für eine Person mit Nutzung auf mehreren Geräten.",
"family": "Abonnement für bis zu sechs Personen.",
}
row = 1
for key in presets_for_version:
preset = OFFICE_PRODUCTS[key]
suffix = "home_student" if key.endswith("_home_student") else key.rsplit("_", 1)[1]
card = EditionCard(
self.cards_frame,
title=preset.label,
description=descriptions.get(suffix, ""),
variable=self.selected_preset,
value=key,
)
card.grid(row=row, column=0, padx=4, pady=4, sticky="ew")
self.edition_cards.append(card)
row += 1
# ------------------------------------------------------------------ Installation
def _on_cancel_clicked(self):
if self._installing:
show_message(
"Hinweis",
"Eine Installation läuft bereits. Bitte warte, bis sie abgeschlossen ist.",
icon="info",
)
return
self.destroy()
def _on_install_clicked(self):
if self._installing:
return
preset_key = self.selected_preset.get()
if preset_key not in OFFICE_PRODUCTS:
show_message("Fehler", "Bitte eine Office-Version auswählen.", icon="cancel")
return
if not OFFICE_PS.exists():
show_message(
"Fehlende Datei",
f"PowerShell-Script nicht gefunden:\n{OFFICE_PS}",
icon="cancel",
)
return
self._installing = True