Skip to content

ipygame.time

pygame-compatible time module.

def get_ticks() -> int

Milliseconds since pygame.init() was called.

def wait(milliseconds: int) -> int

Pause for milliseconds ms. Returns actual wait time.

def delay(milliseconds: int) -> int

Accurate delay (same as wait in ipygame).

def set_timer(event_type: int, millis: int = 0, loops: int = 0) -> None

Repeatedly post event_type every millis ms.

Pass millis=0 to cancel an existing timer. loops is the number of events to post (0 = infinite).

class Clock()

Frame-rate tracking and limiting, compatible with pygame.time.Clock.

def __init__() -> None

def tick(framerate: int = 0) -> int

Update the clock.

If framerate > 0 the method will sleep to keep the loop at that speed. Returns milliseconds since the last call.

def tick_busy_loop(framerate: int = 0) -> int

Like tick() but uses a busy loop for more accuracy.

def get_time() -> int

Milliseconds between the two most recent tick() calls.

def get_rawtime() -> int

Like get_time() but without sleep compensation.

def get_fps() -> float

Compute the clock framerate (calls per second).

async def tick_async(framerate: int = 0) -> int

Async version of tick() for Jupyter notebooks.

Uses asyncio.sleep() instead of time.sleep() so the Jupyter kernel event loop can process widget messages (keyboard, mouse, etc.) between frames.