-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_message_box.py
56 lines (40 loc) · 1.33 KB
/
custom_message_box.py
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
import customtkinter as ctk
is_active = False
def custom_messagebox_panel(parent, message, show_cancel = False):
global is_active
if is_active:
return
is_active = True
can_close = False
result = None
panel = ctk.CTkFrame(parent, fg_color="darkgray", corner_radius=0, height=150)
panel.pack(fill="x", side="top")
message_label = ctk.CTkLabel(panel, text=message, font=("Arial", 14), text_color="white")
message_label.pack(pady=(10, 0))
def on_ok():
nonlocal can_close
nonlocal result
result = True
panel.pack_forget()
can_close = True
def on_cancel():
nonlocal result
nonlocal can_close
result = False
panel.pack_forget()
can_close = True
button_frame = ctk.CTkFrame(panel, fg_color="transparent")
button_frame.pack(pady=(10, 10))
ok_button = ctk.CTkButton(button_frame, text="OK", command=on_ok)
ok_button.grid(row=0, column=0, padx=10)
if show_cancel:
cancel_button = ctk.CTkButton(button_frame, text="Cancel", command=on_cancel)
cancel_button.grid(row=0, column=1, padx=10)
parent.grab_set()
while not can_close:
parent.update_idletasks()
parent.after(100)
parent.update()
parent.grab_release()
is_active = False
return result