core.qt

pyctools.core.qt.QtEventLoop

Event loop using the Qt "main thread" (or "GUI thread").

pyctools.core.qt.QtThreadEventLoop

Event loop using a Qt "worker thread".

class QtEventLoop(owner, **kwds)[source]

Bases: object

Event loop using the Qt “main thread” (or “GUI thread”).

Use this event loop if your component is a Qt widget or needs to run in the main Qt thread for any other reason. See the QtDisplay component for an example.

Pyctools event loops are described in more detail in the ThreadEventLoop documentation.

queue_command(command)[source]

Put a command on the queue to be called in the component’s thread.

Parameters:

command (callable) – the method to be invoked, e.g. new_frame_event.

start()[source]

Start the component’s event loop (thread-safe).

After the event loop is started the Qt thread calls the component’s start_event method, then calls its new_frame_event and new_config_event methods as required until stop is called. Finally the component’s stop_event method is called before the event loop terminates.

join(timeout=3600)[source]

Wait until the event loop terminates or timeout is reached.

This method is not meaningful unless called from the Qt “main thread”, which is almost certainly the thread in which the component was created.

Parameters:

timeout (float) – timeout in seconds.

running()[source]

Is the event loop running.

Return type:

bool

class QtThreadEventLoop(owner, **kwds)[source]

Bases: QtEventLoop

Event loop using a Qt “worker thread”.

Use this event loop if your component is a Qt component that does not need to run in the main thread. This allows a Pyctools component to send or receive Qt signals, giving easy integration with other Qt components.

I have experimented with using QtThreadEventLoop instead of ThreadEventLoop in all the components in a network. Surprisingly it ran at the same speed.

Pyctools event loops are described in more detail in the ThreadEventLoop documentation.

queue_command()

Put a command on the queue to be called in the component’s thread.

Parameters:

command (callable) – the method to be invoked, e.g. new_frame_event.

start()

Start the component’s event loop (thread-safe).

After the event loop is started the Qt thread calls the component’s start_event method, then calls its new_frame_event and new_config_event methods as required until stop is called. Finally the component’s stop_event method is called before the event loop terminates.

running()

Is the event loop running.

Return type:

bool

join(timeout=3600)[source]

Wait until the event loop terminates or timeout is reached.

Parameters:

timeout (float) – timeout in seconds.


Comments or questions? Please email jim@jim-easterbrook.me.uk.