本文整理汇总了Python中PySide.QtGui.QMenu.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.setEnabled方法的具体用法?Python QMenu.setEnabled怎么用?Python QMenu.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.setEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MenuNode
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import setEnabled [as 别名]
#.........这里部分代码省略.........
childType = child.menuType
selfType = self.menuType
if selfType=='menu':
if childType=='menu':
child.qtaction = self.qtmenu.addMenu(child.qtmenu)
elif child.link:
qtmenu = child.link.qtmenu
child.qtaction = self.qtmenu.addMenu(qtmenu)
else:
action = QtGui.QAction(child.label, None,
shortcut = child.shortcut,
statusTip = child.help,
checkable = child.itemType=='check',
triggered = child.handleEvent
)
self.qtmenu.addAction(action)
child.qtaction = action
elif selfType=='menubar':
if childType=='menu':
self.qtmenubar.addMenu(child.qtmenu)
child.qtaction = child.qtmenu.menuAction()
else:
logging.warning('attempt to add menuitem/link to a menubar')
return
else:
logging.warning('menuitem has no child')
def setEnabled(self, enabled):
#todo: set state of linked item
selfType = self.menuType
if selfType == 'menubar':
self.qtmenubar.setEnable(enabled)
return
if self.qtmenu:
self.qtmenu.setEnabled(enabled)
else:
self.qtaction.setEnabled(enabled)
def remove(self):
self.clear()
self.parent.children.remove(self)
selfType = self.menuType
if not self.parent: return
if selfType=='menubar':
return
parentType = self.parent.menuType
if parentType == 'menu':
self.parent.qtmenu.removeAction( self.qtaction )
elif parentType == 'menubar':
self.parent.qtmenubar.removeAction( self.qtaction )
logging.info('remove menunode:' + self.name )
def clear( self ):
if self.menuType in [ 'menu', 'menubar' ]:
for node in self.children[:]: