On 10/12/2018 09:51 AM, aedt wrote:
Hello again.
So I am creating an app that would let users to select time in seconds, and display a
gtk.Spinner
for the given time period. The button that triggers the spinner (in the code,trigger
) is also supposed to show a countdown in the button label.Problem is, the timeout is way too inaccurate. What's causing this inaccuracy and how can I fix it?
The first problem is that you're telling gtkd to give you a timeout that
triggers every time
milliseconds. So if you put a number like 50 in
the entry, then your timeout will be triggered every 50 milliseconds or so.
The second problem is that the GTK event loop isn't anywhere near that
granular. I'd go for more like a fixed 10Hz.
The last problem is mentioned in the docs:
https://api.gtkd.org/gtkd/glib/Timeout.html
"Note that timeout functions may be delayed, due to the processing of
other event sources. Thus they should not be relied on for precise
timing. After each call to the timeout function, the time of the next
timeout is recalculated based on the current time and the given interval
(it does not try to 'catch up' time lost in delays)."