本文整理汇总了Python中PyQt4.QtGui.QMenu.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.setIcon方法的具体用法?Python QMenu.setIcon怎么用?Python QMenu.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.setIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_custom_menu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def process_custom_menu(self, point):
''' See XmlController for documentation '''
item = self.select_item_at(point)
if not item:
return
menu = QMenu()
node = item.node
if node.get('executable') == 'True':
menu.addAction(self.actRunScenario)
elif node.get('type') in ['selectable', 'model_choice']:
menu.addAction(self.actMoveNodeUp)
menu.addAction(self.actMoveNodeDown)
elif node.tag == 'models_to_run': # special case of a selectable list
models_menu = QMenu(menu)
models_menu.setTitle('Add model to run')
models_menu.setIcon(IconLibrary.icon('add'))
available_model_names = get_model_names(self.project)
for model_name in available_model_names:
cb = lambda x = model_name, y = self.selected_index(): self.addModel(y, x)
action = self.create_action('model', model_name, cb)
models_menu.addAction(action)
menu.addMenu(models_menu)
self.add_default_menu_items_for_node(node, menu)
if not menu.isEmpty():
menu.exec_(QCursor.pos())
示例2: add_custom_menu_items_for_node
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def add_custom_menu_items_for_node(self, node, menu):
if node.get('type') == 'scenario':
node_executable = (node.get('executable') == 'True')
menu.addAction(self.actExecutable)
# Workaround: disabled items do not show check marks
if node.get('inherited') is None:
self.actExecutable.setEnabled(True)
self.actExecutable.setText('Executable')
self.actExecutable.setChecked(node_executable)
else:
self.actExecutable.setDisabled(True)
self.actExecutable.setText('Executable: %s' % ('Yes' if node_executable else 'No'))
if node_executable:
menu.addAction(self.actRunScenario)
if node.find('models_to_run') is None:
#if there isn't a child node models_to_run
menu.addAction(self.actModelsToRun)
elif node.get('type') in ['selectable', 'model_choice']:
menu.addAction(self.actMoveNodeUp)
menu.addAction(self.actMoveNodeDown)
elif node.tag == 'models_to_run': # special case of a selectable list
models_menu = QMenu(menu)
models_menu.setTitle('Add model to run')
models_menu.setIcon(IconLibrary.icon('add'))
available_model_names = get_model_names(self.project)
for model_name in available_model_names:
cb = lambda x = model_name, y = self.selected_index(): self.addModel(y, x)
action = self.create_action('model', model_name, cb)
models_menu.addAction(action)
menu.addMenu(models_menu)
示例3: add_submenu
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def add_submenu(self, submenu, menu):
submenu = QMenu(submenu, menu)
submenu.setIcon(QIcon(":/plugins/ProjectLauncher/icon_folder.png"))
menu.addMenu(submenu)
return submenu
示例4: manageActions
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def manageActions(self,modelindex,menu):
'''
Returns a menu for managing social tenure relationship information.
'''
editReceivers = self.signalReceivers(self.editAction)
if editReceivers > 0:
self.editAction.triggered.disconnect()
deleteReceivers = self.signalReceivers(self.deleteAction)
if deleteReceivers > 0:
self.deleteAction.triggered.disconnect()
#Add new entities menu
entityAddMenu = QMenu(QApplication.translate("STRNode","Add"),self.parentWidget())
entityAddMenu.setIcon(QIcon(":/plugins/stdm/images/icons/add.png"))
#Define actions for adding related STR entities
confAction = QAction(QIcon(":/plugins/stdm/images/icons/conflict.png"),
QApplication.translate("STRNode","Conflict Information"),self._view)
confAction.triggered.connect(lambda: self.onCreateConflict(modelindex))
#Check if conflict information already exists. If so, then no need of defining twice
if self.strModel.hasConflict():
confAction.setEnabled(False)
entityAddMenu.addAction(confAction)
taxAction = QAction(QIcon(":/plugins/stdm/images/icons/receipt.png"),
QApplication.translate("STRNode","Tax Information"),self._view)
taxAction.triggered.connect(lambda: self.onCreateTaxation(modelindex))
if self.strModel.hasTaxation():
taxAction.setEnabled(False)
entityAddMenu.addAction(taxAction)
#Add source documents menu
addSrcDocMenu = QMenu(QApplication.translate("STRNode","Source Documents"),self.parentWidget())
addSrcDocMenu.setIcon(QIcon(":/plugins/stdm/images/icons/attachment.png"))
titleDeedAction = QAction(QApplication.translate("STRNode","Title Deed"),self._view)
titleDeedAction.triggered.connect(lambda: self.onAddSourceDocument(TITLE_DEED))
addSrcDocMenu.addAction(titleDeedAction)
notaryRefAction = QAction(QApplication.translate("STRNode","Notary Reference"),self._view)
notaryRefAction.triggered.connect(lambda: self.onAddSourceDocument(NOTARY_REF))
addSrcDocMenu.addAction(notaryRefAction)
statRefPaperAction = QAction(QApplication.translate("STRNode","Statutory Reference Paper"),self._view)
statRefPaperAction.triggered.connect(lambda: self.onAddSourceDocument(STATUTORY_REF_PAPER))
addSrcDocMenu.addAction(statRefPaperAction)
surveyorRefAction = QAction(QApplication.translate("STRNode","Surveyor Reference"),self._view)
surveyorRefAction.triggered.connect(lambda: self.onAddSourceDocument(SURVEYOR_REF))
addSrcDocMenu.addAction(surveyorRefAction)
entityAddMenu.addMenu(addSrcDocMenu)
menu.addMenu(entityAddMenu)
menu.addAction(self.editAction)
menu.addAction(self.deleteAction)
#Disable if the user does not have permission.
if not self.parentWidget()._canEdit:
menu.setEnabled(False)
self.editAction.triggered.connect(lambda: self.onEdit(modelindex))
self.deleteAction.triggered.connect(lambda: self.onDelete(modelindex))
示例5: _read_ini_file
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def _read_ini_file(self, root, ini_file_path, category):
try:
ini_full_path = os.path.join(root, ini_file_path)
parser = ConfigParser()
ini_file = codecs.open(ini_full_path, 'r', 'utf-8')
parser.readfp(ini_file)
#read config
group_id = parser.get('general', 'id')
group_alias = parser.get('ui', 'alias')
icon_file = ConfigReaderHelper.try_read_config(parser, 'ui', 'icon')
group_icon_path = os.path.join(root, icon_file) if icon_file else None
#try read translations
posible_trans = parser.items('ui')
for key, val in posible_trans:
if type(key) is unicode and key == 'alias[%s]' % self.locale:
self.translator.append(group_alias, val)
break
#create menu
group_menu = QMenu(self.tr(group_alias))
group_menu.setIcon(QIcon(group_icon_path))
#append to all groups
# set contrib&user
self.groups[group_id] = GroupInfo(group_id, group_alias, group_icon_path, ini_full_path, group_menu, category)
except Exception, e:
error_message = self.tr('Group INI file can\'t be parsed: ') + e.message
QgsMessageLog.logMessage(error_message, level=QgsMessageLog.CRITICAL)
示例6: __init__
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
class WebLayerGroup:
"""Group in menu"""
def __init__(self, name, icon):
self._menu = QMenu(name)
self._menu.setIcon(QIcon(os.path.join(":/plugins/openlayers/weblayers/icons", icon)))
def menu(self):
return self._menu
示例7: install_shortcuts
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def install_shortcuts(obj, actions, ide):
short = resources.get_shortcut
for action in actions:
short_key = action.get("shortcut", None)
action_data = action.get("action", None)
connect = action.get("connect", None)
shortcut = None
item_ui = None
func = None
if connect:
func = getattr(obj, connect, None)
if short_key and not action_data:
if isinstance(short_key, QKeySequence):
shortcut = QShortcut(short_key, ide)
else:
shortcut = QShortcut(short(short_key), ide)
shortcut.setContext(Qt.ApplicationShortcut)
if isinstance(func, collections.Callable):
ide.connect(shortcut, SIGNAL("activated()"), func)
if action_data:
is_menu = action_data.get('is_menu', False)
if is_menu:
item_ui = QMenu(action_data['text'], ide)
else:
item_ui = QAction(action_data['text'], ide)
object_name = "%s.%s" % (obj.__class__.__name__, connect)
item_ui.setObjectName(object_name)
image_name = action_data.get('image', None)
section = action_data.get('section', None)
weight = action_data.get('weight', None)
keysequence = action_data.get('keysequence', None)
if image_name:
if isinstance(image_name, int):
icon = ide.style().standardIcon(image_name)
item_ui.setIcon(icon)
elif isinstance(image_name, str):
icon = QIcon(":img/" + image_name)
item_ui.setIcon(icon)
if short_key and not is_menu:
item_ui.setShortcut(short(short_key))
item_ui.setShortcutContext(Qt.ApplicationShortcut)
elif keysequence and not is_menu:
item_ui.setShortcut(short(keysequence))
item_ui.setShortcutContext(Qt.ApplicationShortcut)
if isinstance(func, collections.Callable) and not is_menu:
ide.connect(item_ui, SIGNAL("triggered()"), func)
if section and section[0] is not None and weight:
ide.register_menuitem(item_ui, section, weight)
if image_name and not is_menu:
ide.register_toolbar(item_ui, section, weight)
if short_key and shortcut:
ide.register_shortcut(short_key, shortcut, item_ui)
示例8: _setupUi
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def _setupUi(self):
self.setupUi(self)
self.browserView.setModel(self.boardModel)
h = self.browserView.header()
h.setResizeMode(QHeaderView.Fixed)
h.resizeSection(1, 120)
h.setResizeMode(0, QHeaderView.Stretch)
# Action menu
actionMenu = QMenu('Actions', self.toolBar)
actionMenu.setIcon(QIcon(QPixmap(":/actions")))
actionMenu.addAction(self.actionNewFolder)
actionMenu.addAction(self.actionRemoveEmptyFolders)
actionMenu.addAction(self.actionRenameSelected)
actionMenu.addAction(self.actionMoveSelectedToIgnoreBox)
actionMenu.addAction(self.actionSwitchConflictAndOriginal)
actionMenu.addSeparator()
actionMenu.addAction(self.actionMassRename)
actionMenu.addAction(self.actionSplit)
actionMenu.addAction(self.actionUndoSplit)
actionMenu.addAction(self.actionMoveConflicts)
actionMenu.addAction(self.actionMoveConflictsAndOriginals)
self.actionActions.setMenu(actionMenu)
button = QToolButton(self.toolBar)
button.setDefaultAction(actionMenu.menuAction())
button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
self.actionsButton = button
self.toolBar.insertWidget(self.actionActions, button) # the action is a placeholder
self.toolBar.removeAction(self.actionActions)
# Materialize menu
materializeMenu = QMenu('Materialize', self.toolBar)
materializeMenu.setIcon(QIcon(QPixmap(":/materialize")))
materializeMenu.addAction(self.actionRenameInRespectiveLocations)
materializeMenu.addAction(self.actionCopyToOtherLocation)
materializeMenu.addAction(self.actionMoveToOtherLocation)
self.actionMaterialize.setMenu(materializeMenu)
button = QToolButton(self.toolBar)
button.setDefaultAction(materializeMenu.menuAction())
button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
self.materializeButton = button
self.toolBar.insertWidget(self.actionMaterialize, button) # the action is a placeholder
self.toolBar.removeAction(self.actionMaterialize)
示例9: __init__
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
class QuickMapServices:
"""QGIS Plugin Implementation."""
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
self.translator = QTranslator()
self.locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'QuickMapServices_{}.qm'.format(self.locale))
if os.path.exists(locale_path):
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.custom_translator = CustomTranslator()
QCoreApplication.installTranslator(self.custom_translator)
# Create the dialog (after translation) and keep reference
self.settings_dlg = SettingsDialog()
self.info_dlg = AboutDialog()
# Declare instance attributes
self.service_actions = []
self.service_layers = [] # TODO: id and smart remove
self._scales_list = None
# TileLayer assets
self.crs3857 = None
self.downloadTimeout = 30 # TODO: settings
self.navigationMessagesEnabled = Qt.Checked # TODO: settings
self.pluginName = 'QuickMapServices'
# noinspection PyMethodMayBeStatic
def tr(self, message):
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('QuickMapServices', message)
def initGui(self):
#import pydevd
#pydevd.settrace('localhost', port=9921, stdoutToServer=True, stderrToServer=True, suspend=False)
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
# Main Menu
icon_path = self.plugin_dir + '/icons/mActionAddLayer.png'
self.menu = QMenu(self.tr(u'QuickMapServices'))
self.menu.setIcon(QIcon(icon_path))
# DataSources Actions
# Register plugin layer type
self.tileLayerType = TileLayerType(self)
QgsPluginLayerRegistry.instance().addPluginLayerType(self.tileLayerType)
self.groups_list = DsGroupsList(self.locale, self.custom_translator)
self.ds_list = DataSourcesList(self.locale, self.custom_translator)
data_sources = self.ds_list.data_sources.values()
data_sources.sort(key=lambda x: x.alias or x.id)
for ds in data_sources:
ds.action.triggered.connect(self.insert_layer)
gr_menu = self.groups_list.get_group_menu(ds.group)
gr_menu.addAction(ds.action)
if gr_menu not in self.menu.children():
self.menu.addMenu(gr_menu)
# Scales, Settings and About actions
icon_set_nearest_scale_path = self.plugin_dir + '/icons/mActionSettings.png' # TODO change icon
set_nearest_scale_act = QAction(QIcon(icon_set_nearest_scale_path), self.tr('Set proper scale'), self.iface.mainWindow())
set_nearest_scale_act.triggered.connect(self.set_nearest_scale)
self.menu.addAction(set_nearest_scale_act) # TODO: uncomment after fix
self.service_actions.append(set_nearest_scale_act)
icon_scales_path = self.plugin_dir + '/icons/mActionSettings.png' # TODO change icon
scales_act = QAction(QIcon(icon_scales_path), self.tr('Set SlippyMap scales'), self.iface.mainWindow())
scales_act.triggered.connect(self.set_tms_scales)
#self.menu.addAction(scales_act) # TODO: uncomment after fix
self.service_actions.append(scales_act)
icon_settings_path = self.plugin_dir + '/icons/mActionSettings.png'
settings_act = QAction(QIcon(icon_settings_path), self.tr('Settings'), self.iface.mainWindow())
self.service_actions.append(settings_act)
#.........这里部分代码省略.........
示例10: FileController_OpusData
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
#.........这里部分代码省略.........
# if tsitem.node().hasChildNodes():
# tschildren = tsitem.node().childNodes()
# for x in xrange(0,tschildren.count(),1):
# if tschildren.item(x).isElement():
# tselement = tschildren.item(x).toElement()
# if tselement.hasAttribute(QString("type")) and \
# (tselement.attribute(QString("type")) == QString("acts_on")):
# if tselement.hasChildNodes():
# classchildren = tselement.childNodes()
# for x in xrange(0,classchildren.count(),1):
# if classchildren.item(x).isText():
# print "Found some text in the classification element"
# classificationtext = classchildren.item(x).nodeValue()
# classificationtext = str(classchildren.item(x).nodeValue()).split(',')
# if tselement.hasAttribute(QString("type")) and \
# (tselement.attribute(QString("type")) == QString("exports_to")):
# print tselement.text()
# export_to_text = tselement.text()
# tagName = tsitem.domNode.toElement().tagName()
# for i in classificationtext:
# if i != "" and i == classification:
# choices[tagName] = export_to_text
# self.classification = classification
# return choices
def dataActionMenuFunction(self,action):
QObject.disconnect(self.menu, SIGNAL("triggered(QAction*)"),self.dataActionMenuFunction)
if action != self.actRefresh:
actiontext = str(action.text())
tool_node = self.dynactions[actiontext]
filename = self.model.fileName(self.currentIndex)
filepath = self.model.filePath(self.currentIndex)
parentfilepath = self.model.filePath(self.currentIndex.parent())
params = self.getOptionalParams()
window = ExecuteToolGui(parent_widget = self.treeview,
tool_node = tool_node,
tool_config = None,
tool_library_node = self.tool_library_node,
params=params)
window.show()
return
def getOptionalParams(self):
params = {'tool_path': get_path_to_tool_modules(self.manager.project)}
if self.classification == 'database':
params['opus_data_directory'] = str(self.model.filePath(self.currentIndex.parent()))
params['opus_data_year'] = str(self.model.fileName(self.currentIndex))
params['opus_table_name'] = 'ALL'
elif self.classification == 'dataset':
params['opus_data_directory'] = str(self.model.filePath(self.currentIndex.parent().parent()))
params['opus_data_year'] = str(self.model.fileName(self.currentIndex.parent()))
params['opus_table_name'] = str(self.model.fileName(self.currentIndex))
return params
def process_custom_menu(self, position):
self.currentColumn = self.treeview.indexAt(position).column()
self.currentIndex = self.treeview.indexAt(position)
self.menu = QMenu(self.treeview)
if self.currentIndex.isValid():
if self.model.fileInfo(self.currentIndex).suffix() == "txt":
self.menu.addAction(self.actOpenTextFile)
else:
# Do stuff for directories
choices = self.fillInAvailableTools()
if self.classification == "dataset":
self.export_menu = QMenu(QString('Export Opus dataset to'), self.treeview)
self.export_menu.setIcon(IconLibrary.icon('export'))
if len(choices) > 0:
self.dynactions = {}
for export_type,tool_node in choices.iteritems():
dynaction = QAction(IconLibrary.icon('spreadsheet'), export_type, self.treeview)
self.export_menu.addAction(dynaction)
self.dynactions[export_type] = tool_node
QObject.connect(self.export_menu, SIGNAL("triggered(QAction*)"),
self.dataActionMenuFunction)
self.menu.addMenu(self.export_menu)
self.menu.addSeparator()
# We need to provide the option to open the dataset
self.menu.addAction(self.actViewDataset)
if self.classification == "database":
self.export_menu = QMenu(QString('Export Opus database to'))
self.export_menu.setIcon(IconLibrary.icon('export'))
if len(choices) > 0:
self.dynactions = {}
for export_type,tool_node in choices.iteritems():
dynaction = QAction(IconLibrary.icon('spreadsheet'), export_type, self.treeview)
self.export_menu.addAction(dynaction)
self.dynactions[export_type] = tool_node
QObject.connect(self.export_menu, SIGNAL("triggered(QAction*)"),
self.dataActionMenuFunction)
self.menu.addMenu(self.export_menu)
self.menu.addSeparator()
# Now tack on a refresh for all right clicks
#print "Setting model refresh"
self.menu.addAction(self.actRefresh)
self.menu.exec_(QCursor.pos())
示例11: CartoDBPlugin
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
class CartoDBPlugin(QObject):
# initialize plugin directory
PLUGIN_DIR = os.path.dirname(os.path.abspath(__file__))
def __init__(self, iface):
QObject.__init__(self)
QgsMessageLog.logMessage('GDAL Version: ' + str(gdal.VersionInfo('VERSION_NUM')), 'CartoDB Plugin', QgsMessageLog.INFO)
# Save reference to the QGIS interface
self.iface = iface
# initialize locale
locale = QSettings().value("locale/userLocale")[0:2]
localePath = os.path.join(CartoDBPlugin.PLUGIN_DIR, "i18n", "{}.qm".format(locale))
if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# SQLite available?
driverName = "SQLite"
self.sqLiteDrv = ogr.GetDriverByName(driverName)
if self.sqLiteDrv is None:
QgsMessageLog.logMessage('SQLite driver not found', 'CartoDB Plugin', QgsMessageLog.CRITICAL)
else:
QgsMessageLog.logMessage('SQLite driver is found', 'CartoDB Plugin', QgsMessageLog.INFO)
self.databasePath = CartoDBPlugin.PLUGIN_DIR + '/db/database.sqlite'
shutil.copyfile(CartoDBPlugin.PLUGIN_DIR + '/db/init_database.sqlite', self.databasePath)
self.layers = []
self.countLoadingLayers = 0
self.countLoadedLayers = 0
self._cdbMenu = None
self._mainAction = None
self._loadDataAction = None
self._createVizAction = None
self._addSQLAction = None
self.toolbar = CartoDBToolbar()
self._toolbarAction = None
self._menu = None
def initGui(self):
self._cdbMenu = QMenu("CartoDB plugin", self.iface.mainWindow())
self._cdbMenu.setIcon(QIcon(":/plugins/qgis-cartodb/images/icon.png"))
self._mainAction = QAction(self.tr('Add CartoDB Layer'), self.iface.mainWindow())
self._mainAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/add.png"))
self._loadDataAction = QAction(self.tr('Upload layers to CartoDB'), self.iface.mainWindow())
self._loadDataAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/upload.png"))
self._createVizAction = QAction(self.tr('Create New Map'), self.iface.mainWindow())
self._createVizAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/map.png"))
self._addSQLAction = QAction(self.tr('Add SQL CartoDB Layer'), self.iface.mainWindow())
self._addSQLAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/sql.png"))
self.toolbar.setClick(self.connectionManager)
self.toolbar.error.connect(self.toolbarError)
self._toolbarAction = self.iface.addWebToolBarWidget(self.toolbar)
worker = CartoDBPluginWorker(self.toolbar, 'connectCartoDB')
worker.start()
if not self.toolbar.isCurrentUserValid():
self._mainAction.setEnabled(False)
self._loadDataAction.setEnabled(False)
self._createVizAction.setEnabled(False)
self._addSQLAction.setEnabled(False)
self._mainAction.triggered.connect(self.run)
self._loadDataAction.triggered.connect(self.upload)
self._createVizAction.triggered.connect(self.createNewMap)
self._addSQLAction.triggered.connect(self.addSQL)
self._cdbMenu.addAction(self._mainAction)
self._cdbMenu.addAction(self._loadDataAction)
self._cdbMenu.addAction(self._createVizAction)
self._cdbMenu.addAction(self._addSQLAction)
try:
self.iface.layerToolBar().addAction(self._mainAction)
except:
self.iface.addWebToolBarIcon(self._mainAction)
self.iface.addWebToolBarIcon(self._loadDataAction)
self.iface.addWebToolBarIcon(self._createVizAction)
try:
self.iface.layerToolBar().addAction(self._addSQLAction)
except:
self.iface.addWebToolBarIcon(self._addSQLAction)
# Create Web menu, if it doesn't exist yet
tmpAction = QAction("Temporal", self.iface.mainWindow())
self.iface.addPluginToWebMenu("_tmp", tmpAction)
self._menu = self.iface.webMenu()
self._menu.addMenu(self._cdbMenu)
self.iface.removePluginWebMenu("_tmp", tmpAction)
# Register plugin layer type
self.pluginLayerType = CartoDBPluginLayerType(self.iface, self.createLayerCB)
QgsPluginLayerRegistry.instance().addPluginLayerType(self.pluginLayerType)
def unload(self):
#.........这里部分代码省略.........
示例12: get_plugin_actions
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def get_plugin_actions(self):
"""Setup actions"""
quit_action = create_action(self, self.tr("&Quit"), self.tr("Ctrl+Q"),
'exit.png', self.tr("Quit"),
triggered=self.quit)
run_action = create_action(self, self.tr("&Run..."), None,
'run_small.png', self.tr("Run a Python script"),
triggered=self.run_script)
environ_action = create_action(self,
self.tr("Environment variables..."),
icon = 'environ.png',
tip=self.tr("Show and edit environment variables"
" (for current session)"),
triggered=self.show_env)
syspath_action = create_action(self,
self.tr("Show sys.path contents..."),
icon = 'syspath.png',
tip=self.tr("Show (read-only) sys.path"),
triggered=show_syspath)
buffer_action = create_action(self,
self.tr("Buffer..."), None,
tip=self.tr("Set maximum line count"),
triggered=self.change_max_line_count)
font_action = create_action(self,
self.tr("&Font..."), None,
'font.png', self.tr("Set shell font style"),
triggered=self.change_font)
exteditor_action = create_action(self,
self.tr("External editor path..."), None, None,
self.tr("Set external editor executable path"),
triggered=self.change_exteditor)
wrap_action = create_action(self,
self.tr("Wrap lines"),
toggled=self.toggle_wrap_mode)
wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
calltips_action = create_action(self, self.tr("Balloon tips"),
toggled=self.toggle_calltips)
calltips_action.setChecked( CONF.get(self.ID, 'calltips') )
codecompletion_action = create_action(self,
self.tr("Automatic code completion"),
toggled=self.toggle_codecompletion)
codecompletion_action.setChecked( CONF.get(self.ID,
'codecompletion/auto') )
codecompenter_action = create_action(self,
self.tr("Enter key selects completion"),
toggled=self.toggle_codecompletion_enter)
codecompenter_action.setChecked( CONF.get(self.ID,
'codecompletion/enter-key') )
option_menu = QMenu(self.tr("Internal console settings"), self)
option_menu.setIcon(get_icon('tooloptions.png'))
add_actions(option_menu, (buffer_action, font_action, wrap_action,
calltips_action, codecompletion_action,
codecompenter_action, exteditor_action))
menu_actions = [None, run_action, environ_action, syspath_action,
option_menu, None, quit_action]
toolbar_actions = []
# Add actions to context menu
add_actions(self.shell.menu, menu_actions)
return menu_actions, toolbar_actions
示例13: set_actions
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def set_actions(self):
"""Setup actions"""
quit_action = create_action(self, self.tr("&Quit"), self.tr("Ctrl+Q"),
'exit.png', self.tr("Quit"),
triggered=self.quit)
run_action = create_action(self, self.tr("&Run..."), None,
'run_small.png', self.tr("Run a Python script"),
triggered=self.run_script)
environ_action = create_action(self,
self.tr("Environment variables..."),
icon = 'environ.png',
tip=self.tr("Show and edit environment variables"
" (for current session)"),
triggered=self.show_env)
syspath_action = create_action(self,
self.tr("Show sys.path contents..."),
icon = 'syspath.png',
tip=self.tr("Show (read-only) sys.path"),
triggered=show_syspath)
font_action = create_action(self,
self.tr("&Font..."), None,
'font.png', self.tr("Set shell font style"),
triggered=self.change_font)
exteditor_action = create_action(self,
self.tr("External editor path..."), None, None,
self.tr("Set external editor executable path"),
triggered=self.change_exteditor)
wrap_action = create_action(self,
self.tr("Wrap lines"),
toggled=self.toggle_wrap_mode)
wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
calltips_action = create_action(self, self.tr("Balloon tips"),
toggled=self.toggle_calltips)
calltips_action.setChecked( CONF.get(self.ID, 'calltips') )
codecompletion_action = create_action(self, self.tr("Code completion"),
toggled=self.toggle_codecompletion)
codecompletion_action.setChecked( CONF.get(self.ID,
'autocompletion/enabled') )
codecompenter_action = create_action(self,
self.tr("Enter key selects completion"),
toggled=self.toggle_codecompletion_enter)
codecompenter_action.setChecked( CONF.get(self.ID,
'autocompletion/enter-key') )
rollbackimporter_action = create_action(self,
self.tr("Force modules to be completely reloaded"),
tip=self.tr("Force Python to reload modules imported when "
"executing a script in the interactive console"),
toggled=self.toggle_rollbackimporter)
rollbackimporter_action.setChecked( CONF.get(self.ID,
'rollback_importer') )
try:
imp.find_module('matplotlib')
dockablefigures_action = create_action(self,
self.tr("Dockable figures"),
tip=self.tr("If enabled, matplotlib figures may "
"be docked to Spyder's main window "
"(will apply only for new figures)"),
toggled=self.toggle_dockablefigures_mode)
dockablefigures_action.setChecked( CONF.get('figure', 'dockable') )
except ImportError:
dockablefigures_action = None
option_menu = QMenu(self.tr("Interactive console settings"), self)
option_menu.setIcon(get_icon('tooloptions.png'))
add_actions(option_menu, (font_action, wrap_action, calltips_action,
codecompletion_action, codecompenter_action,
rollbackimporter_action, exteditor_action,
dockablefigures_action))
menu_actions = [None, run_action, environ_action, syspath_action,
option_menu, None, quit_action]
toolbar_actions = []
# Add actions to context menu
add_actions(self.shell.menu, menu_actions)
return menu_actions, toolbar_actions
示例14: MSMainWindow
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
class MSMainWindow(QMainWindow):
"""Gui of the main window"""
# MAX_RECENT_FILES = 10
# start putting links spyder numpy scipy et tutti quanti
links = (
"http://numpy.scipy.org/",
"http://packages.python.org/spyder/",
"http://www.riverbankcomputing.co.uk/software/pyqt/intro",
)
pluginPath = path.normcase("pluginmanager/plugins/")
def __init__(self, availablePlugins):
"""
Constructor with all the models needed setup menus
"""
QMainWindow.__init__(self)
self.setDockOptions(QMainWindow.VerticalTabs | QMainWindow.AnimatedDocks)
self.plugins = availablePlugins
self.pluginsInst = []
settings = QSettings(
"INRA/INSA", "-".join([QApplication.instance().APPLICATION_NAME_STR, QApplication.instance().VERSION_STR])
)
self.recentFiles = list(settings.value("RecentFiles").toStringList())
self.setStyleSheet(stylesheet)
self.pipeline = MSPipelineToolBar("Pipeline toolbar", parent=self)
self.addToolBar(0x1, self.pipeline)
self._setupModels()
self._setupUi()
self._setupMenus()
def _setupModels(self):
"""
Warning:Causes segfault when horizontal labels set to True
on aura peu etre a la fin un model par sampleList c'est ce qui parait
le plus logique
"""
# drag and drop table sample
self.sampleModel = QStandardItemModel(self)
self.sampleModel.setHorizontalHeaderLabels(["Sample", "Class"])
# treeView1
self.spectraModel = QStandardItemModel(self)
# treeview2
self.peakModel = QStandardItemModel(self)
# treeview3
self.clusterModel = QStandardItemModel(self)
def _setupMenus(self):
# file
self.fileMenu = QMenu("&File")
self.fileMenu.setTearOffEnabled(True)
self.op = QMenu("&Open...", self.fileMenu)
self.op.setIcon(QIcon(path.normcase("gui/icons/fileopen.png")))
open_ = QAction("&Open rawfiles", self)
open_.setToolTip("Open an mzXML or netCDF file")
open_.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_O))
open_icon = QIcon(path.normcase("gui/icons/fileopen.png"))
open_.setIcon(open_icon)
self.op.addAction(open_)
load_ = QAction("&Open projects...", self)
load_.setToolTip("load binary file containing saved objects")
load_.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_S))
load_icon = QIcon(QPixmap(path.normcase("gui/icons/project_open.png")))
load_.setIcon(load_icon)
self.op.addAction(load_)
self.fileMenu.addMenu(self.op)
save_ = QAction("&Save...", self)
save_.setToolTip("save the actual application model")
save_.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_S))
save_icon = QIcon(path.normcase("gui/icons/save_all.png"))
save_.setIcon(save_icon)
self.fileMenu.addAction(save_)
pkl = QAction("&load a peaklist", self) # TODO:load peaklist
pkl.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_P))
pkl.setToolTip("load a peaklist and process it")
pkl.setIcon(QIcon(path.normcase("gui/icons/featuredetect.png")))
self.fileMenu.addAction(pkl)
convert_ = QAction("&Convert...", self)
convert_.setEnabled(False)
convert_.setToolTip("Convert a .wiff file if Analyst(c) is installed")
convert_icon = QIcon(path.normcase("gui/icons/goto.png"))
convert_.setIcon(convert_icon)
self.fileMenu.addAction(convert_)
a = self.fileMenu.addAction(QIcon(path.normcase("gui/icons/process.png")), "&Launch a batch")
a.setEnabled(False)
b = self.fileMenu.addAction(QIcon(path.normcase("gui/icons/process.png")), "&Merge")
b.setToolTip("Merge MRM file")
#.........这里部分代码省略.........
示例15: set_actions
# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import setIcon [as 别名]
def set_actions(self):
"""Setup actions"""
import_action = create_action(self, self.tr("Import data..."), None,
'ws_open.png', self.tr("Import data to workspace"),
triggered=self.import_data)
save_as_action = create_action(self, self.tr("Save workspace as..."),
None, 'ws_save_as.png', self.tr("Save workspace as..."),
triggered = self.save_as)
exclude_private_action = create_action(self,
self.tr("Exclude private references"),
tip=self.tr("Exclude references which name starts"
" with an underscore"),
toggled=self.toggle_exclude_private)
exclude_private_action.setChecked(CONF.get(self.ID, 'exclude_private'))
exclude_upper_action = create_action(self,
self.tr("Exclude capitalized references"),
tip=self.tr("Exclude references which name starts with an "
"upper-case character"),
toggled=self.toggle_exclude_upper)
exclude_upper_action.setChecked( CONF.get(self.ID, 'exclude_upper') )
exclude_unsupported_action = create_action(self,
self.tr("Exclude unsupported data types"),
tip=self.tr("Exclude references to unsupported data types"
" (i.e. which won't be handled/saved correctly)"),
toggled=self.toggle_exclude_unsupported)
exclude_unsupported_action.setChecked(CONF.get(self.ID,
'exclude_unsupported'))
refresh_action = create_action(self, self.tr("Refresh workspace"),
None, 'ws_refresh.png', self.tr("Refresh workspace"),
triggered = self.refresh_editor)
autorefresh_action = create_action(self, self.tr("Auto refresh"),
toggled=self.toggle_autorefresh)
autorefresh_action.setChecked( CONF.get(self.ID, 'autorefresh') )
autosave_action = create_action(self, self.tr("Auto save"),
toggled=self.toggle_autosave,
tip=self.tr("Automatically save workspace in a temporary file"
" when quitting"))
autosave_action.setChecked( CONF.get(self.ID, 'autosave') )
clear_action = create_action(self, self.tr("Clear workspace"),
icon=get_icon('clear.png'),
tip=self.tr("Clear all data from workspace"),
triggered=self.clear)
font_action1 = create_action(self, self.tr("Header Font..."),
None, 'font.png',
self.tr("Set font style"),
triggered=self.change_font1)
font_action2 = create_action(self, self.tr("Value Font..."),
None, 'font.png',
self.tr("Set font style"),
triggered=self.change_font2)
option_menu = QMenu(self.tr("Workspace settings"), self)
option_menu.setIcon(get_icon('tooloptions.png'))
add_actions(option_menu, (autosave_action, None,
self.truncate_action, self.inplace_action, None,
exclude_private_action, exclude_upper_action,
exclude_unsupported_action,
font_action1, font_action2))
menu_actions = (import_action, save_as_action,
refresh_action, autorefresh_action, clear_action,
option_menu)
toolbar_actions = (refresh_action, import_action, save_as_action)
return (menu_actions, toolbar_actions)