11
11
# QT doesn't call those from Python/ctypes, meaning we can stop other programs from setting it.
12
12
if sys .platform == "win32" :
13
13
import ctypes
14
+
14
15
# pyautogui._pyautogui_win.py
15
16
ctypes .windll .user32 .SetProcessDPIAware = ( # pyright: ignore[reportAttributeAccessIssue]
16
17
lambda : None
89
90
90
91
if sys .platform == "win32" :
91
92
from win32comext .shell import shell as shell32
93
+
92
94
myappid = f"Toufool.AutoSplit.v{ AUTOSPLIT_VERSION } "
93
95
shell32 .SetCurrentProcessExplicitAppUserModelID (myappid )
94
96
@@ -162,8 +164,8 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]):
162
164
163
165
self .setupUi (self )
164
166
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 "" )
167
169
)
168
170
169
171
# 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]):
210
212
self .undo_split_button .clicked .connect (self .undo_split )
211
213
self .next_image_button .clicked .connect (lambda : self .skip_split (navigate_image_only = True ))
212
214
self .previous_image_button .clicked .connect (
213
- lambda : self .undo_split (navigate_image_only = True ),
215
+ lambda : self .undo_split (navigate_image_only = True )
214
216
)
215
217
self .align_region_button .clicked .connect (lambda : align_region (self ))
216
218
self .select_window_button .clicked .connect (lambda : select_window (self ))
217
219
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 )
219
221
)
220
222
self .action_check_for_updates_on_open .changed .connect (
221
223
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 (),
223
226
),
224
227
)
225
228
@@ -246,7 +249,7 @@ def _update_checker_widget_signal_slot(latest_version: str, check_on_open: bool)
246
249
247
250
# live image checkbox
248
251
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 )
250
253
)
251
254
self .timer_live_image .start (int (ONE_SECOND / self .settings_dict ["fps_limit" ]))
252
255
@@ -288,7 +291,8 @@ def __browse(self):
288
291
289
292
def __update_live_image_details (
290
293
self ,
291
- capture : MatLike | None , * ,
294
+ capture : MatLike | None ,
295
+ * ,
292
296
called_from_timer : bool = False ,
293
297
):
294
298
# HACK: Since this is also called in __get_capture_for_comparison,
@@ -393,15 +397,12 @@ def __compare_capture_for_auto_start(self):
393
397
if below_flag and not self .split_below_threshold and similarity_diff >= 0 :
394
398
self .split_below_threshold = True
395
399
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 ):
405
406
self .timer_start_image .stop ()
406
407
self .split_below_threshold = False
407
408
@@ -415,7 +416,7 @@ def __compare_capture_for_auto_start(self):
415
416
while time_delta < start_delay :
416
417
delay_time_left = start_delay - time_delta
417
418
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 )} "
419
420
)
420
421
# Wait 0.1s. Doesn't need to be shorter as we only show 1 decimal
421
422
QTest .qWait (100 )
@@ -547,7 +548,7 @@ def skip_split(self, *, navigate_image_only: bool = False):
547
548
not self .is_running
548
549
or "Delayed Split" in self .current_split_image .text ()
549
550
or not (
550
- self .skip_split_button .isEnabled ()
551
+ self .skip_split_button .isEnabled () # fmt: skip
551
552
or self .is_auto_controlled
552
553
or navigate_image_only
553
554
)
@@ -583,7 +584,7 @@ def reset(self):
583
584
def start_auto_splitter (self ):
584
585
# If the auto splitter is already running or the button is disabled,
585
586
# don't emit the signal to start it.
586
- if (
587
+ if ( # fmt: skip
587
588
self .is_running
588
589
or (not self .start_auto_splitter_button .isEnabled () and not self .is_auto_controlled )
589
590
):
@@ -622,9 +623,8 @@ def __auto_splitter(self): # noqa: C901,PLR0912,PLR0915
622
623
self .split_images_and_loop_number = list (
623
624
flatten (
624
625
((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
+ )
628
628
)
629
629
630
630
# Construct groups of splits
@@ -726,9 +726,9 @@ def __auto_splitter(self): # noqa: C901,PLR0912,PLR0915
726
726
self .gui_changes_on_reset (safe_to_reload_start_image = True )
727
727
728
728
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 ],
732
732
):
733
733
"""
734
734
Wait until the similarity threshold is met.
@@ -765,7 +765,7 @@ def __similarity_threshold_loop(
765
765
# If its the last non-dummy split image and last loop number,
766
766
# disable the skip split button
767
767
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
769
769
)
770
770
self .undo_split_button .setEnabled (self .split_image_number != 0 )
771
771
QApplication .processEvents ()
@@ -827,7 +827,7 @@ def __pause_loop(self, stop_time: float, message: str):
827
827
break
828
828
829
829
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 )} "
831
831
)
832
832
833
833
QTest .qWait (1 )
@@ -903,7 +903,7 @@ def __get_capture_for_comparison(self):
903
903
message += "\n (captured window may be incompatible with BitBlt)"
904
904
self .live_image .setText (message )
905
905
recovered = self .capture_method .recover_window (
906
- self .settings_dict ["captured_window_title" ],
906
+ self .settings_dict ["captured_window_title" ]
907
907
)
908
908
if recovered :
909
909
capture = self .capture_method .get_frame ()
@@ -929,7 +929,7 @@ def __reset_if_should(self, capture: MatLike | None):
929
929
should_reset = similarity >= threshold
930
930
self .reset_highest_similarity = max (similarity , self .reset_highest_similarity )
931
931
self .table_reset_image_highest_label .setText (
932
- decimal (self .reset_highest_similarity ),
932
+ decimal (self .reset_highest_similarity )
933
933
)
934
934
self .table_reset_image_live_label .setText (decimal (similarity ))
935
935
@@ -960,7 +960,7 @@ def __update_split_image(self, specific_image: AutoSplitImage | None = None):
960
960
961
961
# Get split image
962
962
self .split_image = (
963
- specific_image
963
+ specific_image # fmt: skip
964
964
or self .split_images_and_loop_number [0 + self .split_image_number ][0 ]
965
965
)
966
966
if self .split_image .is_ocr :
@@ -972,7 +972,7 @@ def __update_split_image(self, specific_image: AutoSplitImage | None = None):
972
972
973
973
self .current_image_file_label .setText (self .split_image .filename )
974
974
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 ))
976
976
)
977
977
978
978
# Set Image Loop number
@@ -1048,19 +1048,13 @@ def set_preview_image(qlabel: QLabel, image: MatLike | None):
1048
1048
image_format = QtGui .QImage .Format .Format_BGR888
1049
1049
capture = image
1050
1050
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 )
1058
1052
qlabel .setPixmap (
1059
1053
QtGui .QPixmap (qimage ).scaled (
1060
1054
qlabel .size (),
1061
1055
QtCore .Qt .AspectRatioMode .IgnoreAspectRatio ,
1062
1056
QtCore .Qt .TransformationMode .SmoothTransformation ,
1063
- ),
1057
+ )
1064
1058
)
1065
1059
1066
1060
0 commit comments