我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.lightGray()。
def _update_table_view(self): all_column_names, real_column_names, estimated_column_names, system_column_names = self._get_column_names() self.protocol_table.clear() self.protocol_table.setRowCount(self._protocol.length) self.protocol_table.setColumnCount(len(all_column_names)) for index, column_name in enumerate(all_column_names): header_cell = QTableWidgetItem(column_name) if column_name in estimated_column_names: header_cell.setToolTip('This column is estimated from the other columns in the protocol.') self.protocol_table.setHorizontalHeaderItem(index, header_cell) for column_ind, column_name in enumerate(all_column_names): if column_name in system_column_names: generate_function = self._system_columns[column_name] cells = generate_function() for row, cell in enumerate(cells): self.protocol_table.setItem(row, column_ind, cell) else: try: values = self._protocol.get_column(column_name) for row in range(self._protocol.length): cell = NumericalSortedTableItem('{:e}'.format(values[row, 0])) cell.setFlags(QtCore.Qt.ItemIsEnabled) if column_name in estimated_column_names: cell.setBackground(QBrush(Qt.lightGray)) self.protocol_table.setItem(row, column_ind, cell) except KeyError: for row in range(self._protocol.length): cell = QTableWidgetItem('?') cell.setFlags(QtCore.Qt.ItemIsEnabled) cell.setBackground(QBrush(Qt.lightGray)) self.protocol_table.setItem(row, column_ind, cell) self.protocol_table.resizeColumnsToContents()
def _create_volume_number_column(self): """Callback function to generate the volume number column cells. This should return a list of cells in the correct order. """ cells = [] for volume_nmr in range(self._protocol.length): cell = NumericalSortedTableItem(str(volume_nmr)) cell.setFlags(QtCore.Qt.ItemIsEnabled) cell.setBackground(QBrush(Qt.lightGray)) cells.append(cell) return cells
def __init__(self, parent=None): super(XmlSyntaxHighlighter, self).__init__(parent) self.highlightingRules = [] # Tag format. format = QTextCharFormat() format.setForeground(Qt.darkBlue) format.setFontWeight(QFont.Bold) pattern = QRegExp("(<[a-zA-Z:]+\\b|<\\?[a-zA-Z:]+\\b|\\?>|>|/>|</[a-zA-Z:]+>)") self.highlightingRules.append((pattern, format)) # Attribute format. format = QTextCharFormat() format.setForeground(Qt.darkGreen) pattern = QRegExp("[a-zA-Z:]+=") self.highlightingRules.append((pattern, format)) # Attribute content format. format = QTextCharFormat() format.setForeground(Qt.red) pattern = QRegExp("(\"[^\"]*\"|'[^']*')") self.highlightingRules.append((pattern, format)) # Comment format. self.commentFormat = QTextCharFormat() self.commentFormat.setForeground(Qt.lightGray) self.commentFormat.setFontItalic(True) self.commentStartExpression = QRegExp("<!--") self.commentEndExpression = QRegExp("-->")