Esempio n. 1
0
File: prop.py Progetto: whigg/argos
    def _drawContents(self, currentRti=None):
        """ Draws the attributes of the currentRTI
        """
        table = self.table
        table.setUpdatesEnabled(False)
        try:
            table.clearContents()
            verticalHeader = table.verticalHeader()
            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)

            if currentRti is None:
                return

            # Each column in the repo tree corresponds to a row in this detail pane.
            repoModel = self._repoTreeView.model()
            propNames = RepoTreeModel.HEADERS
            table.setRowCount(len(propNames))

            for row, propName in enumerate(propNames):
                nameItem = QtWidgets.QTableWidgetItem(propName)
                nameItem.setToolTip(propName)
                table.setItem(row, self.COL_PROP_NAME, nameItem)
                propValue = repoModel.itemData(currentRti, row)
                propItem = QtWidgets.QTableWidgetItem(propValue)
                propItem.setToolTip(propValue)
                table.setItem(row, self.COL_VALUE, propItem)
                table.resizeRowToContents(row)

            verticalHeader.setSectionResizeMode(
                QtWidgets.QHeaderView.ResizeToContents)

        finally:
            table.setUpdatesEnabled(True)
Esempio n. 2
0
File: attr.py Progetto: xyt556/argos
    def _drawContents(self, currentRti=None):
        """ Draws the attributes of the currentRTI
        """
        #logger.debug("_drawContents: {}".format(currentRti))
        table = self.table
        table.setUpdatesEnabled(False)
        try:
            table.clearContents()
            verticalHeader = table.verticalHeader()
            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)

            attributes = currentRti.attributes if currentRti is not None else {}
            table.setRowCount(len(attributes))

            for row, (attrName,
                      attrValue) in enumerate(sorted(attributes.items())):
                attrStr = to_string(attrValue, decode_bytes='utf-8')

                try:
                    type_str = type_name(attrValue)
                except Exception as ex:
                    logger.exception(ex)
                    type_str = "<???>"

                nameItem = QtWidgets.QTableWidgetItem(attrName)
                nameItem.setToolTip(attrName)
                table.setItem(row, self.COL_ATTR_NAME, nameItem)
                valItem = QtWidgets.QTableWidgetItem(attrStr)
                valItem.setToolTip(attrStr)
                table.setItem(row, self.COL_VALUE, valItem)
                table.setItem(row, self.COL_ELEM_TYPE,
                              QtWidgets.QTableWidgetItem(type_str))
                table.resizeRowToContents(row)

            verticalHeader.setSectionResizeMode(
                QtWidgets.QHeaderView.ResizeToContents)

        finally:
            table.setUpdatesEnabled(True)
Esempio n. 3
0
    def _drawContents(self, currentRti=None):
        """ Draws the attributes of the currentRTI
        """
        table = self.table
        table.setUpdatesEnabled(False)

        sizeAlignment = Qt.AlignRight | Qt.AlignVCenter

        try:
            table.clearContents()
            verticalHeader = table.verticalHeader()
            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)

            if currentRti is None or not currentRti.isSliceable:
                return

            nDims = currentRti.nDims
            dimNames = currentRti.dimensionNames
            dimGroups = currentRti.dimensionGroupPaths
            dimSizes = currentRti.arrayShape

            # Sanity check
            assert len(dimNames) == nDims, "dimNames size {} != {}".format(len(dimNames), nDims)
            assert len(dimGroups) == nDims, "dimGroups size {} != {}".format(len(dimGroups), nDims)
            assert len(dimSizes) == nDims, "dimSizes size {} != {}".format(len(dimSizes), nDims)

            table.setRowCount(nDims)
            for row, (dimName, dimSize, dimGroup) in enumerate(zip(dimNames, dimSizes, dimGroups)):
                table.setItem(row, self.COL_NAME, QtWidgets.QTableWidgetItem(dimName))
                table.setItem(row, self.COL_SIZE, QtWidgets.QTableWidgetItem(str(dimSize)))
                table.item(row, self.COL_SIZE).setTextAlignment(sizeAlignment)
                table.setItem(row, self.COL_GROUP, QtWidgets.QTableWidgetItem(str(dimGroup)))
                table.resizeRowToContents(row)

            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

        finally:
            table.setUpdatesEnabled(True)