1111# QT doesn't call those from Python/ctypes, meaning we can stop other programs from setting it.
1212if sys .platform == "win32" :
1313 import ctypes
14+
1415 # pyautogui._pyautogui_win.py
1516 ctypes .windll .user32 .SetProcessDPIAware = ( # pyright: ignore[reportAttributeAccessIssue]
1617 lambda : None
8990
9091if sys .platform == "win32" :
9192 from win32comext .shell import shell as shell32
93+
9294 myappid = f"Toufool.AutoSplit.v{ AUTOSPLIT_VERSION } "
9395 shell32 .SetCurrentProcessExplicitAppUserModelID (myappid )
9496
@@ -162,8 +164,8 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]):
162164
163165 self .setupUi (self )
164166 self .setWindowTitle (
165- f"AutoSplit v{ AUTOSPLIT_VERSION } " +
166- (" (externally controlled)" if self .is_auto_controlled else "" ),
167+ f"AutoSplit v{ AUTOSPLIT_VERSION } "
168+ + (" (externally controlled)" if self .is_auto_controlled else "" )
167169 )
168170
169171 # Hotkeys need to be initialized to be passed as thread arguments in hotkeys.py
@@ -210,16 +212,17 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]):
210212 self .undo_split_button .clicked .connect (self .undo_split )
211213 self .next_image_button .clicked .connect (lambda : self .skip_split (navigate_image_only = True ))
212214 self .previous_image_button .clicked .connect (
213- lambda : self .undo_split (navigate_image_only = True ),
215+ lambda : self .undo_split (navigate_image_only = True )
214216 )
215217 self .align_region_button .clicked .connect (lambda : align_region (self ))
216218 self .select_window_button .clicked .connect (lambda : select_window (self ))
217219 self .reload_start_image_button .clicked .connect (
218- lambda : self .__reload_start_image (started_by_button = True ),
220+ lambda : self .__reload_start_image (started_by_button = True )
219221 )
220222 self .action_check_for_updates_on_open .changed .connect (
221223 lambda : user_profile .set_check_for_updates_on_open (
222- self , self .action_check_for_updates_on_open .isChecked (),
224+ self ,
225+ self .action_check_for_updates_on_open .isChecked (),
223226 ),
224227 )
225228
@@ -246,7 +249,7 @@ def _update_checker_widget_signal_slot(latest_version: str, check_on_open: bool)
246249
247250 # live image checkbox
248251 self .timer_live_image .timeout .connect (
249- lambda : self .__update_live_image_details (None , called_from_timer = True ),
252+ lambda : self .__update_live_image_details (None , called_from_timer = True )
250253 )
251254 self .timer_live_image .start (int (ONE_SECOND / self .settings_dict ["fps_limit" ]))
252255
@@ -288,7 +291,8 @@ def __browse(self):
288291
289292 def __update_live_image_details (
290293 self ,
291- capture : MatLike | None , * ,
294+ capture : MatLike | None ,
295+ * ,
292296 called_from_timer : bool = False ,
293297 ):
294298 # HACK: Since this is also called in __get_capture_for_comparison,
@@ -393,15 +397,12 @@ def __compare_capture_for_auto_start(self):
393397 if below_flag and not self .split_below_threshold and similarity_diff >= 0 :
394398 self .split_below_threshold = True
395399 return
396- if (
397- ( # noqa: PLR0916 # See above TODO
398- below_flag
399- and self .split_below_threshold
400- and similarity_diff < 0
401- and is_valid_image (capture )
402- )
403- or (not below_flag and similarity_diff >= 0 )
404- ):
400+ if ( # noqa: PLR0916 # See above TODO
401+ below_flag
402+ and self .split_below_threshold
403+ and similarity_diff < 0
404+ and is_valid_image (capture )
405+ ) or (not below_flag and similarity_diff >= 0 ):
405406 self .timer_start_image .stop ()
406407 self .split_below_threshold = False
407408
@@ -415,7 +416,7 @@ def __compare_capture_for_auto_start(self):
415416 while time_delta < start_delay :
416417 delay_time_left = start_delay - time_delta
417418 self .current_split_image .setText (
418- f"Delayed Before Starting:\n { seconds_remaining_text (delay_time_left )} " ,
419+ f"Delayed Before Starting:\n { seconds_remaining_text (delay_time_left )} "
419420 )
420421 # Wait 0.1s. Doesn't need to be shorter as we only show 1 decimal
421422 QTest .qWait (100 )
@@ -547,7 +548,7 @@ def skip_split(self, *, navigate_image_only: bool = False):
547548 not self .is_running
548549 or "Delayed Split" in self .current_split_image .text ()
549550 or not (
550- self .skip_split_button .isEnabled ()
551+ self .skip_split_button .isEnabled () # fmt: skip
551552 or self .is_auto_controlled
552553 or navigate_image_only
553554 )
@@ -583,7 +584,7 @@ def reset(self):
583584 def start_auto_splitter (self ):
584585 # If the auto splitter is already running or the button is disabled,
585586 # don't emit the signal to start it.
586- if (
587+ if ( # fmt: skip
587588 self .is_running
588589 or (not self .start_auto_splitter_button .isEnabled () and not self .is_auto_controlled )
589590 ):
@@ -622,9 +623,8 @@ def __auto_splitter(self): # noqa: C901,PLR0912,PLR0915
622623 self .split_images_and_loop_number = list (
623624 flatten (
624625 ((split_image , i + 1 ) for i in range (split_image .loops ))
625- for split_image
626- in self .split_images
627- ),
626+ for split_image in self .split_images
627+ )
628628 )
629629
630630 # Construct groups of splits
@@ -726,9 +726,9 @@ def __auto_splitter(self): # noqa: C901,PLR0912,PLR0915
726726 self .gui_changes_on_reset (safe_to_reload_start_image = True )
727727
728728 def __similarity_threshold_loop (
729- self ,
730- number_of_split_images : int ,
731- dummy_splits_array : list [bool ],
729+ self ,
730+ number_of_split_images : int ,
731+ dummy_splits_array : list [bool ],
732732 ):
733733 """
734734 Wait until the similarity threshold is met.
@@ -765,7 +765,7 @@ def __similarity_threshold_loop(
765765 # If its the last non-dummy split image and last loop number,
766766 # disable the skip split button
767767 self .skip_split_button .setEnabled (
768- dummy_splits_array [self .split_image_number :].count (False ) > 1 ,
768+ dummy_splits_array [self .split_image_number :].count (False ) > 1
769769 )
770770 self .undo_split_button .setEnabled (self .split_image_number != 0 )
771771 QApplication .processEvents ()
@@ -827,7 +827,7 @@ def __pause_loop(self, stop_time: float, message: str):
827827 break
828828
829829 self .current_split_image .setText (
830- f"{ message } { seconds_remaining_text (stop_time - time_delta )} " ,
830+ f"{ message } { seconds_remaining_text (stop_time - time_delta )} "
831831 )
832832
833833 QTest .qWait (1 )
@@ -903,7 +903,7 @@ def __get_capture_for_comparison(self):
903903 message += "\n (captured window may be incompatible with BitBlt)"
904904 self .live_image .setText (message )
905905 recovered = self .capture_method .recover_window (
906- self .settings_dict ["captured_window_title" ],
906+ self .settings_dict ["captured_window_title" ]
907907 )
908908 if recovered :
909909 capture = self .capture_method .get_frame ()
@@ -929,7 +929,7 @@ def __reset_if_should(self, capture: MatLike | None):
929929 should_reset = similarity >= threshold
930930 self .reset_highest_similarity = max (similarity , self .reset_highest_similarity )
931931 self .table_reset_image_highest_label .setText (
932- decimal (self .reset_highest_similarity ),
932+ decimal (self .reset_highest_similarity )
933933 )
934934 self .table_reset_image_live_label .setText (decimal (similarity ))
935935
@@ -960,7 +960,7 @@ def __update_split_image(self, specific_image: AutoSplitImage | None = None):
960960
961961 # Get split image
962962 self .split_image = (
963- specific_image
963+ specific_image # fmt: skip
964964 or self .split_images_and_loop_number [0 + self .split_image_number ][0 ]
965965 )
966966 if self .split_image .is_ocr :
@@ -972,7 +972,7 @@ def __update_split_image(self, specific_image: AutoSplitImage | None = None):
972972
973973 self .current_image_file_label .setText (self .split_image .filename )
974974 self .table_current_image_threshold_label .setText (
975- decimal (self .split_image .get_similarity_threshold (self )),
975+ decimal (self .split_image .get_similarity_threshold (self ))
976976 )
977977
978978 # Set Image Loop number
@@ -1048,19 +1048,13 @@ def set_preview_image(qlabel: QLabel, image: MatLike | None):
10481048 image_format = QtGui .QImage .Format .Format_BGR888
10491049 capture = image
10501050
1051- qimage = QtGui .QImage (
1052- capture .data ,
1053- width ,
1054- height ,
1055- width * channels ,
1056- image_format ,
1057- )
1051+ qimage = QtGui .QImage (capture .data , width , height , width * channels , image_format )
10581052 qlabel .setPixmap (
10591053 QtGui .QPixmap (qimage ).scaled (
10601054 qlabel .size (),
10611055 QtCore .Qt .AspectRatioMode .IgnoreAspectRatio ,
10621056 QtCore .Qt .TransformationMode .SmoothTransformation ,
1063- ),
1057+ )
10641058 )
10651059
10661060
0 commit comments