def __init__(self, source, column_order, parent=None): QTableWidget.__init__(self, parent) if parent: self.log = parent.parent().log self.setShowGrid(False) self.setSelectionBehavior(QAbstractItemView.SelectRows) # self.setDragDropMode(QAbstractItemView.DragDrop) self.setDragEnabled(True) self.setAcceptDrops(True) # self.setDragDropOverwriteMode(True) # self.setDropIndicatorShown(True) self.verticalHeader().hide() hdr = self.horizontalHeader() if QT_VER == 4: hdr.setResizeMode(QHeaderView.Interactive) else: hdr.setSectionResizeMode(QHeaderView.Interactive) # self.setDropIndicatorShown(True) self.source = source self.hidden_row = None self.empty_row = None self.state = uuid1() self.handle_drop = None self.rearrange = None self.keypress = None self.setColumnHeaders(column_order) self.show() self.source.set_table(self) if hasattr(source, 'sequence') and source.sequence: self._refresh()
def __init__(self, parent=None): QTableWidget.__init__(self, parent) self._cornerText = '' self._cornerButton = self.findChildren(QAbstractButton)[0] self._cornerButton.installEventFilter(self) self.setSelectionMode(QAbstractItemView.NoSelection)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: item = self.itemAt(event.pos()) if item: if QMessageBox.question(self, 'Remove data point', 'Do you ' 'really want to remove this data ' 'point?') == QMessageBox.Yes: event.accept() r = item.row() self.removeRow(r) self.pointRemove.emit(r) QTableWidget.mousePressEvent(self, event)
def __init__(self, parent, validator, curvalue, fmtstr, client, allow_enter=False): self._rows, self._cols = curvalue.shape self.validator = validator QTableWidget.__init__(self, self._rows, self._cols, parent) for i in range(self._rows): for j in range(self._cols): self.setItem(i, j, QTableWidgetItem(fmtstr % curvalue[i, j])) self.cellChanged.connect(lambda i, j: self.valueModified.emit())
def keypress(self, e): if e.key() == Qt.Key_Delete: ind = self.viewer.selectedIndexes()[0].row() self.delete(ind) else: QTableWidget.keyPressEvent(self.viewer, e)
def keyPressEvent(self, e): if self.keypress is not None: self.keypress(e) else: QTableWidget.keyPressEvent(self, e)
def __init__(self, parent=None): QTableWidget.__init__(self, parent)