電子工作
PyQt5
borgSensorSystem1
borgInventory

PyQt5 > 描画 > 円と線を描く + 備考

動作環境
Ubuntu 16.04 LTS desktop amd64
Python 3.5.2
PyQt5 v5.5.1

処理概要

円と線を描く。

参考

code

test_kabaya_juicy_180123.py
import sys

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class Widget(QWidget):
    def __init__(self, parent=None):
        super(Widget, self).__init__(parent)

    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setPen(Qt.red)
        painter.setBrush(Qt.yellow)
        #painter.drawRect(10, 10, 100, 100)
        center = QPoint(100, 100)
        painter.drawEllipse(center, 50, 50)
        #
        len = 50
        painter.drawLine(100 - len, 100 - len, 100 + len, 100 + len)
        painter.drawLine(100 + len, 100 - len, 100 - len, 100 + len)
        painter.drawLine(100, 100 - len, 100, 100 + len)


def main():
    app = QApplication(sys.argv)
    w = Widget()
    w.show()
    w.raise_()
    app.exec_()

if __name__ == '__main__':
    main()

実行例

$ python3 test_kabaya_juicy_180123.py 

qiita.png

備考

フレームをどう作るのか簡単だろうか。

別の利用例: link