Qt Demo

This will launch various Qt compatible packages

Nota: as of 2019-05-26th, PySide2-5.13+ compatibility is

  • Ok for Qtconsole, Qtpy, pyzo, wppm, PyQtgraph, rx
  • ToDo for Spyder, guidata, guiqwt

Qt4 & Qt5 Dedicated Graphic libraries: PyQtgraph, guidata, guiqwt

In [ ]:
# PyQtgraph (Scientific Graphics and GUI Library for Python)
import pyqtgraph.examples; pyqtgraph.examples.run()
In [ ]:
# Guidata (Python library generating graphical user interfaces for easy dataset editing and display)
from guidata import tests; tests.run()
In [ ]:
# Guiqwt (Efficient 2D plotting Python library based on PythonQwt)
from guiqwt import tests; tests.run()
In [ ]:
#QtDemo (if present)
!if exist "%WINPYDIR%\Lib\site-packages\PyQt5\examples\qtdemo\qtdemo.py"  "%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\PyQt5\examples\qtdemo\qtdemo.py"
!if exist "%WINPYDIR%\Lib\site-packages\PyQt4\examples\demos\qtdemo\qtdemo.pyw""%WINPYDIR%\pythonw.exe" "%WINPYDIR%\Lib\site-packages\PyQt4\examples\demos\qtdemo\qtdemo.pyw"
!if exist "%WINPYDIR%\Lib\site-packages\PySide2\examples\datavisualization" "%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\PySide2\examples\datavisualization\bars3d.py"

Reactive programing: rx

In [ ]:
# from https://github.com/ReactiveX/RxPY/blob/master/examples/timeflie
import sys

import rx
from rx import operators as ops
from rx.subjects import Subject
from rx.concurrency.mainloopscheduler import QtScheduler

try:
    from PyQt5 import QtCore
    from PyQt5.QtWidgets import QApplication, QWidget, QLabel
except ImportError:
    try:
        from PySide2 import QtCore
        from PySide2.QtWidgets import QApplication, QLabel, QWidget
    except ImportError:
        raise ImportError('Please ensure either PyQT5 or PySide2 is available!')


class Window(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.setWindowTitle("Rx for Python rocks")
        self.resize(600, 600)
        self.setMouseTracking(True)

        # This Subject is used to transmit mouse moves to labels
        self.mousemove = Subject()

    def mouseMoveEvent(self, event):
        self.mousemove.on_next((event.x(), event.y()))


def main():
    app = QApplication(sys.argv)
    scheduler = QtScheduler(QtCore)

    window = Window()
    window.show()

    text = 'TIME FLIES LIKE AN ARROW'

    def on_next(info):
        label, (x, y), i = info
        label.move(x + i*12 + 15, y)
        label.show()

    def handle_label(label, i):
        delayer = ops.delay(i * 0.100)
        mapper = ops.map(lambda xy: (label, xy, i))

        return window.mousemove.pipe(
            delayer,
            mapper,
            )

    labeler = ops.flat_map_indexed(handle_label)
    mapper = ops.map(lambda c: QLabel(c, window))

    rx.from_(text).pipe(
        mapper,
        labeler,
    ).subscribe(on_next, on_error=print, scheduler=scheduler)

    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
In [ ]:
!pip download --dest  C:\WinP\a QtPy
In [ ]: