immediate bug solved#57
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
Brief description of what this PR does.
self.time_leftandself.timer_id: To track the countdown and manage the after() loop.2. Added
self.timer_label: A new UI element to display the remaining time.3. Implemented
update_timer: Handles the countdown logic and triggers check_result when time runs out.4. Updated
start_test: To initialize the timer and reset the countdown.5. Fixed
check_result: Added a timeout parameter. If the test ends via timeout, elapsed_time is set to the exact TEST_DURATION (60s)instead of calculating it from time.time(), ensuring consistent WPM results.
🔗 Related Issue
Closes: #52#53#54
so basically when i solved immediate bug solution it automattically solved the time related problems so it closed the remaing issues too.
How to verify the "Ghost Timer" Fix
To see if your fix actually worked (independent of the Git error), run your script and do this:
Click Start Test.
Wait 5 seconds.
Click Restart Test immediately.
Watch the clock: If it counts down normally (59, 58, 57...), the Ghost Timer is solved.
If it jumps (59, 57, 55...), the after_cancel is not triggering correctly.
🛠 Changes Made
-Initialised Timer State: Added self.time_left (set to 60s) and self.timer_id to track the countdown and manage the after() loop.
Added Timer UI: Created self.timer_label to display the remaining time to the user.
Implemented
update_timer: This method handles the 1-second interval countdown. When it hits 0, it automatically triggerscheck_result(timeout=True).
Reset Logic in
start_test: Ensuring any existing timer is cancelled before starting a new one (also fixing the "Ghost Timer"issue) and resetting the countdown.
The Math Fix in
check_result:* Added a timeout parameter to the function.
* Logical Fix: If the test ends because the timer reached 0 (timeout=True), the code now uses the exact TEST_DURATION (60) for the
elapsed_time variable. This prevents WPM inaccuracies caused by the slight CPU latency (e.g., 60.01s) that occurs when using
time.time().
📷 Screenshots (if applicable)
✅ Checklist