From 02445269c2d77298c6e38f71780a7cd0520a17c5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 1 Jul 2026 15:37:29 -0400 Subject: [PATCH 1/2] Preset "No Folder Selected" in ui file --- res/design.ui | 3 +++ src/AutoSplit.py | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/design.ui b/res/design.ui index 0ddab8d1..767bb23c 100644 --- a/res/design.ui +++ b/res/design.ui @@ -512,6 +512,9 @@ 22 + + No Folder Selected + true diff --git a/src/AutoSplit.py b/src/AutoSplit.py index 975f8065..b4882c6d 100755 --- a/src/AutoSplit.py +++ b/src/AutoSplit.py @@ -196,9 +196,6 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]): self.update_auto_control = AutoControlledThread(self) self.update_auto_control.start() - # split image folder line edit text - self.split_image_folder_input.setText("No Folder Selected") - # Connecting menu actions self.action_view_help.triggered.connect(view_help) self.action_about.triggered.connect(lambda: open_about(self)) From 2577defe9883209115c198aeb97515c12e7bf290 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 1 Jul 2026 15:37:44 -0400 Subject: [PATCH 2/2] Reorganize `error_messages.py` --- src/error_messages.py | 130 +++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/error_messages.py b/src/error_messages.py index 3c41479c..5a07e2f9 100644 --- a/src/error_messages.py +++ b/src/error_messages.py @@ -16,6 +16,18 @@ if TYPE_CHECKING: from AutoSplit import AutoSplit +# Keep in sync with README.md#DOWNLOAD_AND_OPEN +WAYLAND_WARNING = """\ +All screen capture method are incompatible with Wayland. Follow this guide to disable it: + \ +https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop""" + +CREATE_NEW_ISSUE_MESSAGE = ( + f"Please create a New Issue at " + + f"github.com/{GITHUB_REPOSITORY}/issues, describe what happened, " + + "and copy & paste the entire error message below" +) + def __exit_program(): # stop main thread (which is probably blocked reading input) via an interrupt signal @@ -23,7 +35,7 @@ def __exit_program(): sys.exit(1) -def set_text_message( +def _set_text_message( message: str, details: str = "", kill_button: str = "", @@ -53,66 +65,66 @@ def set_text_message( def split_image_directory(): - set_text_message("No Split Image Folder is selected.") + _set_text_message("No Split Image Folder is selected.") def invalid_directory(directory: str): - set_text_message(f"Folder {directory!r} is invalid or does not exist.") + _set_text_message(f"Folder {directory!r} is invalid or does not exist.") def no_split_image(): - set_text_message("Your Split Image Folder should contain at least one Split Image.") + _set_text_message("Your Split Image Folder should contain at least one Split Image.") def image_type(image: str): - set_text_message( + _set_text_message( f"{image!r} is not a valid image file, does not exist, " + "or the full image file path contains a special character." ) def region(): - set_text_message( + _set_text_message( "No region is selected or the Capture Region window is not open. " + "Select a region or load settings while the Capture Region window is open." ) def split_hotkey(): - set_text_message("No split hotkey has been set.") + _set_text_message("No split hotkey has been set.") def pause_hotkey(): - set_text_message( + _set_text_message( "Your Split Image Folder contains an image filename with a pause flag {p}, " + "but no pause hotkey is set." ) def image_validity(image: str = "File"): - set_text_message(f"{image} not a valid image file") + _set_text_message(f"{image} not a valid image file") def alignment_not_matched(): - set_text_message("No area in capture region matched reference image. Alignment failed.") + _set_text_message("No area in capture region matched reference image. Alignment failed.") def no_keyword_image(keyword: str): - set_text_message( + _set_text_message( f"Your Split Image Folder does not contain an image with the keyword {keyword!r}." ) def multiple_keyword_images(keyword: str): - set_text_message(f"Only one image with the keyword {keyword!r} is allowed.") + _set_text_message(f"Only one image with the keyword {keyword!r} is allowed.") def reset_hotkey(): - set_text_message("Your Split Image Folder contains a Reset Image, but no reset hotkey is set.") + _set_text_message("Your Split Image Folder contains a Reset Image, but no reset hotkey is set.") def old_version_settings_file(): - set_text_message( + _set_text_message( "Old version settings file detected. " + "This version allows settings files in .toml format. " + "Starting from v2.0." @@ -120,48 +132,48 @@ def old_version_settings_file(): def invalid_settings(): - set_text_message("Invalid settings file.") + _set_text_message("Invalid settings file.") def invalid_hotkey(hotkey_name: str): - set_text_message(f"Invalid hotkey {hotkey_name!r}") + _set_text_message(f"Invalid hotkey {hotkey_name!r}") def no_settings_file_on_open(): - set_text_message( + _set_text_message( "No settings file found. " + "One can be loaded on open if placed in the same folder as the AutoSplit executable." ) def too_many_settings_files_on_open(): - set_text_message( + _set_text_message( "Too many settings files found. " + "Only one can be loaded on open if placed in the same folder as the AutoSplit executable." ) def check_for_updates(): - set_text_message( + _set_text_message( "An error occurred while attempting to check for updates. Please check your connection." ) def load_start_image(): - set_text_message( + _set_text_message( "Start Image found, but cannot be loaded unless Start hotkey is set. " + "Please set the hotkey, and then click the Reload Start Image button." ) def stdin_lost(): - set_text_message( + _set_text_message( "stdin not supported or lost, external control like LiveSplit integration will not work." ) def already_open(): - set_text_message( + _set_text_message( "An instance of AutoSplit is already running." + "
Are you sure you want to open a another one?", "", @@ -171,7 +183,7 @@ def already_open(): def linux_groups(): - set_text_message( + _set_text_message( "Linux users must ensure they are in the 'tty' and 'input' groups " + "and have write access to '/dev/uinput'. You can run the following commands to do so:", # Keep in sync with README.md and scripts/install.ps1 @@ -188,22 +200,15 @@ def linux_groups(): def linux_uinput(): - set_text_message( + _set_text_message( "Failed to create a device file using `uinput` module. " + "This can happen when running Linux under WSL. " + "Keyboard events have been disabled." ) -# Keep in sync with README.md#DOWNLOAD_AND_OPEN -WAYLAND_WARNING = """\ -All screen capture method are incompatible with Wayland. Follow this guide to disable it: - \ -https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop""" - - def linux_wayland(): - set_text_message(WAYLAND_WARNING) + _set_text_message(WAYLAND_WARNING) def exception_traceback(exception: BaseException, message: str = ""): @@ -213,18 +218,39 @@ def exception_traceback(exception: BaseException, message: str = ""): + "however, there is no guarantee it will keep working properly. " + CREATE_NEW_ISSUE_MESSAGE ) - set_text_message( + _set_text_message( message, "\n".join(traceback.format_exception(None, exception, exception.__traceback__)), "Close AutoSplit", ) -CREATE_NEW_ISSUE_MESSAGE = ( - f"Please create a New Issue at " - + f"github.com/{GITHUB_REPOSITORY}/issues, describe what happened, " - + "and copy & paste the entire error message below" -) +def tesseract_missing(ocr_split_file_path: str): + _set_text_message( + f"{ocr_split_file_path!r} is an Optical Character Recognition split file " + + "but tesseract couldn't be found." + + f'\nPlease read ' + + f"github.com/{GITHUB_REPOSITORY}#install-tesseract for installation instructions." + ) + + +def ocr_missing_key(ocr_split_file_path: str, missing_key: str): + _set_text_message(f"{ocr_split_file_path!r} is missing an entry for {missing_key!r}") + + +def wrong_ocr_values(ocr_split_file_path: str): + _set_text_message( + f"{ocr_split_file_path!r} has invalid values." + + "\nPlease make sure that `left < right` and `top < bottom`. " + + "Also check for negative values in the 'methods' or 'fps_limit' settings" + ) + + +def invalid_filename_delimiters(filename: str, delimiters: str): + _set_text_message( + f"Split '{filename}' contains invalid parameters. " + + f"'{delimiters}' must not appear more than once." + ) def make_excepthook(autosplit: AutoSplit): @@ -258,31 +284,3 @@ def handle_top_level_exceptions(exception: Exception) -> NoReturn: else: traceback.print_exception(type(exception), exception, exception.__traceback__) sys.exit(1) - - -def tesseract_missing(ocr_split_file_path: str): - set_text_message( - f"{ocr_split_file_path!r} is an Optical Character Recognition split file " - + "but tesseract couldn't be found." - + f'\nPlease read ' - + f"github.com/{GITHUB_REPOSITORY}#install-tesseract for installation instructions." - ) - - -def ocr_missing_key(ocr_split_file_path: str, missing_key: str): - set_text_message(f"{ocr_split_file_path!r} is missing an entry for {missing_key!r}") - - -def wrong_ocr_values(ocr_split_file_path: str): - set_text_message( - f"{ocr_split_file_path!r} has invalid values." - + "\nPlease make sure that `left < right` and `top < bottom`. " - + "Also check for negative values in the 'methods' or 'fps_limit' settings" - ) - - -def invalid_filename_delimiters(filename: str, delimiters: str): - set_text_message( - f"Split '{filename}' contains invalid parameters. " - + f"'{delimiters}' must not appear more than once." - )