PyQt5:窗口大小根据屏幕大小自适应调整

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDesktopWidget     #导入屏幕类


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("mignri")
      #  MainWindow.setObjectName("窗口名称-小强")

        screen = QDesktopWidget().screenGeometry(); #获取屏幕大小
        width = screen.width();         #宽
        height = screen.height();        #窄
        MainWindow.resize(width/4, height/4)

PyQt5:窗口大小根据屏幕大小自适应调整_第1张图片

 

你可能感兴趣的:(qt,python,ui)