本文整理汇总了Python中PyQt5.QtCore.Qt.UserRole方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.UserRole方法的具体用法?Python Qt.UserRole怎么用?Python Qt.UserRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.UserRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def __init__(self, parent = None) -> None:
super().__init__(parent)
self._metadata = None # type: Optional[List[Dict[str, Union[str, List[str], int]]]]
self.addRoleName(Qt.UserRole + 1, "id")
self.addRoleName(Qt.UserRole + 2, "name")
self.addRoleName(Qt.UserRole + 3, "email")
self.addRoleName(Qt.UserRole + 4, "website")
self.addRoleName(Qt.UserRole + 5, "package_count")
self.addRoleName(Qt.UserRole + 6, "package_types")
self.addRoleName(Qt.UserRole + 7, "icon_url")
self.addRoleName(Qt.UserRole + 8, "description")
# List of filters for queries. The result is the union of the each list of results.
self._filter = {} # type: Dict[str, str]
示例2: _update_data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def _update_data(self, data_info):
sorted_keys = list(sorted(data_info.get_map_names()))
if len(data_info.get_map_names()):
self.general_info_nmr_maps.setText(str(len(data_info.get_map_names())))
else:
self.general_info_nmr_maps.setText('0')
with blocked_signals(self.general_map_selection):
self.general_map_selection.clear()
self.general_map_selection.addItems(sorted_keys)
for index, map_name in enumerate(sorted_keys):
item = self.general_map_selection.item(index)
item.setData(Qt.UserRole, map_name)
with blocked_signals(self.mask_name):
self.mask_name.clear()
self.mask_name.insertItem(0, '-- None --')
self.mask_name.insertItems(1, sorted_keys)
示例3: onAdvScanUpdateSSIDs
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def onAdvScanUpdateSSIDs(self, wirelessNetworks):
rowPosition = self.networkTable.rowCount()
if rowPosition > 0:
# Range goes to last # - 1
for curRow in range(0, rowPosition):
try:
curData = self.networkTable.item(curRow, 2).data(Qt.UserRole+1)
except:
curData = None
if (curData):
# We already have the network. just update it
for curKey in wirelessNetworks.keys():
curNet = wirelessNetworks[curKey]
if (curData.macAddr == curNet.macAddr) and (curData.channel == curNet.channel):
# See if we had an unknown SSID
if curData.ssid.startswith('<Unknown') and (not curNet.ssid.startswith('<Unknown')):
curData.ssid = curNet.ssid
self.networkTable.item(curRow, 2).setText(curData.ssid)
curSeries = self.networkTable.item(curRow, 2).data(Qt.UserRole)
curSeries.setName(curData.ssid)
示例4: onCopyNet
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def onCopyNet(self):
self.updateLock.acquire()
curRow = self.networkTable.currentRow()
curCol = self.networkTable.currentColumn()
if curRow == -1 or curCol == -1:
self.updateLock.release()
return
if curCol != 11:
curText = self.networkTable.item(curRow, curCol).text()
else:
curNet = self.networkTable.item(curRow, 2).data(Qt.UserRole+1)
curText = 'Last Recorded GPS Coordinates:\n' + str(curNet.gps)
curText += 'Strongest Signal Coordinates:\n'
curText += 'Strongest Signal: ' + str(curNet.strongestsignal) + '\n'
curText += str(curNet.strongestgps)
clipboard = QApplication.clipboard()
clipboard.setText(curText)
self.updateLock.release()
示例5: onDeleteNet
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def onDeleteNet(self):
self.updateLock.acquire()
curRow = self.networkTable.currentRow()
if curRow == -1:
self.updateLock.release()
return
curNet = self.networkTable.item(curRow, 2).data(Qt.UserRole+1)
curSeries = self.networkTable.item(curRow, 2).data(Qt.UserRole)
if curNet and curSeries:
if (curNet.channel < 15):
self.chart24.removeSeries(curSeries)
else:
self.chart5.removeSeries(curSeries)
self.networkTable.removeRow(curRow)
self.updateLock.release()
示例6: get_item
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def get_item(self, path: List[str], item_name: str):
parents = [None]
for i, name in enumerate(path + [item_name]):
parent_model = self if i == 0 else parents[-1]
items = self.findItems(name, Qt.MatchExactly | Qt.MatchRecursive)
target_item = None
if not items: # create new item if it does not exist
target_item = self._create_item(parent_model, name, {Qt.UserRole: "", Qt.UserRole+1: ""})
else:
for item in items: # check found items with corresponding parent
if item.parent() == parents[-1]:
target_item = item
if target_item is None:
target_item = self._create_item(parent_model, name, {Qt.UserRole: "", Qt.UserRole + 1: ""})
parents.append(target_item)
return parents[-1]
示例7: data
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def data(self, qindex:QModelIndex, role=None):
if role == Qt.DisplayRole or role == Qt.EditRole:
entry = self.entries[qindex.row()]
attr = self.columns[qindex.column()]
value = getattr(entry, attr)
if attr in ("gmd_name_index", "gmd_description_index"):
return get_t9n(self.model, "t9n", value)
elif attr == "kire_id":
kire_model = self.model.get_relation_data("kire")
if kire_model is None:
return None
else:
return kire_model.entries[value]
return value
elif role == Qt.UserRole:
entry = self.entries[qindex.row()]
return entry
示例8: prompt_extractor
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def prompt_extractor(self, item):
extractor = extractors[item.data(Qt.UserRole)]
inputs = []
if not assert_installed(self.view, **extractor.get('depends', {})):
return
if not extractor.get('pick_url', False):
files, mime = QFileDialog.getOpenFileNames()
for path in files:
inputs.append((path, Path(path).stem))
else:
text, good = QInputDialog.getText(self.view, ' ', 'Input an URL:')
if text:
url = urlparse(text)
inputs.append((url.geturl(), url.netloc))
if inputs:
wait = QProgressDialog('Extracting .proto structures...', None, 0, 0)
wait.setWindowTitle(' ')
self.set_view(wait)
self.worker = Worker(inputs, extractor)
self.worker.progress.connect(self.extraction_progress)
self.worker.finished.connect(self.extraction_done)
self.worker.start()
示例9: _settings_str
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def _settings_str(self):
"""Returns a human readable settings representation for logging purposes."""
settings = "Automatically save changes: {}, " \
"Show tray icon: {}, " \
"Allow keyboard navigation: {}, " \
"Sort by usage count: {}, " \
"Enable undo using backspace: {}, " \
"Tray icon theme: {}, " \
"Disable Capslock: {}".format(
self.autosave_checkbox.isChecked(),
self.show_tray_checkbox.isChecked(),
self.allow_kb_nav_checkbox.isChecked(),
self.sort_by_usage_checkbox.isChecked(),
self.enable_undo_checkbox.isChecked(),
self.system_tray_icon_theme_combobox.currentData(Qt.UserRole),
self.disable_capslock_checkbox.isChecked()
)
return settings
示例10: _on_modify_condition
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def _on_modify_condition(self, num_row):
item = self._breakpoints_model.item(num_row, 2)
data = item.data(Qt.UserRole + 2)
if data is None:
data = ''
ptr = self._breakpoints_model.item(num_row, 0).text()
accept, input_ = InputMultilineDialog().input(
'Condition for breakpoint %s' % ptr, input_content=data)
if accept:
what = utils.parse_ptr(ptr)
if what == 0:
what = self._breakpoints_model.item(num_row, 2).data(Qt.UserRole + 2)
if self._app_window.dwarf.dwarf_api('setBreakpointCondition', [what, input_.replace('\n', '')]):
item.setData(input_, Qt.UserRole + 2)
if not item.text():
item.setText('ƒ')
item.setToolTip(input_)
self.onBreakpointChanged.emit(ptr)
# + button
示例11: _on_native_contextmenu
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def _on_native_contextmenu(self, pos):
index = self._nativectx_list.indexAt(pos).row()
glbl_pt = self._nativectx_list.mapToGlobal(pos)
context_menu = QMenu(self)
if index != -1:
item = self._nativectx_model.item(index, 1)
dec = self._nativectx_model.item(index, 2)
telescope = self._nativectx_model.item(index, 3)
# show contextmenu
if self._nativectx_model.item(index, 0).data(Qt.UserRole + 1):
context_menu.addAction('Jump to {0}'.format(item.text()), lambda: self._app_window.jump_to_address(item.text()))
context_menu.addSeparator()
# copy menu
context_sub_menu = QMenu('Copy', context_menu)
context_sub_menu.addAction('Value', lambda: utils.copy_str_to_clipboard(item.text()))
if dec.text():
context_sub_menu.addAction('Decimal', lambda: utils.copy_str_to_clipboard(dec.text()))
if telescope.text():
context_sub_menu.addAction('Telescope', lambda: utils.copy_str_to_clipboard(telescope.text()))
context_menu.addMenu(context_sub_menu)
context_menu.exec_(glbl_pt)
示例12: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def __init__(self, parent = None):
super().__init__(parent)
self.addRoleName(Qt.UserRole + 1, "name")
self.addRoleName(Qt.UserRole + 2, "brand")
self.addRoleName(Qt.UserRole + 3, "colors")
示例13: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def __init__(self, parent = None):
super().__init__(parent)
self._metadata = None
self.addRoleName(Qt.UserRole + 1, "id")
self.addRoleName(Qt.UserRole + 2, "type")
self.addRoleName(Qt.UserRole + 3, "name")
self.addRoleName(Qt.UserRole + 4, "version")
self.addRoleName(Qt.UserRole + 5, "author_id")
self.addRoleName(Qt.UserRole + 6, "author_name")
self.addRoleName(Qt.UserRole + 7, "author_email")
self.addRoleName(Qt.UserRole + 8, "description")
self.addRoleName(Qt.UserRole + 9, "icon_url")
self.addRoleName(Qt.UserRole + 10, "image_urls")
self.addRoleName(Qt.UserRole + 11, "download_url")
self.addRoleName(Qt.UserRole + 12, "last_updated")
self.addRoleName(Qt.UserRole + 13, "is_bundled")
self.addRoleName(Qt.UserRole + 14, "is_active")
self.addRoleName(Qt.UserRole + 15, "is_installed") # Scheduled pkgs are included in the model but should not be marked as actually installed
self.addRoleName(Qt.UserRole + 16, "has_configs")
self.addRoleName(Qt.UserRole + 17, "supported_configs")
self.addRoleName(Qt.UserRole + 18, "download_count")
self.addRoleName(Qt.UserRole + 19, "tags")
self.addRoleName(Qt.UserRole + 20, "links")
self.addRoleName(Qt.UserRole + 21, "website")
self.addRoleName(Qt.UserRole + 22, "login_required")
self.addRoleName(Qt.UserRole + 23, "average_rating")
self.addRoleName(Qt.UserRole + 24, "num_ratings")
self.addRoleName(Qt.UserRole + 25, "user_rating")
# List of filters for queries. The result is the union of the each list of results.
self._filter = {} # type: Dict[str, str]
示例14: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def __init__(self, parent = None):
super().__init__(parent)
self._configs = None
self.addRoleName(Qt.UserRole + 1, "machine")
self.addRoleName(Qt.UserRole + 2, "print_core")
self.addRoleName(Qt.UserRole + 3, "build_plate")
self.addRoleName(Qt.UserRole + 4, "support_material")
self.addRoleName(Qt.UserRole + 5, "quality")
示例15: paint
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import UserRole [as 别名]
def paint(self, painter, option, idx):
new_idx = idx.sibling(idx.row(), 0)
item = self.model.itemFromIndex(new_idx)
if item and item.data(Qt.UserRole) in self.added_node_list:
option.font.setWeight(QFont.Bold)
QStyledItemDelegate.paint(self, painter, option, idx)