本文整理汇总了Python中PyQt5.QtCore.Qt.TextAlignmentRole方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.TextAlignmentRole方法的具体用法?Python Qt.TextAlignmentRole怎么用?Python Qt.TextAlignmentRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.TextAlignmentRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role):
if index.isValid() or (0 <= index.row() < len(self.ListItemData)):
if role == Qt.DisplayRole:
return QVariant(self.ListItemData[index.row()]['name'])
elif role == Qt.DecorationRole:
return QVariant(QIcon(self.ListItemData[index.row()]['iconPath']))
elif role == Qt.SizeHintRole:
return QVariant(QSize(70,80))
elif role == Qt.TextAlignmentRole:
return QVariant(int(Qt.AlignHCenter|Qt.AlignVCenter))
elif role == Qt.FontRole:
font = QFont()
font.setPixelSize(20)
return QVariant(font)
else:
return QVariant()
示例2: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role = Qt.DisplayRole):
if not index.isValid():
return None
obj = self.getObject(index)
prop = self.getProperty(index)
if role == Qt.BackgroundRole:
return color(obj.D)
if role == Qt.TextAlignmentRole:
return Qt.AlignCenter
if (obj is None) or (prop is None):
return None
try:
if role in [Qt.DisplayRole, Qt.EditRole]:
return getAttrRecursive(obj, prop['attr'])
except:
return None
return None
示例3: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index: QModelIndex, role=Qt.DisplayRole):
i, j = index.row(), index.column()
if role == Qt.DisplayRole:
try:
lbl = self.message_type[i]
except IndexError:
return False
if j == 0:
return lbl.name
elif j == 1:
return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[0] + 1
elif j == 2:
return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[1]
elif j == 3:
return lbl.color_index
elif j == 4:
return lbl.apply_decoding
elif role == Qt.TextAlignmentRole:
return Qt.AlignCenter
else:
return None
示例4: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index: QModelIndex, role=None):
i = index.row()
j = index.column()
if role == Qt.DisplayRole:
if self.data is None:
return None
else:
if self.proto_view == 0:
return self.data[i][j]
elif self.proto_view == 1:
return "{0:x}".format(int(self.data[i][4 * j:4 * (j + 1)], 2))
elif self.proto_view == 2:
return chr(int(self.data[i][8 * j:8 * (j + 1)], 2))
elif role == Qt.FontRole:
if i == 0:
font = QFont()
font.setBold(True)
return font
elif role == Qt.TextAlignmentRole:
return Qt.AlignCenter
示例5: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role):
"""Re-implemented method to get the data for a given index and role"""
node = index.internalPointer()
parent = node.parent
if parent:
if role == Qt.DisplayRole and index.column() == 5:
return node.name
elif not parent and role == Qt.DisplayRole and index.column() == 5:
return node.var_list()
elif not parent and role == Qt.DisplayRole:
if index.column() == 0:
return node.id
if index.column() == 1:
return node.name
if index.column() == 2:
return str(node.period)
if role == Qt.TextAlignmentRole and \
(index.column() == 4 or index.column() == 3):
return Qt.AlignHCenter | Qt.AlignVCenter
return None
示例6: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role=Qt.DisplayRole):
'''The data stored under the given role for the item referred
to by the index.
Args:
index (:obj:`QtCore.QModelIndex`): Index
role (:obj:`Qt.ItemDataRole`): Default :obj:`Qt.DisplayRole`
Returns:
data
'''
if role == Qt.DisplayRole:
row = self._data[index.row()]
if (index.column() == 0) and (type(row) != dict):
return row
elif index.column() < self.columnCount():
if type(row) == dict:
if self.header[index.column()] in row:
return row[self.header[index.column()]]
elif self.header[index.column()].lower() in row:
return row[self.header[index.column()].lower()]
return row[index.column()]
return None
elif role == Qt.FontRole:
return QtGui.QFont().setPointSize(30)
elif role == Qt.DecorationRole and index.column() == 0:
return None
elif role == Qt.TextAlignmentRole:
return Qt.AlignLeft;
示例7: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def __init__(self, labels, parent=None):
super(TTable, self).__init__(parent)
self.labels = labels
self.setColumnCount(len(labels))
self.setHorizontalHeaderLabels(labels)
self.verticalHeader().hide()
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.horizontalHeader().model().setHeaderData(0, Qt.Horizontal,
Qt.AlignJustify, Qt.TextAlignmentRole)
self.horizontalHeader().setStretchLastSection(1)
self.setSelectionMode(QtWidgets.QTableView.SingleSelection)
self.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
示例8: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role=Qt.DisplayRole):
if index.isValid():
if role == Qt.DisplayRole or role == Qt.EditRole:
return self.rows[index.row()][index.column()]
elif role == Qt.TextAlignmentRole:
return Qt.AlignCenter
示例9: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def __init__(self, parent=None):
super(ScriptsTable, self).__init__(parent=parent)
self._scripts_model = QStandardItemModel(0, 6)
self._scripts_model.setHeaderData(0, Qt.Horizontal, 'Name')
self._scripts_model.setHeaderData(1, Qt.Horizontal, 'Author')
self._scripts_model.setHeaderData(1, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
self._scripts_model.setHeaderData(2, Qt.Horizontal, 'A')
self._scripts_model.setHeaderData(2, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
self._scripts_model.setHeaderData(3, Qt.Horizontal, 'I')
self._scripts_model.setHeaderData(3, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
self._scripts_model.setHeaderData(4, Qt.Horizontal, 'W')
self._scripts_model.setHeaderData(4, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
self._scripts_model.setHeaderData(5, Qt.Horizontal, 'Description')
self.setModel(self._scripts_model)
self.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(2, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(3, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(4, QHeaderView.ResizeToContents)
self.doubleClicked.connect(self._item_doubleclicked)
示例10: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def __init__(self, parent=None):
super(ThreadsWidget, self).__init__(parent=parent)
self._app_window = parent
self.dwarf = parent.dwarf
self.threads_model = QStandardItemModel(0, 3)
self.threads_model.setHeaderData(0, Qt.Horizontal, 'TID')
self.threads_model.setHeaderData(0, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
if self.dwarf.arch == 'ia32':
self.threads_model.setHeaderData(1, Qt.Horizontal, 'EIP')
elif self.dwarf.arch == 'x64':
self.threads_model.setHeaderData(1, Qt.Horizontal, 'RIP')
else:
self.threads_model.setHeaderData(1, Qt.Horizontal, 'PC')
self.threads_model.setHeaderData(1, Qt.Horizontal, Qt.AlignCenter,
Qt.TextAlignmentRole)
self.threads_model.setHeaderData(2, Qt.Horizontal, 'Symbol')
self.setModel(self.threads_model)
self.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(2, QHeaderView.ResizeToContents)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._on_context_menu)
self.doubleClicked.connect(self._item_double_clicked)
示例11: headerData
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.DisplayRole and orientation == Qt.Horizontal:
return self.header_labels[section]
elif role == Qt.TextAlignmentRole:
return Qt.AlignLeft
return super().headerData(section, orientation, role)
示例12: __role_to_str
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def __role_to_str(self, role):
if role == Qt.DisplayRole:
return "Display"
if role == Qt.BackgroundColorRole:
return "BG-Color"
if role == Qt.TextAlignmentRole:
return "Text-Alignment"
if role == Qt.TextColorRole:
return "TextColor"
if role == Qt.ToolTipRole:
return "ToolTip"
if role == Qt.FontRole:
return "Font"
示例13: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role=None):
if index.isValid():
col_idx = index.column()
row_idx = index.row()
if row_idx < len(self.utxos):
utxo = self.utxos[row_idx]
if utxo:
if role in (Qt.DisplayRole, Qt.EditRole):
col = self.col_by_index(col_idx)
if col:
field_name = col.name
if field_name == 'satoshis':
return app_utils.to_string(round(utxo.satoshis / 1e8, 8))
elif field_name == 'masternode':
if utxo.masternode:
return utxo.masternode.name
elif field_name == 'confirmations':
if utxo.block_height >= UNCONFIRMED_TX_BLOCK_HEIGHT:
return 'Unconfirmed'
else:
return app_utils.to_string(utxo.__getattribute__(field_name))
elif field_name == 'address':
if utxo.address_obj and utxo.address_obj.label:
return utxo.address_obj.label
else:
return utxo.address
elif col.name == 'txid':
if self.tx_explorer_url:
url = self.tx_explorer_url.replace('%TXID%', utxo.txid)
url = f'<a href="{url}">{utxo.txid}</a>'
return url
else:
return utxo.txid
else:
return app_utils.to_string(utxo.__getattribute__(field_name))
elif role == Qt.ForegroundRole:
if utxo.is_collateral:
return QColor(Qt.white)
elif utxo.coinbase_locked or utxo.block_height >= UNCONFIRMED_TX_BLOCK_HEIGHT:
return QColor('red')
elif role == Qt.BackgroundRole:
if utxo.is_collateral:
return QColor(Qt.red)
elif role == Qt.TextAlignmentRole:
col = self.col_by_index(col_idx)
if col:
if col.name in ('satoshis', 'confirmations', 'output_index'):
return Qt.AlignRight
return QVariant()
示例14: initUI
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def initUI(self):
self.documento = QTextDocument()
# =================== WIDGETS QPUSHBUTTON ==================
buttonBuscar = QPushButton("Buscar usuarios", self)
buttonBuscar.setFixedSize(426, 26)
buttonBuscar.move(20, 20)
buttonLimpiar = QPushButton("Limpiar tabla", self)
buttonLimpiar.setFixedSize(140, 26)
buttonLimpiar.move(452, 20)
# =================== WIDGET QTREEWIDGET ===================
self.treeWidgetUsuarios = QTreeWidget(self)
self.treeWidgetUsuarios.setFont(QFont(self.treeWidgetUsuarios.font().family(), 10, False))
self.treeWidgetUsuarios.setRootIsDecorated(False)
self.treeWidgetUsuarios.setHeaderLabels(("D.N.I", "NOMBRE", "APELLIDO", "FECHA DE NACIMIENTO"))
self.model = self.treeWidgetUsuarios.model()
for indice, ancho in enumerate((110, 150, 150, 160), start=0):
self.model.setHeaderData(indice, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
self.treeWidgetUsuarios.setColumnWidth(indice, ancho)
self.treeWidgetUsuarios.setAlternatingRowColors(True)
self.treeWidgetUsuarios.setFixedSize(572, 300)
self.treeWidgetUsuarios.move(20, 56)
# =================== WIDGETS QPUSHBUTTON ==================
buttonVistaPrevia = QPushButton("Vista previa", self)
buttonVistaPrevia.setFixedSize(140, 26)
buttonVistaPrevia.move(156, 364)
buttonImprimir = QPushButton("Imprimir", self)
buttonImprimir.setFixedSize(140, 26)
buttonImprimir.move(304, 364)
buttonExportarPDF = QPushButton("Exportar a PDF", self)
buttonExportarPDF.setFixedSize(140, 26)
buttonExportarPDF.move(452, 364)
# =================== EVENTOS QPUSHBUTTON ==================
buttonBuscar.clicked.connect(self.Buscar)
buttonLimpiar.clicked.connect(self.limpiarTabla)
buttonVistaPrevia.clicked.connect(self.vistaPrevia)
buttonImprimir.clicked.connect(self.Imprimir)
buttonExportarPDF.clicked.connect(self.exportarPDF)
# ======================= FUNCIONES ============================
示例15: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import TextAlignmentRole [as 别名]
def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return None
if not 0 <= index.row() < len(self.sub_signatures):
return None
if role == Qt.DisplayRole:
row = self.sub_signatures.values()[index.row()]
if row is None:
return None
((start_ea, end_ea, mask_options, custom), notes) = row
if index.column() == 0:
if None == start_ea:
return '-'
return '0x{0:08x}'.format(start_ea)
elif index.column() == 1:
if None == end_ea:
return '-'
return '0x{0:08x}'.format(end_ea)
elif index.column() == 2:
return notes
elif index.column() == 3:
if None != mask_options:
temp = Assembly(start_ea, end_ea)
temp.mask_opcodes_tuple(mask_options)
if None != custom:
temp.set_opcode_list(custom, True)
return ''.join(temp.get_opcode_list()).replace(' ', '')
return MiscAssembly.sub_signature_string(custom)
else:
return None
if role == Qt.FontRole:
return QtGui.QFont().setPointSize(30)
if role == Qt.DecorationRole and index.column() == 0:
return None
if role == Qt.TextAlignmentRole:
if index.column() < 2:
return Qt.AlignCenter;
return Qt.AlignLeft;