mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-24 21:30:36 +00:00
Add support for timers and run/quit_event_loop
This commit is contained in:
parent
ebaecbcb7e
commit
33a1d07226
5 changed files with 148 additions and 1 deletions
26
api/python/tests/test_timers.py
Normal file
26
api/python/tests/test_timers.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
import pytest
|
||||
import slint
|
||||
from slint import ValueType
|
||||
from datetime import timedelta
|
||||
|
||||
def test_timer():
|
||||
global counter
|
||||
counter = 0
|
||||
def quit_after_two_invocations():
|
||||
global counter
|
||||
counter = counter + 1
|
||||
if counter >= 2:
|
||||
slint.quit_event_loop()
|
||||
|
||||
test_timer = slint.Timer()
|
||||
test_timer.start(slint.TimerMode.Repeated, timedelta(milliseconds=100), quit_after_two_invocations)
|
||||
slint.run_event_loop()
|
||||
test_timer.stop()
|
||||
assert(counter == 2)
|
||||
|
||||
def test_single_shot():
|
||||
slint.Timer.single_shot(timedelta(milliseconds=100), slint.quit_event_loop)
|
||||
slint.run_event_loop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue