0

I want to build this tag section from WordPress with pyqt

But I have two issues:

  1. I want to set widget in each row as much as possible!

  2. After I remove one item item it going to resize itself like it dose in WordPress!

enter image description here

The code:

    ...
    def btn_Tags(self,tagName):
        def Btn_tag_destroy(tag_objectName):
            for btns in self.groupBox.findChildren(QtWidgets.QPushButton):
                if btns.objectName() == tag_objectName:
                   btns.deleteLater()
                   self.tagList.remove(btns.text())
                   break

    # Buliding tags
    counter = len(self.tagList)
    btn_tag_tag =  QtWidgets.QPushButton(self.Frame_Tags) #QFrame
    btn_tag_tag.setObjectName(f'btn_tag_{counter}')
    btn_tag_tag.setText(tagName)
    btn_tag_tag.setStyleSheet('QPushButton{qproperty-icon: url(close.png);}')
    btn_tag_tag.clicked.connect(lambda: Btn_tag_destroy(f'btn_tag_{counter}'))

    # i did some stuff for geting 3x? grid format but its not what i want
    self.gridLayout.addWidget(btn_tag_tag,int((counter-1)/3),self.col) 
    self.col += 1 
    if self.col>2:
        self.col=0
Qasim
  • 83
  • 10
  • @eyllanesc tnx... the link you send its 150 complex line for just relayout, is there not any easier way (in my case) to doing this ??? – Qasim Aug 12 '21 at 14:48
  • Here in SO the concept of easy or difficult is irrelevant, here it is enough that the problem is solved. – eyllanesc Aug 12 '21 at 16:00

0 Answers0