-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.py
More file actions
229 lines (187 loc) · 7.96 KB
/
windows.py
File metadata and controls
229 lines (187 loc) · 7.96 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
import tkinter as tk
from tkinter import ttk
import sys
from modern_widgets import ModernFrame, ModernButton, ModernLabelFrame
class ChecklistWindow:
def __init__(self, parent, title, items):
self.window = tk.Toplevel(parent)
self.window.title(title)
self.window.geometry("800x600")
self.window.resizable(True, True)
# Make window modal
self.window.transient(parent)
self.window.grab_set()
# Create main container
main_frame = ModernFrame(self.window)
main_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
# Title
title_label = ttk.Label(
main_frame,
text=title,
font=('Helvetica', 16, 'bold')
)
title_label.pack(pady=(0, 20))
# Create scrollable frame for checklist
canvas = tk.Canvas(main_frame)
scrollbar = ttk.Scrollbar(main_frame, orient="vertical", command=canvas.yview)
self.scrollable_frame = ModernFrame(canvas)
self.scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
)
canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
# Pack scrollbar and canvas
scrollbar.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand=True)
# Checklist items
self.checklist_items = items
# Create checkboxes for each item
self.checkboxes = []
for item in self.checklist_items:
frame = ttk.Frame(self.scrollable_frame)
frame.pack(fill=tk.X, pady=5)
var = tk.BooleanVar()
checkbox = ttk.Checkbutton(frame, variable=var)
checkbox.pack(side=tk.LEFT, padx=(0, 5))
# Create label for wrapped text
label = ttk.Label(frame, text=item, wraplength=700, justify=tk.LEFT)
label.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.checkboxes.append(var)
# Add completion button
self.complete_btn = ModernButton(
main_frame,
text="Complete Checklist",
command=self.check_completion
)
self.complete_btn.pack(pady=20)
# Status label
self.status_label = ttk.Label(
main_frame,
text="",
font=('Helvetica', 10)
)
self.status_label.pack(pady=10)
# Bind mouse wheel events for scrolling
def _on_mousewheel(event):
canvas.yview_scroll(int(-1*(event.delta/120)), "units")
def _on_linux_mousewheel(event):
canvas.yview_scroll(int(-1*(event.num)), "units")
# Bind for Windows
canvas.bind_all("<MouseWheel>", _on_mousewheel)
# Bind for Linux
canvas.bind_all("<Button-4>", _on_linux_mousewheel)
canvas.bind_all("<Button-5>", _on_linux_mousewheel)
# Unbind when window is closed
def _on_closing():
canvas.unbind_all("<MouseWheel>")
canvas.unbind_all("<Button-4>")
canvas.unbind_all("<Button-5>")
self.window.destroy()
self.window.protocol("WM_DELETE_WINDOW", _on_closing)
# Center window on screen
self.window.update_idletasks()
width = self.window.winfo_width()
height = self.window.winfo_height()
x = (self.window.winfo_screenwidth() // 2) - (width // 2)
y = (self.window.winfo_screenheight() // 2) - (height // 2)
self.window.geometry(f'{width}x{height}+{x}+{y}')
def check_completion(self):
"""Check if all items in the checklist are completed"""
all_checked = all(var.get() for var in self.checkboxes)
if all_checked:
self.status_label.configure(text="All items completed!", foreground="green")
self.complete_btn.configure(state=tk.DISABLED)
else:
self.status_label.configure(text="Please complete all items", foreground="red")
class ScriptViewerWindow:
def __init__(self, parent, title, content):
self.window = tk.Toplevel(parent)
self.window.title(title)
self.window.geometry("800x600")
self.window.resizable(True, True)
# Make window modal
self.window.transient(parent)
self.window.grab_set()
# Create main container
main_frame = ModernFrame(self.window)
main_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
# Create scrollable frame for content
canvas = tk.Canvas(main_frame)
scrollbar = ttk.Scrollbar(main_frame, orient="vertical", command=canvas.yview)
self.scrollable_frame = ModernFrame(canvas)
self.scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
)
canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
# Pack scrollbar and canvas
scrollbar.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand=True)
# Add content with proper formatting
content_label = ttk.Label(
self.scrollable_frame,
text=content,
wraplength=700,
justify=tk.LEFT,
font=('Helvetica', 11)
)
content_label.pack(pady=10)
# Bind mouse wheel events for scrolling
def _on_mousewheel(event):
canvas.yview_scroll(int(-1*(event.delta/120)), "units")
def _on_linux_mousewheel(event):
canvas.yview_scroll(int(-1*(event.num)), "units")
# Bind for Windows
canvas.bind_all("<MouseWheel>", _on_mousewheel)
# Bind for Linux
canvas.bind_all("<Button-4>", _on_linux_mousewheel)
canvas.bind_all("<Button-5>", _on_linux_mousewheel)
# Unbind when window is closed
def _on_closing():
canvas.unbind_all("<MouseWheel>")
canvas.unbind_all("<Button-4>")
canvas.unbind_all("<Button-5>")
self.window.destroy()
self.window.protocol("WM_DELETE_WINDOW", _on_closing)
# Center window on screen
self.window.update_idletasks()
width = self.window.winfo_width()
height = self.window.winfo_height()
x = (self.window.winfo_screenwidth() // 2) - (width // 2)
y = (self.window.winfo_screenheight() // 2) - (height // 2)
self.window.geometry(f'{width}x{height}+{x}+{y}')
class LoadingIndicator:
def __init__(self, parent, message="Loading..."):
self.window = tk.Toplevel(parent)
self.window.title("")
self.window.geometry("300x100")
self.window.resizable(False, False)
self.window.transient(parent)
self.window.grab_set()
# Center window
self.window.update_idletasks()
width = self.window.winfo_width()
height = self.window.winfo_height()
x = (self.window.winfo_screenwidth() // 2) - (width // 2)
y = (self.window.winfo_screenheight() // 2) - (height // 2)
self.window.geometry(f'{width}x{height}+{x}+{y}')
# Create frame
frame = ttk.Frame(self.window)
frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
# Add message
ttk.Label(
frame,
text=message,
font=('Helvetica', 10)
).pack(pady=(0, 10))
# Add progress bar
self.progress = ttk.Progressbar(
frame,
mode='indeterminate'
)
self.progress.pack(fill=tk.X)
self.progress.start()
def destroy(self):
self.window.destroy()