You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
5.0 KiB
183 lines
5.0 KiB
6 years ago
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Qt Demo\n",
|
||
|
"\n",
|
||
|
"This will launch various Qt compatible packages\n",
|
||
|
"\n",
|
||
|
"Nota: as of 2018-04-29th, PySide2-5.11 compatibility is\n",
|
||
|
" - Ok for Qtconsole, Qtpy, pyzo, wppm \n",
|
||
|
" - ToDo for PyQtgraph, Spyder, guidata, guiqwt, rx\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Qt4 & Qt5 Dedicated Graphic libraries: PyQtgraph, guidata, guiqwt"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# PyQtgraph (Scientific Graphics and GUI Library for Python)\n",
|
||
|
"import pyqtgraph.examples; pyqtgraph.examples.run()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Guidata (Python library generating graphical user interfaces for easy dataset editing and display)\n",
|
||
|
"from guidata import tests; tests.run()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Guiqwt (Efficient 2D plotting Python library based on PythonQwt)\n",
|
||
|
"from guiqwt import tests; tests.run()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"#QtDemo (if present)\n",
|
||
|
"!if exist \"%WINPYDIR%\\Lib\\site-packages\\PyQt5\\examples\\qtdemo\\qtdemo.py\" \"%WINPYDIR%\\python.exe\" \"%WINPYDIR%\\Lib\\site-packages\\PyQt5\\examples\\qtdemo\\qtdemo.py\"\n",
|
||
|
"!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\"\n",
|
||
|
"!if exist \"%WINPYDIR%\\Lib\\site-packages\\PySide2\\examples\\datavisualization\" \"%WINPYDIR%\\python.exe\" \"%WINPYDIR%\\Lib\\site-packages\\PySide2\\examples\\datavisualization\\bars3d.py\"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Reactive programing: rx"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# from https://github.com/ReactiveX/RxPY/blob/master/examples/timeflie\n",
|
||
|
"from rx.subjects import Subject\n",
|
||
|
"from rx.concurrency import QtScheduler\n",
|
||
|
"import sys\n",
|
||
|
"\n",
|
||
|
"try:\n",
|
||
|
" from PyQt4 import QtCore\n",
|
||
|
" from PyQt4.QtGui import QWidget, QLabel\n",
|
||
|
" from PyQt4.QtGui import QApplication\n",
|
||
|
"except ImportError:\n",
|
||
|
" try:\n",
|
||
|
" from PyQt5 import QtCore\n",
|
||
|
" from PyQt5.QtWidgets import QApplication, QWidget, QLabel\n",
|
||
|
" except ImportError:\n",
|
||
|
" from PySide import QtCore\n",
|
||
|
" from PySide.QtGui import QWidget, QLabel\n",
|
||
|
" from PySide.QtGui import QApplication\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"class Window(QWidget):\n",
|
||
|
"\n",
|
||
|
" def __init__(self):\n",
|
||
|
" super(QWidget, self).__init__()\n",
|
||
|
" self.setWindowTitle(\"Rx for Python rocks\")\n",
|
||
|
" self.resize(600, 600)\n",
|
||
|
" self.setMouseTracking(True)\n",
|
||
|
"\n",
|
||
|
" # This Subject is used to transmit mouse moves to labels\n",
|
||
|
" self.mousemove = Subject()\n",
|
||
|
"\n",
|
||
|
" def mouseMoveEvent(self, event):\n",
|
||
|
" self.mousemove.on_next((event.x(), event.y()))\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def main():\n",
|
||
|
" app = QApplication(sys.argv)\n",
|
||
|
" scheduler = QtScheduler(QtCore)\n",
|
||
|
"\n",
|
||
|
" window = Window()\n",
|
||
|
" window.show()\n",
|
||
|
"\n",
|
||
|
" text = 'TIME FLIES LIKE AN ARROW'\n",
|
||
|
" labels = [QLabel(char, window) for char in text]\n",
|
||
|
"\n",
|
||
|
" def handle_label(i, label):\n",
|
||
|
"\n",
|
||
|
" def on_next(pos):\n",
|
||
|
" x, y = pos\n",
|
||
|
" label.move(x + i*12 + 15, y)\n",
|
||
|
" label.show()\n",
|
||
|
"\n",
|
||
|
" window.mousemove.delay(i*100, scheduler=scheduler).subscribe(on_next)\n",
|
||
|
"\n",
|
||
|
" for i, label in enumerate(labels):\n",
|
||
|
" handle_label(i, label)\n",
|
||
|
"\n",
|
||
|
" sys.exit(app.exec_())\n",
|
||
|
"\n",
|
||
|
"if __name__ == '__main__':\n",
|
||
|
" main()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"!pip download --dest C:\\WinP\\a QtPy"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.6.5"
|
||
|
},
|
||
|
"widgets": {
|
||
|
"state": {},
|
||
|
"version": "1.1.2"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|