Why is this stacking ontop of each other, as far as the index should get each of them to next row.

data1 = {'PHOTOSHOP': '6.5', 'NUKE': '7.0v9', 'MAYA': '2014', 'TESTING': '1.28', 'KATANA': '1.7', 'MARI': '4.0'} 
data2 = {'PHOTOSHOP': '10.5', 'NUKE': '6.3v6', 'MAYA': '2012', 'TESTING': '1.28', 'KATANA': '1.0', 'MARI': '1.0'}

class MainWindow(QtGui.QWidget):
    """docstring for MainWindow"""
    def __init__(self, dataIn1, dataIn2):
        super(MainWindow, self).__init__()
        self._dataIn1 =  dataIn1
        self._dataIn2 = dataIn2
        x, y, w, h = 500, 200, 300, 400
        self.setGeometry(x, y, w, h)
        self.buildUI()

    def main(self):
        self.show()

    def buildUI(self):
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setSpacing(10)
        self.combos = []
        for index, (key, values) in enumerate(self._dataIn1.iteritems()):
            label = QtGui.QLabel(key, self)
            combo = QtGui.QComboBox(self)
            combo.addItem(values)
            combo.addItem(self._dataIn2[key])
            # self.combos.append(combo)
            setattr(self, 'combo%d' % index, combo)
            self.gridLayout.addWidget(label, index, 0)
            self.gridLayout.addWidget(combo, index, 2)

def main():
    app = QtGui.QApplication(sys.argv)
    smObj = MainWindow(dataIn1, dataIn2)
    smObj.main()
    app.exec_()

if __name__ == '__main__':
    main()

Recommended Answers

All 3 Replies

Reduce the width and height to minimal size maybe 10 by 10 and see if this still happens, it could just be that the boxs are overlaying because they are running over the eddge of the grid.

Sorry if this doesn't help i'm just starting with GUI in python

After your loop insert this line:
self.setLayout(self.gridLayout)

damn... all this time i was thinking i can only use it with QMainWindow..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.