クラスの抽象化がすばらしい。
成果物
情報源
ここを読めば雰囲気が掴める。
コード
main.py
#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys from PySide2 import QtCore, QtGui, QtWidgets class GraphicView(QtWidgets.QGraphicsView): def __init__(self): QtWidgets.QGraphicsView.__init__(self) self.setWindowTitle("QGraphicsView") scene = QtWidgets.QGraphicsScene(self) scene.setSceneRect(0, 0, 160, 120) self.setScene(scene) line = QtCore.QLineF(10,10,100,100) node = QtWidgets.QGraphicsLineItem(line) scene.addItem(node) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) widget = GraphicView() widget.show() sys.exit(app.exec_())
python3 main.py
構造
所感
Qt, PySide2は、SDL, PySDL2よりも遥かに美しく抽象化されている。すばらしい。
対象環境
- Raspbierry pi 4 Model B
- Raspbian buster 10.0 2019-09-26 ※
- bash 5.0.3(1)-release
- Qt 5.11
- Python 3.7.3
- PySide2
$ uname -a Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux