def init_ui(self): """ Initialize the actual UI :return: """ # Main window desktop = QDesktopWidget() screen_width = desktop.screen().width() screen_height = desktop.screen().height() app_width = 505 app_height = 400 self.setWindowTitle('Stellaris Profile Manager') self.setGeometry( # this centers the window (screen_width / 2) - (app_width / 2), (screen_height / 2) - (app_height / 2), app_width, app_height ) self.setFixedSize(self.size()) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # elements self.create_list_of_profiles() self.create_launch_button() self.create_new_profile_button() self.create_edit_profile_button() self.create_delete_profile_button() self.create_import_profile_button() self.create_export_profile_button() self.create_find_steam_button() self.create_path_to_steam_input() self.create_game_version()
def init_ui(self): """ Initialize the actual UI :return: """ # Main window desktop = QDesktopWidget() screen_width = desktop.screen().width() screen_height = desktop.screen().height() app_width = 450 app_height = 420 self.setWindowTitle('Stellaris Profile Manager') self.setGeometry( # this centers the window (screen_width / 2) - (app_width / 2), (screen_height / 2) - (app_height / 2), app_width, app_height ) self.setFixedSize(self.size()) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # elements self.create_profile_name_input() self.create_list_of_mods() self.create_save_button() self.create_cancel_button() self.create_reload_mods_button()
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 init_ui(self): """ Initialize the actual UI :return: """ # Main window desktop = QDesktopWidget() screen_width = desktop.screen().width() screen_height = desktop.screen().height() app_width = 450 app_height = 375 self.setWindowTitle('Import profile') self.setGeometry( # this centers the window (screen_width / 2) - (app_width / 2), (screen_height / 2) - (app_height / 2), app_width, app_height) self.setFixedSize(self.size()) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # elements self.create_list_of_profiles() self.create_import_button()
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 center(self): # функция отцентровывает окно относительно окна qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
def center(self): qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
def move_window_to_center(self): qreact = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qreact.moveCenter(cp) self.move(qreact.topLeft())
def showCentered(self): rectSpe = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() rectSpe.moveCenter(centerPoint) self.move(rectSpe.topLeft())