Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created July 16, 2019 01:59
Show Gist options
  • Save DataSolveProblems/691ddf3d878122fcd4181dde0654f822 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/691ddf3d878122fcd4181dde0654f822 to your computer and use it in GitHub Desktop.
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