02.PyQt5的位置及尺寸及内容边框设置

位置尺寸设置

from PyQt5.Qt import *
import sys
class App(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('app')
        # self.resize(500,500)
        # self.move(0,0)
        self.setGeometry(0,0,300,300)
        self.setMinimumSize(250,250)
        self.setMaximumSize(500,500)
if __name__ == '__main__':
    app=QApplication(sys.argv)
    window=App()
    window.show()
    sys.exit(app.exec_())

内容边框设置

from PyQt5.Qt import *
import sys
class App(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('app')
        # self.resize(500,500)
        # self.move(0,0)
        self.setGeometry(0,0,300,300)
        self.setMinimumSize(250,250)
        self.setMaximumSize(500,500)
        self.label()
    def label(self):
        label = QLabel(self)
        label.resize(200, 200)
        label.move(50, 50)
        label.setStyleSheet('border:1px solid #cfcfcf')
        label.setContentsMargins(50, 50, 50, 50)
        label.setText('contents')
if __name__ == '__main__':
    app=QApplication(sys.argv)
    window=App()
    window.show()
    sys.exit(app.exec_())

你可能感兴趣的:(Python,pyqt5)