.. _qtservice: ========= QtService ========= .. currentmodule:: PyroMP QtServices provide an event loop for Qt and Pyro4. PySide and PyQt4 is supported, but the former is prefered. .. warning:: Due to problems of Qt with threads it is not possible to use :func:`~QtService.init_resources` to initialize Qt objects. The user interface has to be initialized in the :func:`~QtService.qt_main` function, which is called in the main thread after :func:`~QtService.init_resources` has finished. .. warning:: You have to connect to :class:`events ` or other PyroMP stuff in the :func:`~QtService.init_resources` function or your program will deadlock .. note:: QtService makes it possible to use PySide and PyQt4 in parallel (see :ref:`pyside_pyqt_example`). Calling convention ------------------ Qt objects are not thread-safe. If a threaded server is used, normal function calls won't work (see :ref:`qtservice_example`). Calling functions on QObject needs to use the Qt Signal/Slot mechanism. Example ------- .. code-block:: python import PyroMP from PyroMP.Qt import QtGui, QtCore class MyDialog(QtGui.QDialog): call_func = QtCore.Signal(object) def __init__(self): super(MyDialog, self).__init__() self.call_func.connect(self.my_function) def my_function(self, arg): # do some stuff here class MyService(PyroMP.QtService): def qt_main(self): self.dlg = MyDialog() self.dlg.show() def my_function(self, arg): self.dlg.call_func.emit(arg) API Reference ------------- .. autoclass:: QtService **Methods** .. automethod:: get_logger .. automethod:: init_resources .. automethod:: close_resources .. automethod:: qt_main **Class Methods** .. automethod:: get_connection .. automethod:: get_pyro_name .. automethod:: is_running .. automethod:: start .. automethod:: stop .. automethod:: wait_for