views:

10

answers:

0

I have a subclassed QFrame that generates a list of buttons when my project loads, and at times, I want to be able to completely destroy and rebuild "buttonGrid".

Rather than add a button in the proper spot with the proper geometry settings etc. I figured it'd be easiest to destroy this and then call it again as it was originally one. The question whose answer has eluded me for some time now is how can I destroy this so that it may be called again?

Class

class buttonGrid(QtGui.QFrame):    
    def __init__(self, items, colCount, parent):
        super(buttonGrid, self).__init__(parent)

        # Create a grid layout.
        layout = QtGui.QGridLayout()
        self.setLayout(layout)

        for cnt, item in enumerate(items):
            layout.addWidget(item, cnt / colCount, cnt % colCount)

Caller

x = buttonGrid(listOfButtons, columnCount, self)

Thanks.