def __init__(self, params, parent=None): super(ParametersEditorDialog, self).__init__(parent) self.params = params self.resize(600, 350) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint) self.setWindowTitle('Edit widget parameters') layout = QtGui.QVBoxLayout() buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) self.tree = QtGui.QTreeWidget() layout.addWidget(self.tree) layout.addWidget(buttonBox) self.setLayout(layout) self.mainItem = QtGui.QTreeWidgetItem() self.mainItem.setText(0, "Parameters") for name, value in params.iteritems(): subitem = TreeSettingItem(self.mainItem, self.tree, name, value) self.mainItem.addChild(subitem) self.tree.addTopLevelItem(self.mainItem) self.mainItem.sortChildren(0, QtCore.Qt.AscendingOrder) self.tree.expandAll() self.tree.headerItem().setText(0, "Parameter") self.tree.headerItem().setText(1, "Value") self.tree.resizeColumnToContents(0) self.tree.resizeColumnToContents(1) buttonBox.accepted.connect(self.okPressed) buttonBox.rejected.connect(self.cancelPressed)
def populateConfigParams(self): self.settingsItems = defaultdict(dict) item = QTreeWidgetItem() item.setText(0, "Settings") for param, value in settings.appSettings.iteritems(): subitem = TreeSettingItem(item, self.settingsTree, param, value) item.addChild(subitem) self.settingsItems[param] = subitem self.settingsTree.addTopLevelItem(item) item.sortChildren(0, Qt.AscendingOrder) self.settingsTree.expandAll() self.settingsTree.resizeColumnToContents(0) self.settingsTree.resizeColumnToContents(1)