本文整理汇总了Python中PyQt4.QtGui.QRadioButton.treeItem方法的典型用法代码示例。如果您正苦于以下问题:Python QRadioButton.treeItem方法的具体用法?Python QRadioButton.treeItem怎么用?Python QRadioButton.treeItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QRadioButton
的用法示例。
在下文中一共展示了QRadioButton.treeItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_node
# 需要导入模块: from PyQt4.QtGui import QRadioButton [as 别名]
# 或者: from PyQt4.QtGui.QRadioButton import treeItem [as 别名]
def add_node(self, parentItem, path, type):
item = QTreeWidgetItem(parentItem)
item.setText(0, path_leaf(path))
buttonGroup = QButtonGroup()
isNewFile = type is "UNTRACKED"
isModifiedFile = type is "MODIFIED"
isMissing = type is "MISSING"
isDirectory = type is "DIR"
if isNewFile:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(0, 255, 0)))
if isModifiedFile:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(0, 0, 255)))
if isMissing:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(255, 0, 0)))
if isDirectory:
for i in range(self.tree.columnCount()):
item.setBackground(i, QBrush(QColor(230, 230, 255)))
# must keep reference to buttonGroup for its callback to work
parent_data = self.retrieve_data(parentItem)
if parent_data != None:
path = os.path.join(parent_data[0], path)
self.attach_data(item, (path, buttonGroup, type))
for i in range(self.uncheckableColumns, self.tree.columnCount()):
if i == self.tree.columnCount() - 7 and isMissing:
continue # option to add not enabled for missing files
if i == self.tree.columnCount() - 4 and isNewFile:
continue # option to resolve not enabled for new files
if i == self.tree.columnCount() - 3 and not isMissing:
continue # option to stop tracking enabled only for missing files
if i == self.tree.columnCount() - 2 and not isNewFile:
continue # option to delete enabled only for untracked files
if i == self.tree.columnCount() - 2 and isDirectory:
continue # option to delete not enabled for directories, too dangerous
button = QRadioButton()
buttonGroup.addButton(button, i - self.uncheckableColumns) # id is the index
button.treeItem = item
self.tree.setItemWidget(item, i, button)
buttonGroup.buttonClicked.connect(self.tree_item_radio_clicked)
return item