-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
849 lines (692 loc) · 33.8 KB
/
Copy pathmain.py
File metadata and controls
849 lines (692 loc) · 33.8 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
import os
import sys
import time
from PIL import Image as pillowImage
from PIL import ImageTk as pillowImageTk
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import sv_ttk #tk theme: https://github.com/rdbende/Sun-Valley-ttk-theme/tree/main
APP_TITLE = "Geo-Scatter Installer"
APP_SIZE = "720x880" # Increased height to accommodate 700px header images + content
def get_assets_dir():
"""Get the assets directory, handling both development and bundled execution"""
try: base_path = sys._MEIPASS # PyInstaller creates a temp folder and stores path in _MEIPASS
except AttributeError:
base_path = os.path.dirname(os.path.abspath(__file__)) # Running in development
return os.path.join(base_path, 'assets')
ASSETS_DIR = get_assets_dir()
ICON_PATH = os.path.join(ASSETS_DIR, 'app.ico')
def set_window_icon(window):
"""Set the window icon if available"""
if os.path.exists(ICON_PATH):
try: window.iconbitmap(ICON_PATH)
except Exception as e:
print(f"[ERROR]: set_window_icon(): Could not set window icon: {e}")
else: print(f"[ERROR]: set_window_icon(): Icon file not found '{ICON_PATH}'")
return None
def pop_warning_near_mouse(parent, title="Warning", message="Oh no!", geometry="320x220"):
"""Show a custom warning dialog near the mouse cursor"""
# Get mouse position first
x = parent.winfo_pointerx()
y = parent.winfo_pointery()
x -= 150 # Center the dialog better
y -= 150
# Create dialog but hide it initially
dialog = tk.Toplevel(parent)
dialog.withdraw() # Hide the window initially
dialog.title(title)
dialog.resizable(False, False)
dialog.configure(bg="#1c1c1c")
sv_ttk.set_theme("dark") # Apply theme
set_window_icon(dialog)
# Content frame
content = tk.Frame(dialog, bg="#1c1c1c")
content.pack(fill="both", expand=True, padx=10, pady=10)
# Icon + Message
tk.Label(content, text="⚠️", font=("Segoe UI", 20), bg="#1c1c1c", fg="orange").pack(pady=(0, 10))
tk.Label(content, text=message, font=("Segoe UI", 10), bg="#1c1c1c", fg="white",
wraplength=300, justify="left").pack(pady=(0, 20))
# OK button
ttk.Button(content, text="OK", command=dialog.destroy, takefocus=0).pack()
# Force the dialog to calculate its size and set fixed geometry
dialog.update_idletasks() # Force geometry calculation
dialog.geometry(f"{geometry}+{x}+{y}") # Fixed size + position
# Make modal and show
dialog.transient(parent)
dialog.grab_set()
dialog.deiconify() # Show the window at the correct position and size
parent.wait_window(dialog)
return None
def pop_confirmation_dialog(parent, title="Confirm", message="Are you sure?", confirm_text="Yes", cancel_text="No", geometry="320x240"):
"""Show a confirmation dialog with Yes/No buttons"""
# Get mouse position for dialog placement
x = parent.winfo_pointerx()
y = parent.winfo_pointery()
x -= 100 # Center the dialog better
y -= 50
# Create dialog but hide it initially
dialog = tk.Toplevel(parent)
dialog.withdraw()
dialog.title(title)
dialog.resizable(False, False)
dialog.configure(bg="#1c1c1c")
sv_ttk.set_theme("dark") # Apply theme
set_window_icon(dialog)
# Content frame
content = tk.Frame(dialog, bg="#1c1c1c")
content.pack(fill="both", expand=True, padx=20, pady=20)
# Icon + Message
tk.Label(content, text="❓", font=("Segoe UI", 24), bg="#1c1c1c", fg="orange").pack(pady=(0, 10))
tk.Label(content, text=message, font=("Segoe UI", 11), bg="#1c1c1c", fg="white", wraplength=300, justify="center").pack(pady=(0, 20))
# Button frame
button_frame = tk.Frame(content, bg="#1c1c1c")
button_frame.pack()
# Result variable
result = tk.BooleanVar(value=False)
def on_confirm():
result.set(True)
dialog.destroy()
return None
def on_cancel():
result.set(False)
dialog.destroy()
return None
# Buttons
ttk.Button(button_frame, text=cancel_text, command=on_cancel, takefocus=0).pack(side="left", padx=(0, 10))
ttk.Button(button_frame, text=confirm_text, command=on_confirm, takefocus=0).pack(side="left")
# Force the dialog to calculate its size and set fixed geometry
dialog.update_idletasks() # Force geometry calculation
dialog.geometry(f"{geometry}+{x}+{y}") # Fixed size + position
# Make modal and show
dialog.transient(parent)
dialog.grab_set()
dialog.deiconify() # Show the window at the correct position and size
parent.wait_window(dialog)
return result.get()
def pop_success_message(parent, title="Success!", message="Operation completed successfully.", geometry="320x200"):
"""Show a success dialog with green checkmark"""
# Get mouse position first
x = parent.winfo_pointerx()
y = parent.winfo_pointery()
x -= 150 # Center the dialog better
y -= 150
# Create dialog but hide it initially
dialog = tk.Toplevel(parent)
dialog.withdraw() # Hide the window initially
dialog.title(title)
dialog.resizable(False, False)
dialog.configure(bg="#1c1c1c")
sv_ttk.set_theme("dark") # Apply theme
set_window_icon(dialog)
# Content frame
content = tk.Frame(dialog, bg="#1c1c1c")
content.pack(fill="both", expand=True, padx=10, pady=10)
# Icon + Message
tk.Label(content, text="✅", font=("Segoe UI", 20), bg="#1c1c1c", fg="green").pack(pady=(0, 10))
tk.Label(content, text=message, font=("Segoe UI", 10), bg="#1c1c1c", fg="white",
wraplength=300, justify="left").pack(pady=(0, 20))
# OK button
ttk.Button(content, text="OK", command=dialog.destroy, takefocus=0).pack()
# Force the dialog to calculate its size and set fixed geometry
dialog.update_idletasks() # Force geometry calculation
dialog.geometry(f"{geometry}+{x}+{y}") # Fixed size + position
# Make modal and show
dialog.transient(parent)
dialog.grab_set()
dialog.deiconify() # Show the window at the correct position and size
parent.wait_window(dialog)
return None
IMAGECACHE = {}
def load_header_image(page_number):
"""Load header image for the specified page number"""
image_key = f"page{page_number}"
if (image_key in IMAGECACHE):
return IMAGECACHE[image_key]
image_path = os.path.join(ASSETS_DIR, f'header_{image_key}.jpg')
if os.path.exists(image_path):
try:
image = pillowImage.open(image_path) # Load and resize image to fit window width (720px) while maintaining aspect ratio
aspect_ratio = image.height / image.width # Calculate new height to maintain aspect ratio for 720px width
new_height = int(720 * aspect_ratio)
image = image.resize((720, new_height), pillowImage.LANCZOS)
photo = pillowImageTk.PhotoImage(image)
IMAGECACHE[image_key] = photo
return photo
except Exception as e:
print(f"[WARNING]: Could not load header image for {image_key}: {e}")
return None
else:
print(f"[WARNING]: Header image not found: {image_path}")
return None
# oooooooooo.
# `888' `Y8b
# 888 888 .oooo. .oooo.o .ooooo.
# 888oooo888' `P )88b d88( "8 d88' `88b
# 888 `88b .oP"888 `"Y88b. 888ooo888
# 888 .88P d8( 888 o. )88b 888 .o
# o888bood8P' `Y888""8o 8""888P' `Y8bod8P'
USERSTORAGE = {} # Global storage for user data across all pages
class Wizard(tk.Tk):
def __init__(self):
super().__init__()
self.title(APP_TITLE)
self.geometry(APP_SIZE)
self.resizable(False, False)
sv_ttk.set_theme("dark") # Set modern Sun Valley theme
set_window_icon(self)
# Set window close protocol
self.protocol("WM_DELETE_WINDOW", self.premature_window_close_callback)
# Container for pages
self.container = tk.Frame(self)
self.container.pack(fill="both", expand=True)
# Footer bar with darker background
self.footer = tk.Frame(self, height=52, bg="#141414")
self.footer.pack(fill="x", side="bottom")
# Prev button
self.prev_btn = ttk.Button(self.footer, text="Previous", command=self.prev_page, takefocus=0)
self.prev_btn.pack(side="left", padx=10, pady=10)
# Page indicator centered
self.page_indicator = tk.Label(self.footer, text="Page 1", bg="#141414", fg="#888888", font=("Segoe UI", 9))
self.page_indicator.place(relx=0.5, rely=0.5, anchor="center")
# Next button
self.next_btn = ttk.Button(self.footer, text="Next", command=self.next_page, takefocus=0)
self.next_btn.pack(side="right", padx=10, pady=10)
# Build pages
self.pages = []
self.page_active_idx = 0
self.pages.append(Page1(self.container, self.refresh_page,))
self.pages.append(Page2(self.container, self.refresh_page,))
self.pages.append(Page3(self.container, self.refresh_page,))
self.pages.append(Page4(self.container, self.refresh_page,))
# Set wizard reference for each classes
for p in self.pages:
p.wizard = self
p.place(relx=0, rely=0, relwidth=1, relheight=1)
# Define greyed out button style
style = ttk.Style()
style.configure('Transparent.TButton', foreground='#666666')
self.update_page(0)
# Navigation helpers
def update_page(self, idx: int):
# Safety check - don't update if pages aren't initialized yet
if ((not self.pages) or (idx >= len(self.pages))):
return None
self.page_active_idx = idx
current_page = self.pages[idx]
for i, p in enumerate(self.pages):
p.tkraise() if i == idx else None
# Update page indicator with custom text
self.page_indicator.config(text=current_page.footer_text)
# Update button labels
self.prev_btn.config(text=current_page.prev_button_name)
self.next_btn.config(text=current_page.next_button_name)
# Update button commands to call page-specific callbacks
self.prev_btn.config(command=current_page.prev_button_callback)
self.next_btn.config(command=current_page.next_button_callback)
# Update button states enabled/disabled
can_prev = current_page.prev_button_enabled() if hasattr(current_page, 'prev_button_enabled') else True
self.prev_btn.config(state=("normal" if can_prev else "disabled"))
can_next = current_page.next_button_enabled() if hasattr(current_page, 'next_button_enabled') else True
self.next_btn.config(state=("normal" if can_next else "disabled"))
# Apply greyed out style if page wants transparency effect
is_prev_greyedout = current_page.prev_button_greyedout() if hasattr(current_page, 'prev_button_greyedout') else False
self.prev_btn.configure(style='Transparent.TButton' if is_prev_greyedout else 'TButton')
is_next_greyedout = current_page.next_button_greyedout() if hasattr(current_page, 'next_button_greyedout') else False
self.next_btn.configure(style='Transparent.TButton' if is_next_greyedout else 'TButton')
return None
def refresh_page(self):
"""Called by pages when their state changes - just refresh current page"""
self.update_page(self.page_active_idx)
return None
def prev_page(self):
if (self.page_active_idx > 0):
self.update_page(self.page_active_idx - 1)
return None
def next_page(self):
if (self.page_active_idx < len(self.pages) - 1):
self.update_page(self.page_active_idx + 1)
return None
def premature_window_close_callback(self):
"""Called when user closes the window (clicks X button)"""
# Ask for confirmation before closing
confirmed = pop_confirmation_dialog(self,
message="Are you sure you want to cancel the installation?\n\nAll progress will be lost.",
confirm_text="Yes, Exit",
cancel_text="Continue Installation",
geometry="320x240",
)
if confirmed:
print("[INFO] User confirmed exit - closing installer window")
print("[INFO] Installation was cancelled")
self.destroy()
else:
print("[INFO] User cancelled exit - continuing installation")
return None
class PageBase(tk.Frame):
page_number = -1
title_text = "*CHILDREN DEFINED*"
footer_text = "*CHILDREN DEFINED*"
prev_button_name = "Previous"
next_button_name = "Next"
# def prev_button_callback/next_button_callback(self)->None:
# """*CHILDREN DEFINED*: Called when Previous button is clicked on this page"""
# self.wizard.prev_page/next_page()
# return None
# def prev_button_enabled/next_button_enabled(self)->bool:
# """*CHILDREN DEFINED*: Override in subclasses to control Next button state"""
# return True
# def prev_button_greyedout/next_button_greyedout(self)->bool:
# """*CHILDREN DEFINED*: Override to make Next button semi-transparent, like enabled==False but user can click it"""
# return False # Return True to make button transparent when disabled
def __init__(self, parent, refresh_ui):
super().__init__(parent) # Let Sun Valley theme handle background
self.refresh_ui = refresh_ui
self.wizard = None # Will be set by Wizard class
# Load and display header image
header_image = load_header_image(self.page_number)
if (header_image is not None):
self.imageheader = tk.Label(self, image=header_image, borderwidth=0, highlightthickness=0)
self.imageheader.image = header_image # Keep reference to prevent garbage collection
self.imageheader.pack(anchor="nw", padx=0, pady=0, fill="x")
# Title text (only if no image or as fallback)
self.header = tk.Label(self, text=self.title_text, font=("Segoe UI", 16, "bold"))
self.header.pack(anchor="w", padx=16, pady=(16, 8))
# Separator line below title
ttk.Separator(self, orient="horizontal").pack(fill="x", padx=16, pady=(0, 0))
# Spacer below separator
tk.Frame(self, height=16).pack()
# Define main layout area
self.layout = tk.Frame(self)
self.layout.pack(fill="both", expand=True, padx=16, pady=(0, 12))
#... children defined init..
# ooooooooo. .o
# `888 `Y88. o888
# 888 .d88' .oooo. .oooooooo .ooooo. 888
# 888ooo88P' `P )88b 888' `88b d88' `88b 888
# 888 .oP"888 888 888 888ooo888 888
# 888 d8( 888 `88bod8P' 888 .o 888
# o888o `Y888""8o `8oooooo. `Y8bod8P' o888o
# d" YD
# "Y88888P'
class Page1(PageBase):
page_number = 1
title_text = "License Agreement"
footer_text = f"Page {page_number}"
prev_button_name = "Cancel"
def prev_button_callback(self) -> None:
self.wizard.destroy()
return None
def next_button_callback(self) -> None:
# Check if license accepted, otherwise show warning
match USERSTORAGE["license1_accepted"]:
case False:
pop_warning_near_mouse(self.wizard,
title="Cannot continue",
message="To continue the installation, agreeing with the license is required. The accept button will be available once you scroll to the end of the license text.",
geometry="320x205",
)
case True:
self.wizard.next_page()
return None
def next_button_greyedout(self) -> bool:
return USERSTORAGE["license1_accepted"]==False # Make button semi-transparent when license not accepted, user can click it, will show warning
def __init__(self, parent, refresh_ui):
super().__init__(parent, refresh_ui)
layout = self.layout
# Initialize state if needed
if ("license1_scrolled_to_end" not in USERSTORAGE):
USERSTORAGE.update({
"license1_scrolled_to_end": False,
"license1_accepted": False,
})
# Scrollable long license text
wrapper = tk.Frame(layout, height=200)
wrapper.pack(fill="x")
self.scroll = ttk.Scrollbar(wrapper)
self.scroll.pack(side="right", fill="y")
self.text = tk.Text(wrapper, wrap="word", yscrollcommand=self.scroll.set, height=26, background="#141414", borderwidth=0, highlightthickness=0)
self.text.pack(side="left", fill="both", expand=True, padx=(0, 8),)
self.scroll.config(command=self.text.yview)
# Populate large license text
lines = []
for i in range(1, 201): # 200 lines of license text
lines.append(f"License Agreement Line {i}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
f"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
f"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
f"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n")
self.text.insert("1.0", "".join(lines))
self.text.config(state="disabled")
# Accept toggle (disabled until scrolled to end)
self.accept_var = tk.BooleanVar(value=USERSTORAGE["license1_accepted"])
def on_toggle():
USERSTORAGE["license1_accepted"] = self.accept_var.get()
self.refresh_ui()
return None
self.accept_check = ttk.Checkbutton(layout, text="I accept the license agreement",
variable=self.accept_var, command=on_toggle, state="disabled", takefocus=0)
self.accept_check.pack(anchor="w", pady=(8, 0))
# Hint
tk.Label(layout, text="*Read the license first before accepting it. This button will be available once you scroll to the end of the license text.").pack(anchor="w", pady=(4, 0))
# Track scroll position; enable checkbox only at end
self.bind_scroll_checks()
self.check_scroll()
def bind_scroll_checks(self):
# Bind events to the text widget
for seq in ("<MouseWheel>", "<Button-4>", "<Button-5>", "<KeyRelease>", "<ButtonRelease-1>", "<Configure>"):
self.text.bind(seq, lambda e: self.after(50, self.check_scroll))
# Bind events to the scrollbar widget - check scroll state after interaction
def on_scrollbar_release(event):
self.after(50, self.check_scroll)
return None
self.scroll.bind("<ButtonRelease-1>", on_scrollbar_release)
return None
def check_scroll(self):
# yview returns (first, last) fractions of the document visible
first, last = self.text.yview()
at_end = abs(last - 1.0) < 1e-3 # near bottom
USERSTORAGE["license1_scrolled_to_end"] = at_end
if at_end:
self.accept_check.config(state="normal")
else:
self.accept_check.config(state="disabled")
self.accept_var.set(False) # Reset acceptance if scrolled back up
USERSTORAGE["license1_accepted"] = False
self.refresh_ui()
return None
# ooooooooo. .oooo.
# `888 `Y88. .dP""Y88b
# 888 .d88' .oooo. .oooooooo .ooooo. ]8P'
# 888ooo88P' `P )88b 888' `88b d88' `88b .d8P'
# 888 .oP"888 888 888 888ooo888 .dP'
# 888 d8( 888 `88bod8P' 888 .o .oP .o
# o888o `Y888""8o `8oooooo. `Y8bod8P' 8888888888
# d" YD
# "Y88888P'
class Page2(PageBase):
page_number = 2
title_text = "Install Options"
footer_text = f"Page {page_number}"
def prev_button_callback(self) -> None:
self.wizard.prev_page()
return None
def next_button_callback(self) -> None:
print("[CONFIG] Desktop shortcut:", USERSTORAGE['bool_option1'])
print(f"[CONFIG] Installation Type: {USERSTORAGE['enum_choice']}")
print(f"[CONFIG] Memory Allocation: {USERSTORAGE['float_value']:.1f} GB")
print(f"[CONFIG] Thread Count: {USERSTORAGE['int_value']}")
self.wizard.next_page()
return None
def __init__(self, parent, refresh_ui):
super().__init__(parent, refresh_ui)
layout = self.layout
# Initialize state if needed
if ("bool_option1" not in USERSTORAGE):
USERSTORAGE.update({
"bool_option1": True,
"enum_choice": "Standard",
"float_value": 50.0,
"int_value": 10,
})
# Panel 1: Boolean Checkbox
ttk.Label(layout, text="Installation Options:", font=("Segoe UI", 11, "bold")).pack(anchor="w", pady=(0, 8))
bool_frame = tk.Frame(layout)
bool_frame.pack(anchor="w", fill="x", pady=(0, 16))
self.bool1_var = tk.BooleanVar(value=USERSTORAGE["bool_option1"])
ttk.Checkbutton(bool_frame, text="Create desktop shortcut", variable=self.bool1_var,
command=lambda: self.update_bool("bool_option1", self.bool1_var), takefocus=0).pack(anchor="w", pady=1)
ttk.Separator(layout, orient="horizontal").pack(fill="x", pady=8)
# Panel 2: Enum Radio Buttons
ttk.Label(layout, text="Installation Type:", font=("Segoe UI", 11, "bold")).pack(anchor="w", pady=(0, 8))
self.enum_var = tk.StringVar(value=USERSTORAGE["enum_choice"])
enum_frame = tk.Frame(layout)
enum_frame.pack(anchor="w", pady=(0, 16))
for option in ["Standard", "Complete", "Custom"]:
ttk.Radiobutton(enum_frame, text=option, variable=self.enum_var,
value=option, takefocus=0,
command=lambda: self.update_enum()).pack(anchor="w", pady=1)
ttk.Separator(layout, orient="horizontal").pack(fill="x", pady=8)
# Panel 3: Sliders
ttk.Label(layout, text="Advanced Settings:", font=("Segoe UI", 11, "bold")).pack(anchor="w", pady=(0, 8))
# Float slider
float_frame = tk.Frame(layout)
float_frame.pack(anchor="w", fill="x", pady=(8, 0))
ttk.Label(float_frame, text="Memory Allocation (GB):").pack(anchor="w")
float_slider_frame = tk.Frame(float_frame)
float_slider_frame.pack(anchor="w", fill="x", pady=(4, 0))
self.float_var = tk.DoubleVar(value=USERSTORAGE["float_value"])
self.float_slider = ttk.Scale(float_slider_frame, from_=0, to=100, variable=self.float_var,
orient="horizontal", command=lambda v: self.update_float())
self.float_slider.pack(side="left", fill="x", expand=True, padx=(0, 10))
self.float_label = tk.Label(float_slider_frame, text=f"{USERSTORAGE['float_value']:.1f} GB", width=8)
self.float_label.pack(side="right")
# Int slider
int_frame = tk.Frame(layout)
int_frame.pack(anchor="w", fill="x", pady=(0, 0))
ttk.Label(int_frame, text="Thread Count:").pack(anchor="w")
int_slider_frame = tk.Frame(int_frame)
int_slider_frame.pack(anchor="w", fill="x", pady=(0, 0))
self.int_var = tk.IntVar(value=USERSTORAGE["int_value"])
self.int_slider = ttk.Scale(int_slider_frame, from_=1, to=32, variable=self.int_var,
orient="horizontal", command=lambda v: self.update_int())
self.int_slider.pack(side="left", fill="x", expand=True, padx=(0, 10))
self.int_label = tk.Label(int_slider_frame, text=f"{USERSTORAGE['int_value']}", width=8)
self.int_label.pack(side="right")
# Note
tk.Label(layout, text="Click Next to save configuration and continue.").pack(anchor="w", pady=(12, 0))
def update_bool(self, key, var):
USERSTORAGE[key] = var.get()
return None
def update_enum(self):
USERSTORAGE["enum_choice"] = self.enum_var.get()
return None
def update_float(self):
val = self.float_var.get()
USERSTORAGE["float_value"] = val
self.float_label.config(text=f"{val:.1f} GB")
return None
def update_int(self):
val = int(self.int_var.get())
USERSTORAGE["int_value"] = val
self.int_label.config(text=f"{val}")
return None
# ooooooooo. .oooo.
# `888 `Y88. .dP""Y88b
# 888 .d88' .oooo. .oooooooo .ooooo. ]8P'
# 888ooo88P' `P )88b 888' `88b d88' `88b <88b.
# 888 .oP"888 888 888 888ooo888 `88b.
# 888 d8( 888 `88bod8P' 888 .o o. .88P
# o888o `Y888""8o `8oooooo. `Y8bod8P' `8bd88P'
# d" YD
# "Y88888P'
class Page3(PageBase):
page_number = 3
title_text = "Loadbar Test"
footer_text = f"Page {page_number}"
def prev_button_callback(self) -> None:
self.wizard.prev_page()
return None
def next_button_callback(self) -> None:
match self.loadbar_complete:
case False:
pop_warning_near_mouse(self.wizard,
title="Cannot continue",
message="Loadbar has to be completed before continuing.",
geometry="320x155",
)
case True:
self.wizard.next_page()
return None
def next_button_greyedout(self) -> bool:
return (self.loadbar_complete==False)
def __init__(self, parent, refresh_ui):
super().__init__(parent, refresh_ui)
layout = self.layout
# Initialize loading state
self.loadbar_complete = False
self.loadbar_progress = 0
self.loadbar_loading = False
# Initialize state if needed
if ("loadbar_progress" not in USERSTORAGE):
USERSTORAGE.update({
"loadbar_progress": 0,
"loadbar_complete": False,
})
# Title and description
tk.Label(layout, text="This page demonstrates a fake loading process with a progress bar.\nClick the button below to start the loading simulation.").pack(anchor="w", pady=(0, 20))
# Progress bar and button container
progress_frame = tk.Frame(layout)
progress_frame.pack(fill="x", pady=(20, 0))
# Progress bar (left side)
self.progress_var = tk.DoubleVar(value=USERSTORAGE["loadbar_progress"])
self.progress_bar = ttk.Progressbar(progress_frame, variable=self.progress_var, maximum=100, mode='determinate')
self.progress_bar.pack(side="left", fill="x", expand=True, pady=(0, 1))
# Start button (right side)
self.start_button = ttk.Button(progress_frame, text="Start", command=self.start_loadbar, takefocus=0)
self.start_button.pack(side="right", padx=(10, 0))
# Status label (full width below progress bar)
self.status_label = tk.Label(layout, text="Ready to start loading", font=("Segoe UI", 10), fg="#888888")
self.status_label.pack(anchor="w", pady=(0, 0))
def start_loadbar(self):
if (self.loadbar_loading==True):
return None
self.loadbar_loading = True
self.start_button.config(state="disabled", text="Loading")
self.loadbar_progress = 0
self.progress_var.set(0)
self.status_label.config(text="Initializing loading...", fg="#ffffff")
self.loadbar_complete = False
self.refresh_ui()
self.update_progress()
return None
def update_progress(self):
if (self.loadbar_loading==False):
return None
self.loadbar_progress += 1
self.progress_var.set(self.loadbar_progress)
USERSTORAGE["loadbar_progress"] = self.loadbar_progress
# Update status messages based on progress
match self.loadbar_progress:
case v if (v >= 100):
self.status_label.config(text="Loading complete!", fg="#00ff00")
self.loadbar_complete = True
self.loadbar_loading = False
self.start_button.config(state="normal", text="Done")
USERSTORAGE["loadbar_complete"] = True
self.refresh_ui()
return
case 70:
self.status_label.config(text="Finalizing installation...", fg="#ffffff")
case 50:
self.status_label.config(text="Configuring settings...", fg="#ffffff")
case 30:
self.status_label.config(text="Installing dependencies...", fg="#ffffff")
case 20:
self.status_label.config(text="Loading core files...", fg="#ffffff")
# Schedule next update
self.after(40, self.update_progress)
return None
# ooooooooo. .o
# `888 `Y88. .d88
# 888 .d88' .oooo. .oooooooo .ooooo. .d'888
# 888ooo88P' `P )88b 888' `88b d88' `88b .d' 888
# 888 .oP"888 888 888 888ooo888 88ooo888oo
# 888 d8( 888 `88bod8P' 888 .o 888
# o888o `Y888""8o `8oooooo. `Y8bod8P' o888o
# d" YD
# "Y88888P'
class Page4(PageBase):
page_number = 4
title_text = "Define Install Directory"
footer_text = f"Page {page_number}"
next_button_name = "Finish"
def prev_button_callback(self) -> None:
self.wizard.prev_page()
return None
def next_button_greyedout(self) -> bool:
return (self.path_var_valid==False)
def next_button_callback(self) -> None:
match self.path_var_valid:
case False:
pop_warning_near_mouse(self.wizard,
title="Cannot continue",
message="The install directory is not a directory. Please select a valid directory, and not a file.",
geometry="320x180",
)
case True:
pop_success_message(self.wizard,
title="Installation Complete!",
message="Your application has been successfully installed!\n\nThe installation process is now complete.\nThanks!",
geometry="320x220",
)
self.wizard.destroy()
return None
def __init__(self, parent, refresh_ui):
super().__init__(parent, refresh_ui)
layout = self.layout
# Initialize state if needed
if ("install_dir" not in USERSTORAGE):
USERSTORAGE.update({
"install_dir": "",
})
# Field + validation color
path_row = tk.Frame(layout)
path_row.pack(fill="x", pady=(6, 4))
ttk.Label(path_row, text="Install directory:").pack(side="left", padx=(0, 8))
self.path_var = tk.StringVar(value=USERSTORAGE["install_dir"],)
self.path_var_stripped = self.path_var.get().strip()
self.path_var_valid = False
self.entry = tk.Entry(path_row, textvariable=self.path_var, width=60, takefocus=0, background="#141414", borderwidth=0, highlightthickness=0)
self.entry.pack(side="left", fill="x", expand=True, ipady=6)
self.entry.bind("<KeyRelease>", lambda e: self.sync_and_validate())
def pick_dir():
d = filedialog.askdirectory(title="Select installation directory")
self.path_var.set(d)
self.sync_and_validate()
return None
ttk.Button(path_row, text="Browse...", command=pick_dir, takefocus=0).pack(side="left", padx=8)
# Operator button: append F:/This/Path
def append_magic():
self.path_var.set(self.path_var.get() + (" " if self.path_var.get() else "") + "F:/This/Path")
self.sync_and_validate()
return None
ttk.Button(layout, text="Append F:/This/Path", command=append_magic, takefocus=0).pack(anchor="w", pady=8)
self.refresh_ui()
def sync_and_validate(self):
self.path_var_stripped = self.path_var.get().strip()
self.path_var_valid = os.path.isdir(self.path_var_stripped)
USERSTORAGE["install_dir"] = self.path_var_stripped
self.entry.config(bg=("#141414" if self.path_var_valid else "#600000"))
self.refresh_ui()
return None
if __name__ == "__main__":
print('Launching the program...')
# Initialize the main app (this takes time)
app = Wizard()
# Hide PyInstaller splash screen if it exists
try:
import pyi_splash
# Close splash immediately when app is ready
pyi_splash.close()
print("[SPLASH] PyInstaller splash screen closed successfully")
except ImportError:
# PyInstaller splash not available, that's fine
print("[SPLASH] PyInstaller splash screen not available (not using --splash)")
except Exception as e:
print(f"[SPLASH] Error closing splash screen: {e}")
# Try to force close it
try:
import pyi_splash
# Try multiple close attempts
for _ in range(3):
try:
pyi_splash.close()
break
except:
import time
time.sleep(0.1)
print("[SPLASH] Forced splash close attempted")
except:
print("[SPLASH] All splash close methods failed")
print("[APP] Starting main application...")
app.mainloop()