本文整理汇总了Python中AnyQt.QtWidgets.QAction.actionGroup方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.actionGroup方法的具体用法?Python QAction.actionGroup怎么用?Python QAction.actionGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.actionGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DiscreteVariableEditor
# 需要导入模块: from AnyQt.QtWidgets import QAction [as 别名]
# 或者: from AnyQt.QtWidgets.QAction import actionGroup [as 别名]
#.........这里部分代码省略.........
SourceNameRole: ci
}
elif ci is not None and cj is not None:
# rename or reorder
item = {
Qt.EditRole: cj,
EditStateRole: ItemEditState.NoState,
SourcePosRole: ci_index[ci],
SourceNameRole: ci
}
else:
assert False, "invalid mapping: {!r}".format(tr.mapping)
items.append(item)
elif var is not None:
items = [
{Qt.EditRole: c,
EditStateRole: ItemEditState.NoState,
SourcePosRole: i,
SourceNameRole: c}
for i, c in enumerate(var.categories)
]
else:
items = []
with disconnected(self.values_model.dataChanged,
self.on_values_changed):
self.values_model.clear()
self.values_model.insertRows(0, len(items))
for i, item in enumerate(items):
self.values_model.setItemData(
self.values_model.index(i, 0),
item
)
self.add_new_item.actionGroup().setEnabled(var is not None)
def __categories_mapping(self):
# type: () -> CategoriesMappingType
model = self.values_model
source = self.var.categories
res = []
for i in range(model.rowCount()):
midx = model.index(i, 0)
category = midx.data(Qt.EditRole)
source_pos = midx.data(SourcePosRole) # type: Optional[int]
if source_pos is not None:
source_name = source[source_pos]
else:
source_name = None
state = midx.data(EditStateRole)
if state == ItemEditState.Dropped:
res.append((source_name, None))
elif state == ItemEditState.Added:
res.append((None, category))
else:
res.append((source_name, category))
return res
def get_data(self):
"""Retrieve the modified variable
"""
var, tr = super().get_data()
if var is None:
return var, tr
mapping = self.__categories_mapping()
if any(_1 != _2 or _2 != _3