本文整理汇总了Python中PyQt4.QtGui.QMenu.addActions方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addActions方法的具体用法?Python QMenu.addActions怎么用?Python QMenu.addActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.addActions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_menu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def _create_menu(self):
mbar = self._ui.menubar
menu = QMenu(mbar)
menu.setTitle("File")
menu.addAction(self._actions['data_new'])
menu.addAction(self._actions['session_save'])
menu.addAction(self._actions['session_restore'])
menu.addAction(self._actions['tab_new'])
menu.addAction(self._actions['window_new'])
mbar.addMenu(menu)
menu = QMenu(mbar)
menu.setTitle("Tab")
menu.addAction(self._actions['tab_new'])
menu.addAction(self._actions['window_new'])
menu.addSeparator()
menu.addAction(self._actions['cascade'])
menu.addAction(self._actions['tile'])
menu.addAction(self._actions['tab_rename'])
mbar.addMenu(menu)
menu = QMenu(mbar)
menu.setTitle("Layers")
menu.addActions(self._ui.layerWidget.actions())
a = act("Define new component", self,
tip="Define a new component using python expressions")
a.triggered.connect(self._create_component)
menu.addAction(a)
mbar.addMenu(menu)
示例2: contextMenuRequested
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def contextMenuRequested(point):
" quick and dirty custom context menu "
menu = QMenu()
menu.addActions(
(
qaqq,
qamin,
qanor,
qamax,
qasrc,
qakb,
qacol,
qati,
qasb,
qatb,
qatim,
qatit,
qafnt,
qapic,
qadoc,
qali,
qaslf,
qaqt,
qapy,
qabug,
)
)
menu.exec_(self.mapToGlobal(point))
示例3: Main
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class Main(plugin.Plugin):
" Main Class "
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
if linux_distribution():
self.menu = QMenu('Open with')
self.menu.aboutToShow.connect(self.build_submenu)
self.ex_locator = self.locator.get_service('explorer')
self.ex_locator.add_project_menu(self.menu, lang='all')
def build_submenu(self):
''' build sub menu on the fly based on file path '''
self.menu.clear()
if self.ex_locator.get_current_project_item().isFolder is not True:
filenam = self.ex_locator.get_current_project_item().get_full_path()
entry = xdg_query('default', guess_type(filenam, strict=False)[0])
if entry:
app = entry.replace('.desktop', '')
self.menu.addActions([
QAction(QIcon.fromTheme(app), app, self,
triggered=lambda: Popen([app, filenam])),
QAction(QIcon.fromTheme('folder-open'), 'File Manager',
self, triggered=lambda: Popen(['xdg-open',
path.dirname(filenam)]))])
self.menu.show()
示例4: FilterSetWidget
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class FilterSetWidget(QWidget, Ui_FilterSetWidget):
def __init__(self, parent=None):
super(FilterSetWidget, self).__init__(parent)
self.setupUi(self)
self._filterSetActionGroup = QActionGroup(self)
self._filterSetActionGroup.addAction(self.saveFilterSetAction)
self._filterSetActionGroup.addAction(self.reloadFilterSetAction)
self._filterSetActionGroup.addAction(self.deleteFilterSetAction)
self._filterSetActionGroup.addAction(self.exportFilterSetAction)
self._filterSetMenu = QMenu(self)
self._filterSetMenu.addActions(self._filterSetActionGroup.actions())
self.filterSetTool.setMenu(self._filterSetMenu)
self.filterSetTool.setDefaultAction(self.saveFilterSetAction)
def setFilterSet(self, filterSet):
self.setFilterSetKey(filterSet.key)
if filterSet.source == 'ark':
self.saveFilterSetAction.setEnabled(False)
self.deleteFilterSetAction.setEnabled(False)
self.filterSetTool.setDefaultAction(self.reloadFilterSetAction)
else:
self.saveFilterSetAction.setEnabled(True)
self.deleteFilterSetAction.setEnabled(True)
self.filterSetTool.setDefaultAction(self.saveFilterSetAction)
def setFilterSetKey(self, key):
self.filterSetCombo.setCurrentIndex(self.filterSetCombo.findData(key))
def currentFilterSetKey(self):
return self.filterSetCombo.itemData(self.filterSetCombo.currentIndex())
def currentFilterSetName(self):
return self.filterSetCombo.currentText()
示例5: Main
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class Main(plugin.Plugin):
" Main Class "
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
self.menu = QMenu('Convert Image')
self.menu.aboutToShow.connect(self.build_submenu)
self.ex_locator = self.locator.get_service('explorer')
self.ex_locator.add_project_menu(self.menu, lang='all')
def build_submenu(self):
''' build sub menu on the fly based on file path '''
self.menu.clear()
if self.ex_locator.get_current_project_item().isFolder is not True:
filenam = self.ex_locator.get_current_project_item().get_full_path()
# pillow.readthedocs.org/en/latest/handbook/image-file-formats.html
exten = ('bmp', 'cur', 'gbr', 'gif', 'ico', 'jfif', 'jpeg', 'pbm',
'pcx', 'pgm', 'png', 'ppm', 'psd', 'tga', 'tiff', 'xbm', 'xpm')
conditional = path.splitext(filenam)[1][1:].strip().lower() in exten
if conditional:
self.menu.addActions([
QAction('{} to WEBP'.format(path.basename(filenam)[:50]),
self, triggered=lambda: self.convert_img('WEBP')),
QAction('{} to JPG'.format(path.basename(filenam)[:50]),
self, triggered=lambda: self.convert_img('JPEG')),
QAction('{} to PNG'.format(path.basename(filenam)[:50]),
self, triggered=lambda: self.convert_img('PNG')), ])
self.menu.show()
def convert_img(self, fmt):
""" convert image to desired format """
filenam = self.ex_locator.get_current_project_item().get_full_path()
im = Image.open(filenam).convert("RGB")
im.save(path.splitext(filenam)[0] + ".{}".format(fmt.lower()), fmt)
示例6: _onTvFilesCustomContextMenuRequested
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def _onTvFilesCustomContextMenuRequested(self, pos ):
"""Connected automatically by uic
"""
menu = QMenu()
menu.addAction( core.actionManager().action( "mFile/mClose/aCurrent" ) )
menu.addAction( core.actionManager().action( "mFile/mSave/aCurrent" ) )
menu.addAction( core.actionManager().action( "mFile/mReload/aCurrent" ) )
menu.addSeparator()
# sort menu
sortMenu = QMenu( self )
group = QActionGroup( sortMenu )
group.addAction( self.tr( "Opening order" ) )
group.addAction( self.tr( "File name" ) )
group.addAction( self.tr( "URL" ) )
group.addAction( self.tr( "Suffixes" ) )
group.triggered.connect(self._onSortTriggered)
sortMenu.addActions( group.actions() )
for i, sortMode in enumerate(["OpeningOrder", "FileName", "URL", "Suffixes"]):
action = group.actions()[i]
action.setData( sortMode )
action.setCheckable( True )
if sortMode == self.model.sortMode():
action.setChecked( True )
aSortMenu = QAction( self.tr( "Sorting" ), self )
aSortMenu.setMenu( sortMenu )
aSortMenu.setIcon( QIcon( ":/enkiicons/sort.png" ))
aSortMenu.setToolTip( aSortMenu.text() )
menu.addAction( sortMenu.menuAction() )
menu.exec_( self.tvFiles.mapToGlobal( pos ) )
示例7: contextMenu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def contextMenu(self, pos):
menu = QMenu()
menu.addActions(self.contextMenuActions)
difficultyMenu = menu.addMenu("Change difficulty")
difficultyMenu.addActions(self.difficultyActions)
# change position a little to have a corner of the menu where the mouse is
if platform.system() != "Windows":
menu.exec_(self.wordsTable.mapToGlobal(QPoint(pos.x()+18,pos.y() +24)))
else:
menu.exec_(self.wordsTable.mapToGlobal(QPoint(pos.x()+16,pos.y() +24)))
示例8: initLexerMenu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def initLexerMenu(self):
self.action_Lexer = QAction(Icons.file_obj, 'Lexer', self)
men = QMenu()
self.lexGroup = QActionGroup(self)
self.lexGroup.setExclusive(True)
self.lexGroup.selected.connect(self.parent.setLexer)
#langs = [i for i in dir(Qsci) if i.startswith('QsciLexer')]
langs = ['Bash', 'Batch', 'CMake', 'CPP', 'CSS', 'C#','HTML','Java', 'JavaScript', 'Lua', 'Makefile','Python', 'SQL', 'XML', 'YAML']
for l in langs:
act = self.make_action_lex(l)
self.lexGroup.addAction(act)
if(langs.index(l) == 8): #For javascript
act.setChecked(True)
#print l[9:] # we don't need to print "QsciLexer" before each name
men.addActions(self.lexGroup.actions())
self.action_Lexer.setMenu(men)
self.addAction(self.action_Lexer)
示例9: _create_menu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def _create_menu(self):
mbar = self._ui.menubar
menu = QMenu(mbar)
menu.setTitle("File")
menu.addAction(self._actions['data_new'])
#menu.addAction(self._actions['data_save']) # XXX add this
menu.addAction(self._actions['session_restore'])
menu.addAction(self._actions['session_save'])
mbar.addMenu(menu)
menu = QMenu(mbar)
menu.setTitle("Canvas")
menu.addAction(self._actions['tab_new'])
menu.addAction(self._actions['viewer_new'])
menu.addSeparator()
menu.addAction(self._actions['cascade'])
menu.addAction(self._actions['tile'])
menu.addAction(self._actions['tab_rename'])
mbar.addMenu(menu)
menu = QMenu(mbar)
menu.setTitle("Data Manager")
menu.addActions(self._ui.layerWidget.actions())
mbar.addMenu(menu)
menu = QMenu(mbar)
menu.setTitle("Toolbars")
tbar = EditSubsetModeToolBar()
self._mode_toolbar = tbar
self.addToolBar(tbar)
tbar.hide()
a = QAction("Selection Mode Toolbar", menu)
a.setCheckable(True)
a.toggled.connect(tbar.setVisible)
try:
tbar.visibilityChanged.connect(a.setChecked)
except AttributeError: # Qt < 4.7. Signal not supported
pass
menu.addAction(a)
menu.addActions(tbar.actions())
mbar.addMenu(menu)
示例10: Main
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class Main(plugin.Plugin):
" Main Class "
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
self.menu = QMenu('Copy path')
self.menu.addActions([QAction('Full file path', self, triggered=lambda:
QApplication.clipboard().setText(self.locator.get_service('explorer'
).get_current_project_item().get_full_path())),
QAction('Filename only', self, triggered=lambda:
QApplication.clipboard().setText(path.basename(
self.locator.get_service('explorer').get_current_project_item(
).get_full_path()))),
QAction('Directory path only', self, triggered=lambda:
QApplication.clipboard().setText(path.dirname(
self.locator.get_service('explorer').get_current_project_item(
).get_full_path())))
])
self.locator.get_service('explorer').add_project_menu(self.menu,
lang='all')
示例11: Main
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class Main(plugin.Plugin):
" Main Class "
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
if linux_distribution():
self.menu = QMenu('Open with')
self.menu.aboutToShow.connect(self.build_submenu)
self.ex_locator = self.locator.get_service('explorer')
self.ex_locator.add_project_menu(self.menu, lang='all')
def build_submenu(self):
''' build sub menu on the fly based on file path '''
self.menu.clear()
if self.ex_locator.get_current_project_item().isFolder is not True:
filenam = self.ex_locator.get_current_project_item().get_full_path()
entry = xdg_query('default', guess_type(filenam, strict=False)[0])
if entry:
app = entry.replace('.desktop', '')
actions = [
QAction(QIcon.fromTheme(app), app, self,
triggered=lambda: Popen([app, filenam])),
QAction(QIcon.fromTheme('folder-open'), 'File Manager',
self, triggered=lambda: Popen(['xdg-open', path.dirname(filenam)]))]
#QAction(QIcon.fromTheme('Sublime Text 2'), 'Sublime',
# self, triggered=lambda: Popen(['sublime-text', filenam])),
#QAction(QIcon.fromTheme('Sqliteman'), 'Sqliteman',
# self, triggered=lambda: Popen(['sqliteman', filenam])),
#QAction(QIcon.fromTheme('Google Chrome'), 'Google Chrome',
# self, triggered=lambda: Popen(['google-chrome', filenam]))
for key in usersettings.commands.keys():
action = QAction(QIcon.fromTheme(key), key,
self, triggered=lambda: Popen([usersettings.commands[key], filenam]))
actions.append(action)
self.menu.addActions(actions)
self.menu.show()
示例12: initApiMenu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def initApiMenu(self):
self.action_Api = QAction(Icons.lib, 'Api', self)
men = QMenu()
self.apiGroup = QActionGroup(self)
self.apiGroup.setExclusive(True)
self.apiGroup.selected.connect(self.parent.setApi)
list = oslistdir(apiDir)
apis = []
if(list != None):
for i in list:
if i.endswith("api"):
apis.append(i.replace(".api", ""))
if(apis != None):
for i in apis:
act = self.make_action_api(i)
self.apiGroup.addAction(act)
if(i == "emo"): #For emo
act.setChecked(True)
men.addActions(self.apiGroup.actions())
self.action_Api.setMenu(men)
self.addAction(self.action_Api)
示例13: handlePackageContextAction
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def handlePackageContextAction(point):
window = QApplication.activeWindow()
package = window.currentPackage()
menu = QMenu(parent=window)
install = QAction(QIcon(':/icons/installed.png'), "&Install", window.packages)
install.connect(install, SIGNAL('triggered()'), lambda: Frontend.default().install(package))
install.setEnabled(package.get('state', False) & (State.NonInstalled | State.AUR))
update = QAction(QIcon(':/icons/upgrade.png'), "&Update", window.packages)
update.connect(update, SIGNAL('triggered()'), lambda: Frontend.default().install(package, update=True))
update.setEnabled(package.get('state', False) & State.Update)
remove = QAction(QIcon(':/icons/stop.png'), "&Remove", window.packages)
remove.connect(remove, SIGNAL('triggered()'), lambda: Frontend.default().remove(package))
remove.setEnabled(package.get('state', False) & (State.Installed | State.Update))
remove_forced = QAction(QIcon(':/icons/orphan.png'), "&Remove (force)", window.packages)
remove_forced.connect(remove_forced, SIGNAL('triggered()'), lambda: Frontend.default().remove(package, force=True))
remove_forced.setEnabled(package.get('state', False) & (State.Installed | State.Update))
menu.addActions((install, update, remove, remove_forced))
menu.exec_(window.packages.mapToGlobal(point))
示例14: build_menu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
def build_menu(self, signals):
"""Build the menu."""
def action_cmp(a,b):
aText = a.text().upper()
bText = b.text().upper()
if aText == bText: return 0
if aText < bText: return -1
return 1
menu = QMenu(self)
connected = False
# the signals
signal_actions = []
for signal in signals:
icon = self.icon_for_signal(signal)
if signal.is_connected():
connected = True
when_triggered = (lambda sign: lambda:self.please_connect(sign))(signal)
action = QAction(icon, signal.ssid, self, triggered = when_triggered)
signal_actions.append(action)
signal_actions.sort(cmp = action_cmp)
menu.addActions(signal_actions)
self.update_connected_state(connected)
# the bottom part
menu.addSeparator()
menu.addAction(QAction("Share...", self, triggered=self.share_keys))
menu.addAction(QAction("Update Database", self, triggered=self.update_database))
menu.addAction(QAction("Rescan", self, triggered=self.rescan_networks))
menu.addAction(QAction("Quit", self, triggered=self.app_quit))
menu.addAction(QAction("WTF?", self, triggered=self.open_about_dialog))
return menu
示例15: Main
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addActions [as 别名]
class Main(plugin.Plugin):
" Main Class "
def initialize(self, *args, **kwargs):
" Init Main Class "
super(Main, self).initialize(*args, **kwargs)
self.menu1 = QMenu('Compress')
self.menu1.aboutToShow.connect(self.build_submenu)
self.ex_locator = self.locator.get_service('explorer')
self.ex_locator.add_project_menu(self.menu1, lang='all')
if not version_info[0] < 3:
self.menu2 = QMenu('Extract')
self.menu2.aboutToShow.connect(self.build_submenu)
self.ex_locator.add_project_menu(self.menu2, lang='all')
def build_submenu(self):
''' build sub menu on the fly based on file path '''
self.menu1.clear()
if self.ex_locator.get_current_project_item().isFolder is True:
folder = self.ex_locator.get_current_project_item().get_full_path()
self.menu1.addActions([
QAction('To ZIP', self, triggered=lambda:
make_archive(folder, 'zip', folder)),
QAction('To TAR', self, triggered=lambda:
make_archive(folder, 'tar', folder)),
QAction('To BZ2', self, triggered=lambda:
make_archive(folder, 'bztar', folder))])
self.menu1.show()
elif not version_info[0] < 3:
self.menu2.clear()
filenam = self.ex_locator.get_current_project_item().get_full_path()
exten = ('zip', 'tar', 'bz2', 'bztar', 'gztar')
conditional = path.splitext(filenam)[1][1:].strip().lower() in exten
if conditional:
self.menu2.addAction(QAction('From {}'.format(
path.splitext(filenam)[1].upper()), self, triggered=lambda:
unpack_archive(filenam, path.dirname(filenam))))
self.menu2.show()