Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QApplication, QMainWindow, QGraphicsScene, QDesktopWidget
- from PyQt5.QtCore import QRectF, Qt
- from ui import Ui_MainWindow
- import sys
- class Window(Ui_MainWindow, QMainWindow):
- def __init__(self):
- super().__init__()
- self.setupUi(self)
- self.wheight = self.height()
- self.wwidth = self.width()
- self.scene = QGraphicsScene()
- self.scene.setSceneRect(QRectF(0, 0, self.wwidth, self.wheight))
- self.gv.setScene(self.scene)
- screen = QDesktopWidget().screenGeometry()
- ww = int(screen.width() / 2)
- wh = int(screen.height() / 2)
- self.resize(ww, wh)
- self.show()
- self.gv.fitInView(0, 0, self.wwidth, self.wheight)
- def resizeEvent(self, e):
- self.gv.fitInView(0, 0, self.wwidth, self.wheight)
- def main():
- app = QApplication(sys.argv)
- w = Window()
- w.show()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement