I have a UI I wrote that in which I place all my widgets in a list through a list comprehension. I had originally attempted to place everything in a dictionary comprehension so that everything would have a label.
widgets = [
QtGui.QLineEdit(),
QtGui.QSpinBox(),
QtGui.QLabel("-"),
QtGui.QSpinBox(),
QtGui.QPushButton("Export"),
QtGui.QPushButton("Del")
]
as opposed to
widgets = {
"textField":QtGui.QLineEdit(),
"minFrame":QtGui.QSpinBox(),
"dash":QtGui.QLabel("-"),
"maxFrame":QtGui.QSpinBox(),
"exportButton":QtGui.QPushButton("Export"),
"delButton":QtGui.QPushButton("Del")
}
My question here is why is it that when I implement the dictionary, the order of the elements seems to mix up. So when I loop through to add them to the layout like so:
for w in widgets: # or widgets.values() for the dic
mainLayout.addWidget(w)
It seems like the dictionary is slower to initialize all the objects than a list.