Advertisement
Guest User

main.py

a guest
Apr 4th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. from PyQt5.QtWidgets import QApplication, QMainWindow, QGraphicsScene, QDesktopWidget
  2. from PyQt5.QtCore import QRectF, Qt
  3. from ui import Ui_MainWindow
  4. import sys
  5.  
  6. class Window(Ui_MainWindow, QMainWindow):
  7.     def __init__(self):
  8.         super().__init__()
  9.         self.setupUi(self)
  10.  
  11.         self.wheight = self.height()
  12.         self.wwidth = self.width()
  13.  
  14.         self.scene = QGraphicsScene()
  15.         self.scene.setSceneRect(QRectF(0, 0, self.wwidth, self.wheight))
  16.         self.gv.setScene(self.scene)
  17.        
  18.         screen = QDesktopWidget().screenGeometry()
  19.         ww = int(screen.width() / 2)
  20.         wh = int(screen.height() / 2)
  21.  
  22.         self.resize(ww, wh)
  23.         self.show()
  24.  
  25.         self.gv.fitInView(0, 0, self.wwidth, self.wheight)
  26.  
  27.     def resizeEvent(self, e):
  28.         self.gv.fitInView(0, 0, self.wwidth, self.wheight)
  29.  
  30. def main():
  31.     app = QApplication(sys.argv)
  32.     w = Window()
  33.     w.show()
  34.     sys.exit(app.exec_())
  35.  
  36.  
  37. if __name__ == '__main__':
  38.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement