Пример #1
0
    def data(self, index, role):
        if not index.isValid():
            return

        status = self.model_data[index.row()][self.get_column_index("status")]
        col = self.get_column_name(index.column())

        if role == Qt.BackgroundColorRole:
            color = QColor(*self.state_colors[status])
            color.setAlpha(color.alpha() / 2)
            if col == 'stdout' or col == 'stderr':
                color = QColor(100, 100, 100, 100)  # make items stand out
            return color

        if role != Qt.DisplayRole:
            return

        if self.get_column_name(index.column()).find("time") >= 0:
            if status == "Pending" or status == "Waiting":
                return

            timestamp = eval(self.model_data[index.row()][index.column()])
            return time.ctime(timestamp)

        if col == 'stdout' or col == 'stderr':
            return "OPEN"

        if col == 'current_memory_usage' or col == 'max_memory_usage':
            try:
                memory_usage = int(
                    self.model_data[index.row()][index.column()])
            except ValueError:
                return self.model_data[index.row()][index.column()]
            else:
                return SingleProgressModel._get_byte_with_unit(memory_usage)

        return self.model_data[index.row()][index.column()]
Пример #2
0
def color_from_qcolor(color: QColor) -> Color:
    """Convert :py:class:`PyQt5.QtGui.QColor` to :py:class:`.Color`"""
    return Color(color.red() / 255, color.green() / 255, color.blue() / 255, color.alpha() / 255)
 def on_color_picker_color_changed(color: QColor):
     for channel in self._controller.selected_channels:
         channel.color = (color.red() / 255, color.green() / 255,
                          color.blue() / 255, color.alpha() / 255)