def get_window_center_point(widget): """ 使窗口居中显示 :param widget: 需要居中显示的窗口 :return: """ desktop_widget = QDesktopWidget() screen_rect = desktop_widget.screenGeometry() return (screen_rect.width()-widget.width()) / 2, (screen_rect.height()-widget.height()) / 2
def images_resize(self): geometry = QDesktopWidget.screenGeometry(QDesktopWidget()) width = geometry.width() height = geometry.height() for image in self.images.keys(): if image == 'road': continue if isinstance(self.images[image], list): for i in range(len(self.images[image])): wth = self.images[image][i].width() hgt = self.images[image][i].height() self.images[image][i] = self.images[image][i]\ .scaledToWidth((wth * width) / 1920) self.images[image][i] = self.images[image][i]\ .scaledToHeight((hgt * height) / 1080) else: wth = self.images[image].width() hgt = self.images[image].height() self.images[image] = self.images[image]\ .scaledToWidth((wth * width) / 1920) self.images[image] = self.images[image]\ .scaledToHeight((hgt * height) / 1080)