def __init__(self, names=[], N=10, *args, **kwargs): """ Parameters ---------- %(ColormapModel.parameters)s Other Parameters ---------------- ``*args, **kwargs`` Anything else that is passed to the ColormapDialog """ super(QDialog, self).__init__(*args, **kwargs) vbox = QVBoxLayout() self.table = ColormapTable(names=names, N=N) vbox.addWidget(self.table) self.setLayout(vbox) col_width = self.table.columnWidth(0) header_width = self.table.verticalHeader().width() row_height = self.table.rowHeight(0) available = QDesktopWidget().availableGeometry() height = int(min(row_height * (self.table.rowCount() + 1), 2. * available.height() / 3.)) width = int(min(header_width + col_width * N + 0.5 * col_width, 2. * available.width() / 3.)) self.resize(QtCore.QSize(width, height))
def add_page(self, widget): """Add a new page to the preferences dialog Parameters ---------- widget: ConfigPage The page to add""" widget.validChanged.connect(self.bt_apply.setEnabled) widget.validChanged.connect( self.bbox.button(QDialogButtonBox.Ok).setEnabled) scrollarea = QScrollArea(self) scrollarea.setWidgetResizable(True) scrollarea.setWidget(widget) self.pages_widget.addWidget(scrollarea) item = QListWidgetItem(self.contents_widget) try: item.setIcon(widget.icon) except TypeError: pass item.setText(widget.title) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) item.setSizeHint(QtCore.QSize(0, 25)) widget.propose_changes.connect(self.check_changes)
def sizeHint(self): """Reimplemented to use the rowHeight as height""" s = super(ColorLabel, self).sizeHint() return QtCore.QSize(s.width(), self.rowHeight(0) * self.rowCount())
def sizeHint(self): header = self.horizontalHeader().sizeHint().height() s = super(PlotControlTable, self).sizeHint() return QtCore.QSize(s.width(), self.rowHeight(0) * self.rowCount() + header)