本文整理汇总了Python中qtpy.QtWidgets.QMenu.addAction方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addAction方法的具体用法?Python QMenu.addAction怎么用?Python QMenu.addAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QMenu
的用法示例。
在下文中一共展示了QMenu.addAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_contextmenu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def show_contextmenu(self, pos: QPoint):
menu = QMenu(self)
index = self.currentIndex()
node = index.internalPointer()
# insert item and node
menu.addAction(self.insertitemAction)
menu.addAction(self.insertnodeAction)
# edit key
if isinstance(node, (JsonNode, JsonItem)):
menu.addSeparator()
menu.addAction(self.editkeyAction)
if isinstance(node, JsonItem):
menu.addAction(self.editAction)
self.editAction.setEnabled(not node.readonly)
# remove
if isinstance(node, (JsonNode, JsonItem)):
menu.addSeparator()
menu.addAction(self.removeitemAction)
# properties
if isinstance(node, JsonItem):
menu.addSeparator()
menu.addAction(self.propertiesAction)
menu.setDefaultAction(self.propertiesAction)
menu.popup(self.viewport().mapToGlobal(pos), self.editAction)
示例2: tableMenu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def tableMenu(self, event):
"""Right click menu for table, can plot or print selected logs"""
menu = QMenu(self)
plotAction = menu.addAction("Plot selected")
plotAction.triggered.connect(self.presenter.new_plot_logs)
plotAction = menu.addAction("Print selected")
plotAction.triggered.connect(self.presenter.print_selected_logs)
menu.exec_(event.globalPos())
示例3: context_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def context_menu(self):
try:
menu = super(PyDMRelatedDisplayButton, self).context_menu()
except:
menu = QMenu(self)
if len(menu.findChildren(QAction)) > 0:
menu.addSeparator()
menu.addAction(self.open_in_new_window_action)
return menu
示例4: context_menu_requested
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def context_menu_requested(self, event):
"""Popup context menu."""
if self.fig:
pos = QPoint(event.x(), event.y())
context_menu = QMenu(self)
context_menu.addAction(ima.icon('editcopy'), "Copy Image",
self.copy_figure,
QKeySequence(
get_shortcut('plots', 'copy')))
context_menu.popup(self.mapToGlobal(pos))
示例5: _display_roi_context_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _display_roi_context_menu(self, roi_index):
def delete_roi(event):
self._dc.remove_subset_group(self._dc.subset_groups[roi_index])
context_menu = QMenu()
action = QAction("Delete ROI", context_menu)
action.triggered.connect(delete_roi)
context_menu.addAction(action)
pos = self._viewer.mapToParent(QCursor().pos())
context_menu.exec_(pos)
示例6: _make_export_button
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _make_export_button(self):
"""
Makes the export button menu, containing a list of export
types
:return: The export button menu
"""
export_button = QPushButton("Export")
export_menu = QMenu()
for text, extension in EXPORT_TYPES:
export_menu.addAction(text, lambda ext=extension: self.presenter.export_plots_called(ext))
export_button.setMenu(export_menu)
return export_button
示例7: _init_ui
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _init_ui(self):
loadUi(os.path.abspath(
os.path.join(os.path.dirname(__file__),
".", "model_editor.ui")), self)
# Populate the add mode button with a dropdown containing available
# fittable model objects
self.add_model_button.setPopupMode(QToolButton.InstantPopup)
models_menu = QMenu(self.add_model_button)
self.add_model_button.setMenu(models_menu)
for k, v in MODELS.items():
action = QAction(k, models_menu)
action.triggered.connect(lambda x, m=v: self._add_fittable_model(m))
models_menu.addAction(action)
self.fit_model_thread = None
# Initially hide the model editor tools until user has selected an
# editable model spectrum object
self.editor_holder_widget.setHidden(True)
self.setup_holder_widget.setHidden(False)
self.equation_edit_button.clicked.connect(
self._on_equation_edit_button_clicked)
self.new_model_button.clicked.connect(self._on_create_new_model)
self.remove_model_button.clicked.connect(self._on_remove_model)
self.advanced_settings_button.clicked.connect(
lambda: ModelAdvancedSettingsDialog(self, self).exec())
self.save_model_button.clicked.connect(self._on_save_model)
self.load_model_button.clicked.connect(self._on_load_from_file)
self._data_item_proxy_model = DataItemProxyModel()
self._data_item_proxy_model.setSourceModel(self.hub.model)
self.data_selection_combo.setModel(self._data_item_proxy_model)
self.data_selection_combo.currentIndexChanged.connect(self._redraw_model)
# When a plot data item is select, get its model editor model
# representation
self.hub.workspace.current_selected_changed.connect(
self._on_plot_item_selected)
# When the plot window changes, reset model editor
self.hub.workspace.mdi_area.subWindowActivated.connect(self._on_new_plot_activated)
# Listen for when data items are added to internal model
self.hub.model.data_added.connect(self._on_data_item_added)
# Connect the fit model button
self.fit_button.clicked.connect(self._on_fit_clicked)
示例8: openWidgetMenu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def openWidgetMenu(self,position):
indexes = self.ui.treeWidget_2.selectedIndexes()
item = self.ui.treeWidget_2.itemAt(position)
if item == None:
return
#item = self.ui.listWidget.itemAt(position)
if len(indexes) > 0:
menu = QMenu()
menu.addAction(QAction("Delete", menu,checkable = True))#This function is perhaps useless
#menu.triggered.connect(self.eraseItem)
item = self.ui.treeWidget_2.itemAt(position)
#collec = str(item.text())
menu.triggered.connect(lambda action: self.ListMethodSelected(action, item))
menu.exec_(self.ui.treeWidget_2.viewport().mapToGlobal(position))
示例9: build_context_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def build_context_menu(self, index):
"""Build context menu for test item that given index points to."""
contextMenu = QMenu(self)
if self.isExpanded(index):
menuItem = create_action(self, _('Collapse'),
triggered=lambda: self.collapse(index))
else:
menuItem = create_action(self, _('Expand'),
triggered=lambda: self.expand(index))
menuItem.setEnabled(self.model().hasChildren(index))
contextMenu.addAction(menuItem)
menuItem = create_action(
self, _('Go to definition'),
triggered=lambda: self.go_to_test_definition(index))
test_location = self.model().data(index, Qt.UserRole)
menuItem.setEnabled(test_location[0] is not None)
contextMenu.addAction(menuItem)
return contextMenu
示例10: _dict_to_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _dict_to_menu(self, menu_dict, menu_widget=None):
'''Stolen shamelessly from specviz. Thanks!'''
if not menu_widget:
menu_widget = QMenu()
for k, v in menu_dict.items():
if isinstance(v, dict):
new_menu = menu_widget.addMenu(k)
self._dict_to_menu(v, menu_widget=new_menu)
else:
act = QAction(k, menu_widget)
if isinstance(v, list):
if v[0] == 'checkable':
v = v[1]
act.setCheckable(True)
act.setChecked(False)
act.triggered.connect(v)
menu_widget.addAction(act)
return menu_widget
示例11: _add_axes_scale_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _add_axes_scale_menu(self, menu):
"""Add the Axes scale options menu to the given menu"""
axes_menu = QMenu("Axes", menu)
axes_actions = QActionGroup(axes_menu)
current_scale_types = self._get_axes_scale_types()
for label, scale_types in iteritems(AXES_SCALE_MENU_OPTS):
action = axes_menu.addAction(label, partial(self._quick_change_axes, scale_types))
if current_scale_types == scale_types:
action.setCheckable(True)
action.setChecked(True)
axes_actions.addAction(action)
menu.addMenu(axes_menu)
示例12: initialize_toolbar
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def initialize_toolbar(self):
"""
"""
# Merge the main tool bar and the plot tool bar to get back some
# real estate
self.current_workspace.addToolBar(
self.current_workspace.current_plot_window.tool_bar)
self.current_workspace.main_tool_bar.setIconSize(QSize(15, 15))
# Hide the first five actions in the default specviz tool bar
for act in self.current_workspace.main_tool_bar.actions()[:6]:
act.setVisible(False)
# Hide the tabs of the mdiarea in specviz.
self.current_workspace.mdi_area.setViewMode(QMdiArea.SubWindowView)
self.current_workspace.current_plot_window.setWindowFlags(Qt.FramelessWindowHint)
self.current_workspace.current_plot_window.showMaximized()
if self._layout is not None:
cube_ops = QAction(QIcon(":/icons/cube.svg"), "Cube Operations",
self.current_workspace.main_tool_bar)
self.current_workspace.main_tool_bar.addAction(cube_ops)
self.current_workspace.main_tool_bar.addSeparator()
button = self.current_workspace.main_tool_bar.widgetForAction(cube_ops)
button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self.current_workspace.main_tool_bar)
button.setMenu(menu)
# Create operation actions
menu.addSection("2D Operations")
act = QAction("Simple Linemap", self)
act.triggered.connect(lambda: simple_linemap(self))
menu.addAction(act)
act = QAction("Fitted Linemap", self)
act.triggered.connect(lambda: fitted_linemap(self))
menu.addAction(act)
menu.addSection("3D Operations")
act = QAction("Fit Spaxels", self)
act.triggered.connect(lambda: fit_spaxels(self))
menu.addAction(act)
act = QAction("Spectral Smoothing", self)
act.triggered.connect(lambda: spectral_smoothing(self))
menu.addAction(act)
示例13: _make_sort_button
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _make_sort_button(self):
"""
Make the sort button, with separate groups for ascending and
descending, sorting by name or last shown
:return: The sort menu button
"""
sort_button = QPushButton("Sort")
sort_menu = QMenu()
ascending_action = QAction("Ascending", sort_menu, checkable=True)
ascending_action.setChecked(True)
ascending_action.toggled.connect(self.presenter.set_sort_order)
descending_action = QAction("Descending", sort_menu, checkable=True)
order_group = QActionGroup(sort_menu)
order_group.addAction(ascending_action)
order_group.addAction(descending_action)
number_action = QAction("Number", sort_menu, checkable=True)
number_action.setChecked(True)
number_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.Number))
name_action = QAction("Name", sort_menu, checkable=True)
name_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.Name))
last_active_action = QAction("Last Active", sort_menu, checkable=True)
last_active_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.LastActive))
sort_type_group = QActionGroup(sort_menu)
sort_type_group.addAction(number_action)
sort_type_group.addAction(name_action)
sort_type_group.addAction(last_active_action)
sort_menu.addAction(ascending_action)
sort_menu.addAction(descending_action)
sort_menu.addSeparator()
sort_menu.addAction(number_action)
sort_menu.addAction(name_action)
sort_menu.addAction(last_active_action)
sort_button.setMenu(sort_menu)
return sort_button
示例14: _make_context_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _make_context_menu(self):
"""
Makes the context menu with options relating to plots
:return: The context menu, and export sub-menu with a list of
export types
"""
context_menu = QMenu()
context_menu.addAction("Show", self.presenter.show_multiple_selected)
context_menu.addAction("Hide", self.presenter.hide_selected_plots)
context_menu.addAction("Delete", self.presenter.close_action_called)
context_menu.addAction("Rename", self.rename_selected_in_context_menu)
export_menu = context_menu.addMenu("Export")
for text, extension in EXPORT_TYPES:
export_menu.addAction(text, lambda ext=extension: self.presenter.export_plots_called(ext))
return context_menu, export_menu
示例15: _rebuild_menu
# 需要导入模块: from qtpy.QtWidgets import QMenu [as 别名]
# 或者: from qtpy.QtWidgets.QMenu import addAction [as 别名]
def _rebuild_menu(self):
if not any(self._filenames):
self._filenames = []
if not any(self._titles):
self._titles = []
if len(self._filenames) == 0:
self.setEnabled(False)
if len(self._filenames) <= 1:
self.setMenu(None)
self._menu_needs_rebuild = False
return
menu = QMenu(self)
for i, filename in enumerate(self._filenames):
if i >= len(self._titles):
title = filename
else:
title = self._titles[i]
action = menu.addAction(title)
macros = ""
if i < len(self._macros):
macros = self._macros[i]
action.triggered.connect(partial(self.open_display, filename, macros, target=None))
self.setMenu(menu)
self._menu_needs_rebuild = False