-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
493 lines (419 loc) · 23.2 KB
/
gui.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
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
import os
import platform
import subprocess
import sys
import webbrowser
import wx.adv
import wx.lib.buttons as buttons
from wx.lib.delayedresult import startWorker
from compress_logic import run_compression
from compress_logic import request_stop as logic_request_stop
from helpers import count_files_in_source, count_files_in_destination, log_to_console, collect_multi_frame_tiff_groups
COMPRESSION_OPTIONS = [
'Compress with Quality Retention',
'Compress Size x2',
'Compress Size x4',
'Compress Size x8',
'Compress Size x16',
]
class CompressorApp(wx.Frame):
def __init__(self, parent, title):
super(CompressorApp, self).__init__(parent, title=title, size=(1600, 800))
# Initialize the attributes
self.last_frame_size = (0, 0) # Initialize with a dummy value
self.bmp = None
self.last_size = (0, 0) # Initialize with a dummy value
self.source_directory = None
self.destination_directory = None
self.panel = wx.Panel(self)
self.last_github_click_time = 0
self.stop_requested = False
self.instance_of_app = self
self.should_merge = False
# Determine if we're running as a bundled executable
base_path = os.path.dirname(os.path.abspath(__file__))
# Load the icon windows
if platform.system() == "Windows":
self.icon = wx.Icon()
icon_path = os.path.join(base_path, "img", "icon.ico")
self.icon.CopyFromBitmap(wx.Bitmap(icon_path, wx.BITMAP_TYPE_ANY))
self.SetIcon(self.icon)
# Load the image
self.image_file = os.path.join(base_path, 'img', 'background2.png')
self.image = wx.Image(self.image_file, wx.BITMAP_TYPE_ANY)
# Bind the EVT_PAINT event of the panel to the on_paint method
self.panel.Bind(wx.EVT_PAINT, self.on_paint)
# Add buttons to the panel
# Select Source Directory button
self.btn_source = buttons.GenButton(self.panel, label='📁 Source Directory ', pos=(50, 150))
self.btn_source.SetBackgroundColour('navy')
self.btn_source.SetForegroundColour('white')
self.btn_source.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
# Select Destination Directory Button
self.btn_dest = buttons.GenButton(self.panel, label='📁 Destination Directory ', pos=(50, 200))
self.btn_dest.SetBackgroundColour('navy')
self.btn_dest.SetForegroundColour('white')
self.btn_dest.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
self.btn_start = buttons.GenButton(self.panel, label='▶️ Start Compression', pos=(500, 360))
self.btn_start.SetBackgroundColour('navy')
self.btn_start.SetForegroundColour('white')
self.btn_start.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
self.stop_button = buttons.GenButton(self.panel, label='⏹️ Stop Compression', pos=(650, 360))
self.stop_button.SetBackgroundColour('navy')
self.stop_button.SetForegroundColour('white')
self.stop_button.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
self.stop_button.Disable()
# Add a TextCtrl for console output
self.console_output = wx.TextCtrl(self.panel, size=(0, 150),
style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH)
monospaced_font = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.console_output.SetBackgroundColour(wx.BLACK)
self.console_output.SetForegroundColour(wx.WHITE)
self.console_output.SetFont(monospaced_font)
# Redirect stdout and stderr to the TextCtrl widget
sys.stdout = self.TextRedirector(self.console_output)
sys.stderr = self.TextRedirector(self.console_output)
# Bind the buttons to their respective event handlers
self.Bind(wx.EVT_BUTTON, self.on_select_source, self.btn_source)
self.Bind(wx.EVT_BUTTON, self.on_select_destination, self.btn_dest)
self.Bind(wx.EVT_BUTTON, self.on_start_compression, self.btn_start)
self.Bind(wx.EVT_BUTTON, self.request_stop, self.stop_button)
# Bind the resize event to the update background function
self.Bind(wx.EVT_SIZE, self.on_resize)
# Create a BoxSizer for vertical layout
main_sizer = wx.BoxSizer(wx.VERTICAL)
# Buttons
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
button_sizer.Add(self.btn_source, 0, wx.CENTER | wx.ALL, 10)
button_sizer.Add(self.btn_dest, 0, wx.CENTER | wx.ALL, 10)
# Add a Choice widget for compression options
self.compression_choice = wx.Choice(self.panel, choices=COMPRESSION_OPTIONS)
self.compression_choice.SetBackgroundColour(wx.Colour('navy'))
self.compression_choice.SetForegroundColour(wx.Colour('white'))
self.compression_choice.SetSelection(0) # Set default selection to the first option
font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
self.compression_choice.SetFont(font)
# Sizer for the compression choice widget
choice_sizer = wx.BoxSizer(wx.HORIZONTAL)
choice_label = wx.StaticText(self.panel)
choice_sizer.Add(choice_label, 0, wx.CENTER | wx.ALL, 5)
choice_sizer.Add(self.compression_choice, 1, wx.EXPAND | wx.ALL, 5)
main_sizer.Add(button_sizer, 0, wx.CENTER)
main_sizer.Add(choice_sizer, 0, wx.CENTER)
# Console output
console_sizer = wx.BoxSizer(wx.VERTICAL)
console_sizer.Add(self.console_output, 1, wx.ALL | wx.EXPAND | wx.LEFT | wx.RIGHT, 20)
main_sizer.Add(console_sizer, 1, flag=wx.ALL | wx.EXPAND, border=0)
# Start button
button_sizer_start_stop = wx.BoxSizer(wx.HORIZONTAL)
button_sizer_start_stop.Add(self.btn_start, 0, wx.ALL, 10)
button_sizer_start_stop.Add(self.stop_button, 0, wx.ALL, 10)
main_sizer.Add(button_sizer_start_stop, 0, wx.CENTER)
# Create a checkbox for merging channels (initially hidden)
self.merge_checkbox = wx.CheckBox(self.panel, label="Detected channels: Group into multi-frame images?")
main_sizer.Add(self.merge_checkbox, 0, wx.ALL | wx.CENTER, 5)
self.merge_checkbox.Hide()
self.merge_checkbox.Bind(wx.EVT_CHECKBOX, self.on_merge_channels)
# Load standard gif icon and loading animation gif
self.github_icon_path = os.path.join(base_path, 'img', 'github_icon.gif')
self.github_loading_path = os.path.join(base_path, 'img', 'busy_loading.gif')
self.standard_animation = wx.adv.Animation(self.github_icon_path)
self.loading_animation = wx.adv.Animation(self.github_loading_path)
self.gif_ctrl = wx.adv.AnimationCtrl(self.panel, -1, self.standard_animation)
self.gif_ctrl.Play()
outer_sizer = wx.BoxSizer(wx.VERTICAL)
outer_sizer.AddStretchSpacer()
outer_sizer.Add(main_sizer, 1, wx.CENTER | wx.EXPAND | wx.BOTTOM, border=90)
# Initially position the GIF control; will be updated in the on_resize method
self.on_resize(None) # Call once to set the initial position
# Bind the gif control to the GitHub link click event
self.gif_ctrl.Bind(wx.EVT_LEFT_DOWN, self.on_github_icon_click)
# Set the main sizer for the panel
self.panel.SetSizer(outer_sizer)
self.Centre()
self.Show(True)
def on_merge_channels(self, event):
self.should_merge = self.merge_checkbox.GetValue()
def on_resize(self, event):
"""Reposition the GitHub GIF when the window size changes."""
frame_width, frame_height = self.GetSize()
if not hasattr(self, "last_frame_size") or abs(self.last_frame_size[0] - frame_width) > 10 or abs(
self.last_frame_size[1] - frame_height) > 10:
gif_width, gif_height = self.gif_ctrl.GetSize()
margin = 65 # Margin from the bottom and right edges
gif_position = (frame_width - gif_width - margin, frame_height - gif_height - margin)
self.gif_ctrl.SetPosition(gif_position)
self.last_frame_size = (frame_width, frame_height)
if event: # Check if the event exists to avoid errors on initial call
self.update_background(event) # Update the background image as well
def set_gif_animation(self, mode):
"""Swap the animation based on the mode."""
if mode == 'standard':
self.gif_ctrl.SetAnimation(self.standard_animation)
elif mode == 'loading':
self.gif_ctrl.SetAnimation(self.loading_animation)
self.gif_ctrl.Play()
def on_paint(self, event):
"""Paint the background image."""
# Create a device context (DC) used for drawing onto the widget
dc = wx.PaintDC(self.panel)
width, height = self.panel.GetSize()
# Scale the image to cover the entire panel
scaled_image = self.image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
bmp = wx.Bitmap(scaled_image)
# Draw the bitmap onto the panel
dc.DrawBitmap(bmp, 0, 0, True)
# Now draw the custom text
# Add an explanation label at the top
explanation_text = (
"This Software Compress images from a chosen Source Directory and saves them "
"in a Destination Directory.\n\n"
"✳️ Select the Source Directory.\n"
"✳️ Select the Destination Directory.\n"
"✳️ Pick a Compression Option. (Default: 'Compress with Quality Retention').\n"
"✳️ Click 'Start Compression'.\n\n"
"⭐Compression Options:\n"
" - To Compress with Top-Tier Quality retention use ➡️'Compress with Quality Retention'\n"
" - To Compress and Greatly Decrease the Image Size use ➡️ 'Compress Size x2'\nHalves the image dimensions, maintaining aspect ratio.\nThe reduction in file size is notable, and the quality remains largely intact.\n\n"
" - As you increase the compression size (x4, x8, x16), the image size decreases proportionally.\n\nQuality loss becomes more noticeable, especially with 'Compress Size x16'."
)
font = wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_HEAVY)
dc.SetFont(font)
text_color = wx.Colour('white')
shadow_color = wx.Colour('black')
shadow_offset = (-1, 1)
# Draw shadow
dc.SetTextForeground(shadow_color)
dc.DrawText(explanation_text, 20 + shadow_offset[0], 20 + shadow_offset[1])
# Draw text
dc.SetTextForeground(text_color)
dc.DrawText(explanation_text, 20, 20)
def on_github_icon_click(self, event):
# Disable the GitHub icon temporarily
self.gif_ctrl.Disable()
github_url = "https://github.com/zenWai/CompressImages-python"
webbrowser.open(github_url)
# Clickable once every 5 seconds
wx.CallLater(5000, self.gif_ctrl.Enable)
class TextRedirector:
"""A helper class to redirect the stdout/stderr to the TextCtrl widget."""
def __init__(self, widget):
self.widget = widget
def write(self, text):
# Append text to the TextCtrl widget
self.widget.AppendText(text)
def flush(self):
# Needed for file-like interface
pass
def update_background(self, event):
size = self.GetSize()
if not hasattr(self, "last_size") or self.last_size != size:
# Resize the image
image = wx.Image(self.image_file, wx.BITMAP_TYPE_ANY)
image = image.Scale(size[0], size[1], wx.IMAGE_QUALITY_HIGH)
self.bmp = wx.Bitmap(image)
self.last_size = size
event.Skip() # Ensure other event handlers get the resize event as well
self.panel.Refresh()
def on_select_source(self, event):
dlg = wx.DirDialog(self, "Select the Source Directory", "", wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
self.source_directory = dlg.GetPath()
(total_files,
supported_extensions,
unsupported_files_count,
unsupported_files
) = count_files_in_source(self.source_directory, self.console_output)
grouped_files = collect_multi_frame_tiff_groups(self.source_directory)
if grouped_files:
self.merge_checkbox.Show()
wx.CallAfter(self.panel.Layout)
else:
self.merge_checkbox.Hide()
wx.CallAfter(self.panel.Layout)
MSG_SEPARATOR = "========================================\n"
MSG_SRC_DIR = f"Source Directory: {self.source_directory}\n"
MSG_TOTAL_FILES = f"Total Files in Source Directory: {total_files}"
MSG_UNSUPPORTED_FILES = f"[⚠] Unsupported Files in Source Directory: {unsupported_files_count} - {', '.join(unsupported_files)}"
MSG_UNSUPPORTED_FILES_WARNING = f"[⚠] Only files with the following extensions will be compressed: {', '.join(supported_extensions)}"
MSG_SELECT_SOURCE_WITH_SUP_EXT = "[⚠] Please select a Source Directory with Supported Files\n"
log_to_console(self.console_output, MSG_SRC_DIR, None, False)
log_to_console(self.console_output, MSG_TOTAL_FILES, None, False)
if unsupported_files_count > 0:
log_to_console(self.console_output, MSG_UNSUPPORTED_FILES, None, False)
log_to_console(self.console_output, MSG_UNSUPPORTED_FILES_WARNING, wx.RED, False)
if unsupported_files_count == total_files:
log_to_console(self.console_output, MSG_SELECT_SOURCE_WITH_SUP_EXT, wx.RED, False)
log_to_console(self.console_output, MSG_SEPARATOR, None, False)
dlg.Destroy()
def on_select_destination(self, event):
dlg = wx.DirDialog(self, "Select a Empty Destination Directory", "", wx.DD_DEFAULT_STYLE)
if dlg.ShowModal() == wx.ID_OK:
self.destination_directory = dlg.GetPath()
total_files = count_files_in_destination(self.destination_directory)
MSG_SEPARATOR = "========================================"
MSG_DEST_DIR = f"Destination Directory: {self.destination_directory}"
MSG_DEST_DIR_NOT_EMPTY = f"[⚠] Total Files in Destination Directory: {total_files}"
MSG_DEST_DIR_NOT_EMPTY_WARNING = "[⚠] Please Select a Empty Destination Directory"
MSG_DEST_DIR_EMPTY = "[*] Status check complete: Destination directory is appropriately empty."
log_to_console(self.console_output, MSG_DEST_DIR, None, False)
log_to_console(self.console_output, MSG_SEPARATOR, None, False)
if total_files == 0:
log_to_console(self.console_output, MSG_DEST_DIR_EMPTY, wx.GREEN, False)
log_to_console(self.console_output, MSG_SEPARATOR, None, False)
else:
log_to_console(self.console_output, MSG_DEST_DIR_NOT_EMPTY, None, False)
log_to_console(self.console_output, MSG_DEST_DIR_NOT_EMPTY_WARNING, wx.RED, False)
log_to_console(self.console_output, MSG_SEPARATOR, None, False)
dlg.Destroy()
def on_start_compression(self, event):
MSG_SOURCE_DIR = 'Missing source directory. Please select a source directory.'
MSG_DESTINATION_DIR = 'Missing destination directory. Please select a destination directory.'
MSG_SOURCE_DEST_SAME = 'Source and Destination directories cannot be the same. Please select a different destination directory.'
MSG_SOURCE_DEST_DIF_DISK = 'DETECTED: Source and Destination directories are on different Partition/Disk. App needs Source and Destination on same Partition/Disk'
MSG_DEST_IS_SUBDIR_OF_SOURCE = 'The destination directory cannot be a subdirectory of the source directory.\n -Try creating a new Empty Folder outside of the Source Directory.\n -Select that new Folder as your Destination Directory'
MSG_DEST_DIR_NOT_EMPTY = 'The destination directory is not empty. Please select an empty directory or clear the contents of the selected directory before starting the compression.'
# Check if source directory is not selected
if not self.source_directory:
wx.MessageBox(MSG_SOURCE_DIR,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Check if destination directory is not selected
if not self.destination_directory:
wx.MessageBox(MSG_DESTINATION_DIR,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Check if source and destination directories are the same
if self.source_directory == self.destination_directory:
wx.MessageBox(MSG_SOURCE_DEST_SAME,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Check for different disks (or partitions)
if os.name == 'nt': # For Windows
if os.path.splitdrive(self.source_directory)[0] != os.path.splitdrive(self.destination_directory)[0]:
wx.MessageBox(MSG_SOURCE_DEST_DIF_DISK,
'Warning', wx.OK | wx.ICON_WARNING)
return
else: # For Unix-like systems (macOS, Linux)
if os.path.ismount(self.source_directory) != os.path.ismount(self.destination_directory):
wx.MessageBox(MSG_SOURCE_DEST_DIF_DISK,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Check if the destination directory is a subdirectory of the source directory
if os.path.commonpath([self.source_directory, self.destination_directory]) == os.path.normpath(
self.source_directory):
wx.MessageBox(MSG_DEST_IS_SUBDIR_OF_SOURCE,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Check if the destination directory is not empty
if os.listdir(self.destination_directory):
wx.MessageBox(MSG_DEST_DIR_NOT_EMPTY,
'Warning', wx.OK | wx.ICON_WARNING)
return
# Proceed with disabling UI elements and starting the compression
self.gif_ctrl.Disable()
self.btn_source.Disable()
self.btn_dest.Disable()
self.btn_start.Disable()
self.compression_choice.Disable()
self.stop_button.Enable()
if not self.merge_checkbox.IsShown():
self.should_merge = False
else:
self.merge_checkbox.Disable()
self.stop_requested = False
# Set the GIF to loading mode
wx.CallAfter(self.set_gif_animation, 'loading')
# Force UI update
self.Refresh()
startWorker(self.compression_done, run_compression,
wargs=(self.compression_choice, self.source_directory, self.destination_directory,
self.console_output, self.is_stop_requested, self.should_merge))
# User request Stop Button
def is_stop_requested(self):
return self.stop_requested
def request_stop(self, event):
self.stop_button.Disable()
logic_request_stop(self.set_stop_requested, self.console_output)
def set_stop_requested(self, value):
self.stop_requested = value
def enable_controls(self):
self.btn_source.Enable()
self.btn_dest.Enable()
self.btn_start.Enable()
self.compression_choice.Enable()
self.stop_button.Disable()
self.stop_requested = False
self.merge_checkbox.Enable()
# Force UI update
self.Refresh()
def show_completion_dialog(self, log_file_path):
dlg = CustomDialog(self, title="Compression Completed", log_file_path=log_file_path,
source_directory=self.source_directory,
destination_directory=self.destination_directory)
dlg.ShowModal()
dlg.Destroy()
def compression_done(self, result):
"""Handle the results of the compression thread."""
result_value = result.get()
if result_value:
# If compression was stopped prematurely
if result_value == "STOPPED":
MSG_STOPPED = "[⚠] Compression was stopped by the user. Compressed files might "
"be corrupted due to interruption.\n\n"
log_to_console(self.console_output, MSG_STOPPED, wx.RED, True)
else:
# Show the custom dialog
self.set_gif_animation('standard')
self.show_completion_dialog(result_value)
# Completed, set the GIF back to standard mode
self.set_gif_animation('standard')
# Re-enable the GitHub icon clickable action
self.gif_ctrl.Enable()
# Re-enable the buttons and the compression option
self.enable_controls()
# Modal Dialog to open log.txt when compression successful
class CustomDialog(wx.Dialog):
def __init__(self, *args, log_file_path, source_directory, destination_directory, **kwargs):
super(CustomDialog, self).__init__(*args, **kwargs)
self.log_file_path = log_file_path
self.source_directory = source_directory
self.destination_directory = destination_directory
sizer = wx.BoxSizer(wx.VERTICAL)
message = wx.StaticText(self, label="Compression of images has completed!")
sizer.Add(message, wx.SizerFlags().Border(wx.TOP | wx.LEFT, 10))
# Button to open the log file
open_log_btn = wx.Button(self, label="Open Log File")
open_log_btn.Bind(wx.EVT_BUTTON, self.open_log_file)
sizer.Add(open_log_btn, wx.SizerFlags().Border(wx.ALL, 10))
# Button to open Source Directory
open_src_btn = wx.Button(self, label="Source Directory")
open_src_btn.Bind(wx.EVT_BUTTON, self.open_source_directory)
# Button to open Destination Directory
open_dest_btn = wx.Button(self, label="Destination Directory")
open_dest_btn.Bind(wx.EVT_BUTTON, self.open_destination_directory)
# Buttons Source and Destination together
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
button_sizer.Add(open_src_btn, 0, wx.RIGHT, 10)
button_sizer.Add(open_dest_btn, 0, wx.LEFT, 10)
sizer.Add(button_sizer, 0, wx.CENTER | wx.ALL, 10)
ok_button = wx.Button(self, wx.ID_OK, "OK")
sizer.Add(ok_button, wx.SizerFlags().Border(wx.ALL, 10).Center())
self.SetSizer(sizer)
self.Fit()
def open_log_file(self, event):
self.open_path(self.log_file_path)
def open_source_directory(self, event):
self.open_path(self.source_directory)
def open_destination_directory(self, event):
self.open_path(self.destination_directory)
def open_path(self, path):
try:
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin": # macOS
subprocess.run(["open", path], check=True)
else: # Assuming Linux or other Unix-like OS
subprocess.run(["xdg-open", path], check=True)
except Exception as e:
wx.MessageBox(f"Failed to open the path: {e}", "Error", wx.OK | wx.ICON_ERROR)