Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide2.QtWidgets import QWidget, QVBoxLayout, QPushButton, QApplication
- from PySide2.QtGui import QPainter, QImage
- import sys
- IMAGE_PATH = r"e:\Photos\Austria wekend\IMG_7259.JPG"
- class GameWindowDialog(QWidget):
- def __init__(self):
- super(GameWindowDialog, self).__init__()
- self.resize(500, 500)
- self.background_image = QImage(IMAGE_PATH)
- main_layout = QVBoxLayout(self)
- button = QPushButton("Click")
- main_layout.addWidget(button)
- def paintEvent(self, e):
- painter = QPainter()
- painter.begin(self)
- self.drawWidget(painter)
- painter.end()
- def drawWidget(self, painter):
- rect = self.rect()
- painter.drawImage(rect, self.background_image)
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- win = GameWindowDialog()
- win.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement