Exemple #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        _create_qApp()
        if len(self.signals) != 1:
            raise ValueError('Cross section view only supports a single '
                             'ROI')

        self.label = list(self.signals.keys())[0]
        self.live_window = _new_window('Live update - {}'.format(self.label))
        self._final_window = None
Exemple #2
0
def install_qt_kicker(loop=None, update_rate=0.03):
    """Install a periodic callback to integrate Qt and asyncio event loops.

    If a version of the Qt bindings are not already imported, this function
    will do nothing.

    It is safe to call this function multiple times.

    Parameters
    ----------
    loop : event loop, optional
    update_rate : number
        Seconds between periodic updates. Default is 0.03.
    """
    if loop is None:
        loop = asyncio.get_event_loop()
    global _QT_KICKER_INSTALLED
    if loop in _QT_KICKER_INSTALLED:
        return
    if not any(p in sys.modules for p in ['PyQt4', 'pyside', 'PyQt5']):
        return
    import matplotlib.backends.backend_qt5
    from matplotlib.backends.backend_qt5 import _create_qApp
    from matplotlib._pylab_helpers import Gcf

    _create_qApp()
    qApp = matplotlib.backends.backend_qt5.qApp

    try:
        _draw_all = Gcf.draw_all  # mpl version >= 1.5
    except AttributeError:
        # slower, but backward-compatible
        def _draw_all():
            for f_mgr in Gcf.get_all_fig_managers():
                f_mgr.canvas.draw_idle()

    def _qt_kicker():
        # The RunEngine Event Loop interferes with the qt event loop. Here we
        # kick it to keep it going.
        _draw_all()

        qApp.processEvents()
        loop.call_later(update_rate, _qt_kicker)

    _QT_KICKER_INSTALLED[loop] = loop.call_soon(_qt_kicker)
Exemple #3
0
def install_qt_kicker():
    """Install a periodic callback to integrate qt and asyncio event loops

    If a version of the qt bindings are not already imported, this function
    will do nothing.

    It is safe to call this function multiple times.
    """

    global _INSTALLED
    if _INSTALLED is not None:
        return
    if not any(p in sys.modules for p in ['PyQt4', 'pyside', 'PyQt5']):
        return
    import asyncio
    import matplotlib.backends.backend_qt5
    from matplotlib.backends.backend_qt5 import _create_qApp
    from matplotlib._pylab_helpers import Gcf

    _create_qApp()
    qApp = matplotlib.backends.backend_qt5.qApp

    try:
        _draw_all = Gcf.draw_all  # mpl version >= 1.5
    except AttributeError:
        # slower, but backward-compatible
        def _draw_all():
            for f_mgr in Gcf.get_all_fig_managers():
                f_mgr.canvas.draw_idle()

    def _qt_kicker():
        # The RunEngine Event Loop interferes with the qt event loop. Here we
        # kick it to keep it going.
        _draw_all()

        qApp.processEvents()
        loop.call_later(0.03, _qt_kicker)

    loop = asyncio.get_event_loop()
    _INSTALLED = loop.call_soon(_qt_kicker)
Exemple #4
0
import asyncio
import time as ttime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.backends.backend_qt5
from matplotlib.backends.backend_qt5 import _create_qApp
_create_qApp()

qApp = matplotlib.backends.backend_qt5.qApp

plt.close('all')
fig, ax = plt.subplots()
ln, = ax.plot([], [], marker='o')
ax.set_xlim(0, 50)
ax.set_ylim(0, 50)

loop = asyncio.get_event_loop()


def dummy(start_time, j, timeout):
    if loop.time() > start_time + timeout:
        print("skipping  {}".format(j))
        return
    print("running! {}".format(j))


def plotter(j):
    N = 10000
    for _ in range(N):
        ttime.sleep(.3 / N)
    ln.set_xdata(np.r_[ln.get_xdata(), j])
Exemple #5
0
import asyncio
import warnings
from prettytable import PrettyTable

import matplotlib.backends.backend_qt5
from matplotlib.backends.backend_qt5 import _create_qApp
import matplotlib.pyplot as plt

from datetime import datetime
import numpy as np

import logging
logger = logging.getLogger(__name__)


_create_qApp()
qApp = matplotlib.backends.backend_qt5.qApp

from matplotlib._pylab_helpers import Gcf

try:
    _draw_all = Gcf.draw_all  # mpl version >= 1.5
except AttributeError:
    # slower, but backward-compatible
    def _draw_all():
        for f_mgr in Gcf.get_all_fig_managers():
            f_mgr.canvas.draw_idle()


def _qt_kicker():
    # The RunEngine Event Loop interferes with the qt event loop. Here we