0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-01-23
動作環境
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

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?