Created
July 16, 2019 01:59
-
-
Save DataSolveProblems/691ddf3d878122fcd4181dde0654f822 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget | |
from PyQt5.QtGui import QPainter, QPixmap, QPen | |
image_path = r"<image file path>" | |
class Demo(QWidget): | |
def __init__(self): | |
super().__init__() | |
self.image = QPixmap(image_path) | |
def paintEvent(self, event): | |
# draw on image | |
pen = QPen() | |
pen.setWidth(5) | |
# upload Image | |
painter = QPainter(self) | |
painter.drawPixmap(self.rect(), self.image) | |
painter.setPen(pen) | |
painter.drawEllipse(300, 300, 150, 150) | |
def main(): | |
app = QApplication(sys.argv) | |
demo = Demo() | |
demo.show() | |
sys.exit(app.exec_()) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment