From 59ddff61d231dd6386385d5081d19d44fc4fe718 Mon Sep 17 00:00:00 2001 From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:43:41 +0300 Subject: [PATCH] chore: Refactor code to remove unnecessary time delay in startButton click event handler --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a42e369..ccc84e3 100644 --- a/main.py +++ b/main.py @@ -55,7 +55,8 @@ def start_typing(self): self.startButton.setEnabled(False) self.stopButton.setEnabled(True) - QTimer.singleShot(delay * 1000, lambda: self.initiate_typing(text, interval, type_enter, chars_per_stroke)) + time.sleep(delay) + self.initiate_typing(text, interval, type_enter, chars_per_stroke) def initiate_typing(self, text, interval, type_enter, chars_per_stroke): self.thread = TypingThread(text, interval, type_enter, chars_per_stroke) @@ -66,7 +67,7 @@ def initiate_typing(self, text, interval, type_enter, chars_per_stroke): def update_progress(self, value): self.progressBar.setValue(value) - + def typing_finished(self): self.startButton.setEnabled(True) self.stopButton.setEnabled(False)