本文整理汇总了Python中PyQt4.QtGui.QMenu.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.setEnabled方法的具体用法?Python QMenu.setEnabled怎么用?Python QMenu.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.setEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogSParserMain
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setEnabled [as 别名]
#.........这里部分代码省略.........
row_2 = selected_indexes[1].row()
time_stamp1 = float(self.table_data[row_1][self.time_stamp_column])
time_stamp2 = float(self.table_data[row_2][self.time_stamp_column])
self.user_interface.statusbar.showMessage("Time difference = {}".format(abs(time_stamp2 - time_stamp1)))
else:
self.user_interface.statusbar.showMessage("")
def cell_right_clicked(self, point):
"""
Handle the event of right-clicking on a table cell.
This function is responsible for showing the context menu for the user
to choose from.
"""
index = self.proxy_model.mapToSource(
self.user_interface.tblLogData.indexAt(point))
logging.debug("Cell[%d, %d] was right-clicked. Contents = %s", index.row(), index.column(), index.data())
self.right_clicked_cell_index = index
self.populate_unhide_context_menu(index.column())
self.prepare_clipboard_text()
self.menuFilter.popup(QCursor.pos())
def populate_unhide_context_menu(self, column):
self.unhide_menu.clear()
if(self.is_filtering_mode_out):
filtered_out_set = self.per_column_filter_out_set_list[column]
else:
filtered_out_set = set(self.columns_dict[column].keys()) - self.per_column_filter_in_set_list[column]
if(len(filtered_out_set) > 0):
self.unhide_menu.setEnabled(True)
for filtered_string in filtered_out_set:
temp_action = QAction(filtered_string, self.unhide_menu)
temp_action.triggered.connect(functools.partial(self.unhide_selected_rows_only_based_on_column, self.right_clicked_cell_index.column(), filtered_string))
self.unhide_menu.addAction(temp_action)
else:
self.unhide_menu.setEnabled(False)
def cell_double_clicked(self, index):
"""
Handles the event of double-clicking on a table cell.
If the double clicked cell was at the column of file:line, the function
triggers external text editor (currently this is gedit on Linux) and make
it point on the corresponding line.
"""
index = self.proxy_model.mapToSource(index)
logging.info("cell[%d][%d] = %s", index.row(), index.column(), index.data())
row = index.row()
file_matcher = re.search(self.file_column_pattern, self.table_data[row][self.file_column])
line_matcher = re.search(self.line_column_pattern, self.table_data[row][self.line_column])
if((file_matcher is not None) and (line_matcher is not None)):
file = file_matcher.group(1)
line = line_matcher.group(1)
full_path = "{}{}".format(self.root_source_path_prefix, file.strip())
logging.info("Using external editor (gedit) to open %s at line %s", file, line)
editor = self.external_editor_configs["editor"]
示例2: ProfileTableViewer
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setEnabled [as 别名]
#.........这里部分代码省略.........
self.__outsideCallersMenu = QMenu( "Outside callers", self )
self.__calleesMenu = QMenu( "Callees", self )
self.__outsideCalleesMenu = QMenu( "Outside callees", self )
self.__contextMenu.addMenu( self.__callersMenu )
self.__contextMenu.addMenu( self.__outsideCallersMenu )
self.__contextMenu.addSeparator()
self.__contextMenu.addMenu( self.__calleesMenu )
self.__contextMenu.addMenu( self.__outsideCalleesMenu )
self.__contextMenu.addSeparator()
self.__disasmAct = self.__contextMenu.addAction(
PixmapCache().getIcon( 'disasmmenu.png' ),
"Disassemble", self.__onDisassemble )
self.__callersMenu.triggered.connect( self.__onCallContextMenu )
self.__outsideCallersMenu.triggered.connect( self.__onCallContextMenu )
self.__calleesMenu.triggered.connect( self.__onCallContextMenu )
self.__outsideCalleesMenu.triggered.connect( self.__onCallContextMenu )
self.__table.setContextMenuPolicy( Qt.CustomContextMenu )
self.__table.customContextMenuRequested.connect( self.__showContextMenu )
return
def __showContextMenu( self, point ):
" Context menu "
self.__callersMenu.clear()
self.__outsideCallersMenu.clear()
self.__calleesMenu.clear()
self.__outsideCalleesMenu.clear()
# Detect what the item was clicked
item = self.__table.itemAt( point )
funcName = item.getFunctionName()
self.__disasmAct.setEnabled( item.getFileName() != "" and \
not funcName.startswith( "<" ) )
# Build the context menu
if item.callersCount() == 0:
self.__callersMenu.setEnabled( False )
self.__outsideCallersMenu.setEnabled( False )
else:
callers = self.__stats.stats[ item.getFuncIDs() ][ 4 ]
callersList = callers.keys()
callersList.sort()
for callerFunc in callersList:
menuText = self.__getCallLine( callerFunc, callers[ callerFunc ] )
if self.__isOutsideItem( callerFunc[ 0 ] ):
act = self.__outsideCallersMenu.addAction( menuText )
else:
act = self.__callersMenu.addAction( menuText )
funcFileName, funcLine, funcName = self.__getLocationAndName( callerFunc )
act.setData( QVariant( funcFileName + ":" + \
str( funcLine ) + ":" + \
funcName ) )
self.__callersMenu.setEnabled( not self.__callersMenu.isEmpty() )
self.__outsideCallersMenu.setEnabled( not self.__outsideCallersMenu.isEmpty() )
if item.calleesCount() == 0:
self.__calleesMenu.setEnabled( False )
self.__outsideCalleesMenu.setEnabled( False )
else:
callees = self.__stats.all_callees[ item.getFuncIDs() ]
calleesList = callees.keys()
calleesList.sort()
for calleeFunc in calleesList:
menuText = self.__getCallLine( calleeFunc, callees[ calleeFunc ] )
示例3: GuiMenu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setEnabled [as 别名]
#.........这里部分代码省略.........
SIGNAL('triggered()'),
self._menu_delete_elem_main_file)
menu_main_file.addAction(remove_elem_in_main_file_action)
copy_main_to_second_file_action = QAction("Copy to second File", self)
QObject.connect(copy_main_to_second_file_action,
SIGNAL('triggered()'),
self._menu_copy_main_to_second_file)
menu_main_file.addAction(copy_main_to_second_file_action)
expand_all_action = QAction("Expand all", self)
QObject.connect(expand_all_action,
SIGNAL('triggered()'),
lambda: self.signal_wrapper. \
signal_treeview1_expand_all.emit())
menu_main_file.addAction(expand_all_action)
collapse_all_action = QAction("Collapse all", self)
QObject.connect(collapse_all_action,
SIGNAL('triggered()'),
lambda: self.signal_wrapper. \
signal_treeview1_collapse_all.emit())
menu_main_file.addAction(collapse_all_action)
menu_main_file.addSeparator()
self._initialize_tree_specific_menu_entries(self.tree_main,
menu_main_file,
self.MAIN_TREE)
def _init_gui_menu_second_file(self):
"""Initialises the second window / file
"""
self.menu_second_file.setEnabled(False)
self.addMenu(self.menu_second_file)
menu_open_second_file_action = QAction("Open file", self)
QObject.connect(menu_open_second_file_action,
SIGNAL('triggered()'),
self._menu_second_window_open_file)
self.menu_second_file.addAction(menu_open_second_file_action)
remove_elem_in_second_file_action = QAction("Remove element", self)
QObject.connect(remove_elem_in_second_file_action,
SIGNAL('triggered()'),
self._menu_delete_elem_second_file)
self.menu_second_file.addAction(remove_elem_in_second_file_action)
copy_second_to_main_file_action = QAction("Copy to main File", self)
QObject.connect(copy_second_to_main_file_action,
SIGNAL('triggered()'),
self._menu_copy_second_to_main_file)
self.menu_second_file.addAction(copy_second_to_main_file_action)
expand_all_action = QAction("Expand all", self)
QObject.connect(expand_all_action,
SIGNAL('triggered()'),
lambda: self.signal_wrapper. \
signal_treeview2_expand_all.emit())
self.menu_second_file.addAction(expand_all_action)
collapse_all_action = QAction("Collapse all", self)
QObject.connect(collapse_all_action,
SIGNAL('triggered()'),
lambda: self.signal_wrapper. \
signal_treeview2_collapse_all.emit())
self.menu_second_file.addAction(collapse_all_action)
示例4: MenuNode
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.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[:]:
示例5: BrowserView
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setEnabled [as 别名]
#.........这里部分代码省略.........
self.contextMenuReload.triggered.connect(self.reloadChoosen)
self.contextMenuClear.triggered.connect(self.clearChoosen)
self.contextMenuFilter.triggered.connect(self.filterChoosen)
self.contextMenuLimit.triggered.connect(self.limitChoosen)
def rightClick(self, point):
""" Called when the view is right-clicked.
Displays a context menu with possible actions.
:param point: contains the global screen coordinates for the
right-click that generated this call.
:type potin: QPoint
"""
# This is a list of QModelIndex objects, which will be used by
# the various context menu slots.
# We therfore store it as a class member
self.selection = self.entryList.selectedIndexes()
openSupport = True
reloadSupport = True
clearSupport = True
filterSupport = True
limitSupport = True
addSupport = True
deleteSupport = True
exportSupport = True
editServerSupport = True
# The number of selected items is used for naming of the actions
# added to the submenues
numselected = len(self.selection)
# View disabled menu if nothing selected
self.contextMenu.setEnabled(True) # Remember to enable if a selection
if not numselected > 0: # If nothing is selected
self.contextMenu.setEnabled(False) # Disable
self.contextMenu.exec_(self.entryList.mapToGlobal(point)) # Show
return
# Iterate through the list of selected indexes, and
# validate what operations are supported. That is,
# if one of the selected indexes do not support an
# operation, we cannot allow to apply that operation
# on the whole selection
for index in self.selection:
item = index.internalPointer()
operations = item.getSupportedOperations()
if not AbstractLDAPTreeItem.SUPPORT_OPEN & operations:
openSupport = False
if not AbstractLDAPTreeItem.SUPPORT_RELOAD & operations:
reloadSupport = False
if not AbstractLDAPTreeItem.SUPPORT_CLEAR & operations:
clearSupport = False
if not AbstractLDAPTreeItem.SUPPORT_FILTER & operations:
filterSupport = False
if not AbstractLDAPTreeItem.SUPPORT_LIMIT & operations:
limitSupport = False
if not AbstractLDAPTreeItem.SUPPORT_ADD & operations:
addSupport = False
if not AbstractLDAPTreeItem.SUPPORT_DELETE & operations:
deleteSupport = False
if not AbstractLDAPTreeItem.SUPPORT_EXPORT & operations:
exportSupport = False
if index.internalPointer().getParentServerItem() == None:
editServerSupport = False