Python GUI编程网 > QSS教程_QSS视频教程 > 外边距和内边距设置
python教程

外边距和内边距设置

发布日期:2021年4月21日 05:12
阅读:2074
作者:Python GUI编程网

外边距和内边距设置

00:00 / 01:23
1x
2x
1.5x
1.25x
1x
0.8x
0.5x

外边距和内边距设置

################################
# PyQt5中文网 - PyQt5全套视频教程 #
#    https://www.PyQt5.cn/     #
#         主讲: 村长            #
################################

from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("QSS-语法声明-外边距和内边距设置 - PyQt5中文网")
        self.resize(600, 500)
        self.func_list()

    def func_list(self):
        self.func()

    def func(self):
        label1 = QLabel('外边距和内边距设置', self)
        label1.resize(200, 200)

        '''外边距(px/em)
        margin
        margin-top
        margin-right
        margin-bottom
        margin-left
        
        QLabel{
            border-width:10px;
            border-color:red;
            border-style:solid;
            margin-top:10px;
            margin-left:100px;
            background-color:green;
        }
        '''

        '''内边距(px/em)
        padding
        padding-top
        padding-right
        padding-bottom
        padding-left
        
        QLabel{
            border-width:10px;
            border-color:red;
            border-style:solid;
            padding-bottom:10px;
            padding-right:100px;
            background-color:green;
        }
        '''

        pass




if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()

    with open('base5.qss', 'r', encoding='UTF-8') as f:
        qApp.setStyleSheet(f.read())

    window.show()
    sys.exit(app.exec_())