Guest User

Untitled

a guest
Jul 22nd, 2019
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. from PyQt5.QtCore import QTimer, Qt
  6. from PyQt5.QtGui import QPixmap, QPainter, QPen, QColor, QBrush
  7. from PyQt5.QtWidgets import (QWidget, QComboBox, QApplication, QPushButton, QLineEdit, QListWidget, QFileDialog,
  8. QTextEdit, QDesktopWidget, QGroupBox, QHBoxLayout, QVBoxLayout, QLabel)
  9.  
  10.  
  11. class Test(QWidget):
  12. def __init__(self):
  13. super().__init__()
  14. self.state = None
  15. self.initUI()
  16.  
  17. def initUI(self):
  18. pixmap = QPixmap("file_name.png")
  19. lbl = QLabel(self, alignment=Qt.AlignHCenter)
  20. lbl.setScaledContents(True)
  21. lbl.setPixmap(pixmap)
  22.  
  23. hbox = QHBoxLayout()
  24. hbox.addWidget(lbl)
  25.  
  26. vbox = QVBoxLayout(self)
  27. vbox.addLayout(hbox)
  28. vbox.addStretch()
  29. self.setLayout(vbox)
  30.  
  31. self.setWindowTitle("test")
  32. self.setFixedSize(1200, 1000)
  33. self.show()
  34.  
  35. def paintEvent(self, e):
  36. self.qp = QPainter()
  37. self.qp.begin(self)
  38. self.qp.setRenderHint(QPainter.Antialiasing)
  39. self.qp.setPen((QPen(QColor("green"))))
  40. self.qp.drawEllipse(100, 100, 30, 30)
  41. self.qp.end()
  42.  
  43.  
  44. if __name__ == '__main__':
  45. app = QApplication(sys.argv)
  46. ex = Test()
  47. sys.exit(app.exec_())
RAW Paste Data