本文整理汇总了Python中PySide.QtGui.QMenu.addAction方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addAction方法的具体用法?Python QMenu.addAction怎么用?Python QMenu.addAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.addAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def create(self, window: QtGui.QMainWindow, parent_menu: QtGui.QMenu):
if self.disabled:
return
if callable(self.method_name):
method = self.method_name
else:
method = getattr(window, self.method_name)
if self.sep:
parent_menu.addSeparator()
if self.submenu:
menu = QtGui.QMenu(self.verbose_name, p(parent_menu))
if self.icon:
action = parent_menu.addMenu(get_icon(self.icon), menu)
else:
action = parent_menu.addMenu(menu)
action.hovered.connect(functools.partial(self.fill_submenu, window, menu, method))
else:
if self.icon:
action = QtGui.QAction(get_icon(self.icon), self.verbose_name, p(parent_menu))
else:
action = QtGui.QAction(self.verbose_name, p(parent_menu))
# noinspection PyUnresolvedReferences
action.triggered.connect(method)
parent_menu.addAction(action)
if self.shortcut:
action.setShortcut(self.shortcut)
if self.help_text:
action.setStatusTip(self.help_text)
示例2: init_notebooks
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def init_notebooks(self):
frame = QFrame()
layout = QVBoxLayout()
frame.setLayout(layout)
self.ui.scrollArea.setWidget(frame)
for notebook_struct in self.app.provider.list_notebooks():
notebook = Notebook.from_tuple(notebook_struct)
count = self.app.provider.get_notebook_notes_count(notebook.id)
widget = QWidget()
menu = QMenu(self)
menu.addAction(self.tr('Change Name'), Slot()(partial(
self.change_notebook, notebook=notebook,
)))
action = menu.addAction(self.tr('Remove Notebook'), Slot()(partial(
self.remove_notebook, notebook=notebook,
)))
action.setEnabled(False)
widget.ui = Ui_Notebook()
widget.ui.setupUi(widget)
widget.ui.name.setText(notebook.name)
widget.ui.content.setText(self.tr('Containts %d notes') % count)
widget.ui.actionBtn.setIcon(QIcon.fromTheme('gtk-properties'))
widget.setFixedHeight(50)
layout.addWidget(widget)
widget.ui.actionBtn.clicked.connect(Slot()(partial(
self.show_notebook_menu,
menu=menu, widget=widget,
)))
示例3: showHeaderMenu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def showHeaderMenu( self, pos ):
header = self.horizontalHeader()
column = header.logicalIndexAt(pos.x())
filterAction = QAction(self)
filterAction.setText('Filter column')
filterAction.triggered.connect(lambda: self.filterColumn(self.indexAt(pos)))
symbolAction = QAction(self)
symbolAction.setText('Symbol')
symbolAction.triggered.connect(lambda: self.changeColumnDisplay(self.indexAt(pos),'symbol'))
colourAction = QAction(self)
colourAction.setText('Color')
colourAction.triggered.connect(lambda: self.changeColumnDisplay(self.indexAt(pos),'brush'))
sizeAction = QAction(self)
sizeAction.setText('Size')
sizeAction.triggered.connect(lambda: self.changeColumnDisplay(self.indexAt(pos),'size'))
# show menu about the column
menu = QMenu(self)
displayMenu = menu.addMenu('Change graph display')
displayMenu.addAction(symbolAction)
displayMenu.addAction(colourAction)
displayMenu.addAction(sizeAction)
menu.addAction(filterAction)
menu.popup(header.mapToGlobal(pos))
示例4: showContextMenu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def showContextMenu(self, point):
'Show the Columns context menu'
if self.model() is None:
return
# If we are viewing a proxy model, skip to the source model
mdl = self.model()
while isinstance(mdl, QAbstractProxyModel):
mdl = mdl.sourceModel()
if mdl is None or not hasattr(mdl, 'columns'):
return
# Generate and show the Menu
m = QMenu()
for i in range(len(mdl.columns)):
c = mdl.columns[i]
if c.internal:
continue
a = QAction(mdl.headerData(i, Qt.Horizontal, Qt.DisplayRole), m)
a.setCheckable(True)
a.setChecked(not self.isColumnHidden(i))
a.triggered.connect(partial(self.showHideColumn, c=i, s=self.isColumnHidden(i)))
m.addAction(a)
m.exec_(self.header().mapToGlobal(point))
示例5: _create_theme_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def _create_theme_menu(self):
theme_menu = QMenu(self)
theme_menu.setTitle('Buttons Theme')
theme_menu.setTearOffEnabled(True)
theme_menu.setWindowTitle(TAG)
theme_actions = QActionGroup(self)
theme_actions.setExclusive(True)
# create ordered theme list
custom_order_theme = sorted(THEMES.iterkeys())
custom_order_theme.remove('Maya Theme')
custom_order_theme.insert(0, 'Maya Theme')
default_item = True
for theme in custom_order_theme:
current_theme_action = QAction(theme, theme_actions)
current_theme_action.setCheckable(True)
current_theme_action.setChecked(
MTTSettings.value('theme', 'Maya Theme') == theme)
current_theme_action.triggered.connect(self.on_change_theme)
theme_menu.addAction(current_theme_action)
if default_item:
theme_menu.addSeparator()
default_item = False
return theme_menu
示例6: createVersionEveryWhereMenuForView
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def createVersionEveryWhereMenuForView(self, view):
versionEverywhereMenu = QMenu(self.actionTitle)
self._versionActions = []
# We look to the activeView for a selection of Clips
clips = self.clipSelectionFromView(view)
# And bail if nothing is found
if len(clips)==0:
return versionEverywhereMenu
# Now, if we have just one Clip selected, we'll form a special menu, which lists all versions
if len(clips)==1:
# Get a reversed list of Versions, so that bigger ones appear at top
versions = list(reversed(clips[0].binItem().items()))
for version in versions:
self._versionActions+=[self.makeVersionActionForSingleClip(version)]
elif len(clips)>1:
# We will add Max/Min/Prev/Next options, which can be called on a TrackItem, without the need for a Version object
self._versionActions+=[self.makeAction(self.eMaxVersion,self.setTrackItemVersionForClipSelection, icon=None)]
self._versionActions+=[self.makeAction(self.eMinVersion,self.setTrackItemVersionForClipSelection, icon=None)]
self._versionActions+=[self.makeAction(self.eNextVersion,self.setTrackItemVersionForClipSelection, icon=None)]
self._versionActions+=[self.makeAction(self.ePreviousVersion,self.setTrackItemVersionForClipSelection, icon=None)]
for act in self._versionActions:
versionEverywhereMenu.addAction(act)
return versionEverywhereMenu
示例7: contextMenuEvent
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def contextMenuEvent(self, event):
''' When user right-clicks: display context menu '''
png_action = 'Export branch to PNG, SVG or PDF'
hl_action = 'Hyperlink'
my_menu = QMenu(png_action)
if not hasattr(self, '_no_hyperlink'):
my_menu.addAction(hl_action)
my_menu.addAction(png_action)
action = my_menu.exec_(event.screenPos())
if action:
if action.text() == png_action:
# Save a picture of the selected symbol and all its children
filename = QFileDialog.getSaveFileName(self.window(),
'Export picture', '.',
'Picture (*.png, *.svg, *.pdf)')[0]
if not filename:
return
save_fmt = filename.split(os.extsep)[-1]
if save_fmt not in ('png', 'svg', 'pdf'):
return
self.scene().export_branch_to_picture(self, filename, save_fmt)
elif action.text() == hl_action:
if self.text:
self.hyperlink_dialog.setParent(
self.scene().views()[0], Qt.Dialog)
self.hlink_field.setText(self.text.hyperlink)
self.hyperlink_dialog.show()
示例8: tag_context_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def tag_context_menu(self, pos):
index = self.ui.tagsList.currentIndex()
item = self.tagsModel.itemFromIndex(index)
if hasattr(item, 'tag'):
menu = QMenu(self.ui.tagsList)
menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_tag)
menu.exec_(self.ui.tagsList.mapToGlobal(pos))
示例9: popup
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def popup(self,pos):
menu = QMenu()
saveRepAction = QAction(self)
saveRepAction.setText('Save representation...')
saveRepAction.triggered.connect(lambda: self.saveRep(self.indexAt(pos)))
menu.addAction(saveRepAction)
action = menu.exec_(self.mapToGlobal(pos))
示例10: notebook_context_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def notebook_context_menu(self, pos):
index = self.ui.notebooksList.currentIndex()
item = self.notebooksModel.itemFromIndex(index)
if hasattr(item, 'notebook'):
menu = QMenu(self.ui.notebooksList)
menu.addAction(QIcon.fromTheme('gtk-edit'), self.tr('Rename'), self.rename_notebook)
menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_notebook)
menu.exec_(self.ui.notebooksList.mapToGlobal(pos))
示例11: HierarchyTreeView
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
class HierarchyTreeView(QTreeView):
def __init__(self):
super(HierarchyTreeView, self).__init__()
#ukljucuje kontekstni meni
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.openMenu)
def openMenu(self, position):
self.contextMenu = QMenu()
newMenu = QMenu("New")
self.contextMenu.addMenu(newMenu)
actionNewProj = QAction("NewProject", None)
actionNewProj.triggered.connect(self.addNode)
actionRename = QAction("Rename", None)
actionRename.triggered.connect(self.renameNode)
actionRemProj = QAction("Delete", None)
actionRemProj.triggered.connect(self.removeNode)
newMenu.addAction(actionNewProj)
self.contextMenu.addAction(actionRename)
self.contextMenu.addAction(actionRemProj)
#prikaz kontekstnog menija
self.contextMenu.exec_(self.viewport().mapToGlobal(position))
def addNode(self):
model = self.model()
node = Node("NoviCvor")
if not self.currentIndex().isValid():
model.insertRow(model.rowCount(self.currentIndex()), node)
else:
model.insertRow(model.rowCount(self.currentIndex()), node, self.currentIndex())
self.expand(self.currentIndex())
def removeNode(self):
model = self.model()
model.removeRow(self.currentIndex().internalPointer().getIndex(), self.currentIndex().parent())
def renameNode(self):
self.currentIndex().internalPointer().setName("NOVO")
def mousePressEvent(self, event):
if(self.selectionMode() == QAbstractItemView.SingleSelection):
self.clearSelection()
self.setCurrentIndex(QModelIndex())
super(HierarchyTreeView, self).mousePressEvent(event)
示例12: sort_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def sort_menu(self):
sort_by=QMenu("Sort By")
sort_by.setIcon( QIcon(appicon("default_menu")) )
sorting=["Year","Title","Oldest","Newest","My Rating","IMDb Rating","ASC","DESC"]
for i in sorting:
k=SortbyAction(i,self)
k.triggered.connect(self.click_event)
sort_by.addAction(k)
return sort_by
示例13: _setupContextMenu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def _setupContextMenu(self):
from visualscrape.lib.data import ActionStore
context_menu = QMenu(self)
export_action = NamedAction(self.tr("Export ..."), self, name="export")
export_action.triggered.connect(self._requestTabExport)
context_menu.addAction(export_action)
self.setTabBar(ContextMenuTabBar(context_menu))
action_store = ActionStore.get_instance()
action_store.register_action(export_action)
示例14: __LobbyListMenu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def __LobbyListMenu( self, position ):
lobby_menu = QMenu()
rm_from_lobby = QAction( self )
rm_from_lobby.setText( "Remove player from lobby" )
rm_from_lobby.triggered.connect( self._RemoveFromLobbyListAction )
lobby_menu.addAction( rm_from_lobby )
lobby_menu.exec_( self.window.lobby_lst.viewport().mapToGlobal( position ) )
示例15: click
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addAction [as 别名]
def click(self, res, event):
"""Open resource"""
button = event.button()
if button == Qt.LeftButton:
subprocess.Popen(["xdg-open", res.file_path])
elif button == Qt.RightButton:
menu = QMenu(self.parent)
if not res.in_content:
menu.addAction(self.parent.tr("Remove Resource"), Slot()(partial(self.remove, res=res)))
menu.addAction(self.parent.tr("Save As"), Slot()(partial(self.save, res=res)))
menu.exec_(event.globalPos())