Ejemplo n.º 1
0
 def init_page(self, page_count):
     while self.layer.count():
         self.layer.itemAt(0).widget().setParent(None)
     self.btn_lis.clear()
     for i in range(1, page_count + 1):
         btn = CommonBtn(str(i), self)
         btn.setFixedSize(46, 36)
         btn.clicked.connect(self.click_page_btn)
         if i == 1:
             btn.setProperty('class', 'active')
         self.btn_lis.append(btn)
         self.layer.addWidget(btn)
     self.top.set_qss.emit()
Ejemplo n.º 2
0
    def __init__(self, parent, top):
        super().__init__(top)
        self.parent = parent
        self.top = top
        self.i = 0
        self.setWindowTitle('选择头像')
        self.setObjectName('choose-avatar')

        layer = qt.QGridLayout()

        lis = listdir('./static/avatar/')
        self.avatar_lis = []
        for i in range(len(lis) - 1):
            avatar = CommonBtn(self)
            avatar.i = i + 1
            avatar.setProperty('class', 'avatar')
            avatar.setFixedSize(74, 74)
            avatar.setIcon(qt.QIcon(f'./static/avatar/{i+1}.png'))
            avatar.setIconSize(qt.QSize(70, 70))
            avatar.clicked.connect(self.click_avatar)
            self.avatar_lis.append(avatar)
            layer.addWidget(avatar, i // 4, i % 4)
        self.setLayout(layer)