def set_image(self, image: QImage) -> None: """Sets the background image for self :param image: image to set as background of self """ self.__scene.clear() self.__word_polygons = [] screen_res = QDesktopWidget().screenGeometry() image = image.scaled(screen_res.width() * 0.75, screen_res.height() * 0.75, Qt.KeepAspectRatio) bg = QGraphicsPixmapItem(QPixmap(image)) self.setFixedSize(image.width(), image.height()) self.__currentImage = image self.__scene.addItem(bg)
def initUI(self): centralWidget = QWidget() self.setCentralWidget(centralWidget) self.setWindowTitle(self._gameBoard.name) self.setWindowIcon(QIcon(os.path.join('./Pictures/', 'berserker_icon.png'))) #Apparently this doens't work the same way on a mac. self.statusBar().showMessage('Ready!') vbox = QVBoxLayout() centralWidget.setLayout(vbox) self.gameStats = GameStats(self) self.mapView = MapView(self) self.bottomButtons = BottomButtons(self) vbox.addWidget(self.gameStats) vbox.addWidget(self.mapView) vbox.addWidget(self.bottomButtons) screen = QDesktopWidget().screenGeometry() self.setGeometry((screen.width() - (self.gameboard.width - 1) * 20) / 2, (screen.height() - self.gameboard.height * 20 - 200) / 2, 500, 400) self.show()
def initUI(self): centralWidget = QWidget() self.setCentralWidget(centralWidget) self.setWindowTitle(self._gameBoard.name) self.setWindowIcon( QIcon(os.path.join('./Pictures/', 'berserker_icon.png')) ) #Apparently this doens't work the same way on a mac. self.statusBar().showMessage('Ready!') vbox = QVBoxLayout() centralWidget.setLayout(vbox) self.gameStats = GameStats(self) self.mapView = MapView(self) self.bottomButtons = BottomButtons(self) vbox.addWidget(self.gameStats) vbox.addWidget(self.mapView) vbox.addWidget(self.bottomButtons) screen = QDesktopWidget().screenGeometry() self.setGeometry( (screen.width() - (self.gameboard.width - 1) * 20) / 2, (screen.height() - self.gameboard.height * 20 - 200) / 2, 500, 400) self.show()
def CenterOnScreen(self): '''alinhando a o formulario no centro da tela''' resolucao = QDesktopWidget().screenGeometry() self.move((resolucao.width() / 2) - (self.frameSize().width() / 2), (resolucao.height() / 2) - (self.frameSize().height() / 2))