Python PyQt5.QtWidgets.QAction() Examples
The following are 30
code examples of PyQt5.QtWidgets.QAction().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtWidgets
, or try the search function
.
Example #1
Source File: mainwindow.py From dcc with Apache License 2.0 | 7 votes |
def __init__(self, bin_windows, parent=None): super(TabsWindow, self).__init__(parent) self.bin_windows = bin_windows self.setTabsClosable(True) self.tabCloseRequested.connect(self.tabCloseRequestedHandler) self.currentChanged.connect(self.currentTabChanged) self.closeAllTabs = QtWidgets.QAction( "Close all tabs", self, triggered=self.actioncloseAllTabs) self.closeOtherTabs = QtWidgets.QAction( "Close other tabs", self, triggered=self.actioncloseOtherTabs) self.closeLeftTabs = QtWidgets.QAction( "Close left tabs", self, triggered=self.actioncloseLeftTabs) self.closeRightTabs = QtWidgets.QAction( "Close right tabs", self, triggered=self.actioncloseRightTabs)
Example #2
Source File: first.py From FIRST-plugin-ida with GNU General Public License v2.0 | 7 votes |
def custom_menu(self, point): index = self.tree_view.indexAt(point) address = index.data(FIRSTUI.ROLE_ADDRESS) if not address: return menu = QtWidgets.QMenu(self.tree_view) goto_action = QtWidgets.QAction('&Go to Function', self.tree_view) goto_action.triggered.connect(lambda:IDAW.Jump(address)) menu.addAction(goto_action) metadata_id = index.data(FIRSTUI.ROLE_ID) if metadata_id: history_action = QtWidgets.QAction('View &History', self.tree_view) history_action.triggered.connect(lambda:self.metadata_history(metadata_id)) menu.addAction(history_action) menu.exec_(QtGui.QCursor.pos())
Example #3
Source File: telemetry.py From sparrow-wifi with GNU General Public License v3.0 | 6 votes |
def createTable(self): # Set up location table self.locationTable = QTableWidget(self) self.locationTable.setColumnCount(8) self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2) self.locationTable.setShowGrid(True) self.locationTable.setHorizontalHeaderLabels(['macAddr','SSID', 'Strength', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude']) self.locationTable.resizeColumnsToContents() self.locationTable.setRowCount(0) self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.ntRightClickMenu = QMenu(self) newAct = QAction('Copy', self) newAct.setStatusTip('Copy data to clipboard') newAct.triggered.connect(self.onCopy) self.ntRightClickMenu.addAction(newAct) self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu) self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu)
Example #4
Source File: synchronizer.py From linux-show-player with GNU General Public License v3.0 | 6 votes |
def __init__(self): self.syncMenu = QMenu(translate('Synchronizer', 'Synchronization')) self.menu_action = MainWindow().menuTools.addMenu(self.syncMenu) self.addPeerAction = QAction( translate('Synchronizer', 'Manage connected peers'), MainWindow()) self.addPeerAction.triggered.connect(self.manage_peers) self.syncMenu.addAction(self.addPeerAction) self.showIpAction = QAction( translate('Synchronizer', 'Show your IP'), MainWindow()) self.showIpAction.triggered.connect(self.show_ip) self.syncMenu.addAction(self.showIpAction) self.peers = [] self.cue_media = {}
Example #5
Source File: first.py From FIRST-plugin-ida with GNU General Public License v2.0 | 6 votes |
def applied_custom_menu(self, point): index = self.applied_tree_view.indexAt(point) address = index.data(FIRSTUI.ROLE_ADDRESS) if not address: return menu = QtWidgets.QMenu(self.applied_tree_view) goto_action = QtWidgets.QAction('&Go to Function', self.applied_tree_view) goto_action.triggered.connect(lambda:IDAW.Jump(address)) menu.addAction(goto_action) metadata_id = index.data(FIRSTUI.ROLE_ID) if metadata_id: history_action = QtWidgets.QAction('View &History', self.applied_tree_view) history_action.triggered.connect(lambda:self._metadata_history(metadata_id)) menu.addAction(history_action) menu.exec_(QtGui.QCursor.pos())
Example #6
Source File: treewindow.py From dcc with Apache License 2.0 | 6 votes |
def createActions(self): self.xrefAct = QtWidgets.QAction( "Xref from/to", self, statusTip="List the references where this element is used", triggered=self.actionXref) self.expandAct = QtWidgets.QAction("Expand", self, statusTip="Expand all the subtrees", triggered=self.actionExpand) self.collapseAct = QtWidgets.QAction("Collapse", self, statusTip="Collapse all the subtrees", triggered=self.actionCollapse)
Example #7
Source File: common.py From awesometts-anki-addon with GNU General Public License v3.0 | 6 votes |
def __init__(self, target, text, sequence, parent): """ Initializes the menu action and wires its 'triggered' event. If the specified parent is a QMenu, this new action will automatically be added to it. """ # PyQt5 uses an odd behaviour for multi-inheritance super() calls, # please see: http://pyqt.sourceforge.net/Docs/PyQt5/multiinheritance.html # Importantly there is no way to pass self.triggered to _Connector # before initialization of the QAction (and I do not know if it is # possible # to change order of initialization without changing the # order in mro). So one trick is to pass the signal it in a closure # so it will be kind of lazy evaluated later and the other option is to # pass only signal name and use getattr in _Connector. For now the latter # is used (more elegant, but less flexible). # Maybe composition would be more predictable here? super().__init__(ICON, text, parent, signal_name='triggered', target=target) self.setShortcut(sequence) self._sequence = sequence if isinstance(parent, QtWidgets.QMenu): parent.addAction(self)
Example #8
Source File: __main__.py From Lector with GNU General Public License v3.0 | 6 votes |
def generate_library_filter_menu(self, directory_list=None): self.libraryFilterMenu.clear() def generate_name(path_data): this_filter = path_data[1] if not this_filter: this_filter = os.path.basename( path_data[0]).title() return this_filter filter_actions = [] filter_list = [] if directory_list: checked = [i for i in directory_list if i[3] == QtCore.Qt.Checked] filter_list = list(map(generate_name, checked)) filter_list.sort() filter_list.append(self._translate('Main_UI', 'Manually Added')) filter_actions = [QtWidgets.QAction(i, self.libraryFilterMenu) for i in filter_list] filter_all = QtWidgets.QAction('All', self.libraryFilterMenu) filter_actions.append(filter_all) for i in filter_actions: i.setCheckable(True) i.setChecked(True) i.triggered.connect(self.set_library_filter) self.libraryFilterMenu.addActions(filter_actions) self.libraryFilterMenu.insertSeparator(filter_all) self.libraryToolBar.libraryFilterButton.setMenu(self.libraryFilterMenu)
Example #9
Source File: presets.py From linux-show-player with GNU General Public License v3.0 | 6 votes |
def __init__(self): super().__init__() if not os.path.exists(PRESETS_DIR): os.makedirs(PRESETS_DIR, exist_ok=True) # Entry in mainWindow menu self.manageAction = QAction(MainWindow()) self.manageAction.triggered.connect(self.__edit_presets) self.manageAction.setText(translate('Presets', 'Presets')) self.menu_action = MainWindow().menuTools.addAction(self.manageAction) self.loadOnCueAction = QAction(None) self.loadOnCueAction.triggered.connect(self.__load_on_cue) self.loadOnCueAction.setText(translate('Presets', 'Load preset')) self.createFromCueAction = QAction(None) self.createFromCueAction.triggered.connect(self.__create_from_cue) self.createFromCueAction.setText(translate('Presets', 'Save as preset')) CueLayout.cm_registry.add_separator() CueLayout.cm_registry.add_item(self.loadOnCueAction) CueLayout.cm_registry.add_item(self.createFromCueAction) CueLayout.cm_registry.add_separator()
Example #10
Source File: replay_gain.py From linux-show-player with GNU General Public License v3.0 | 6 votes |
def __init__(self): self._gain_thread = None # Entry in mainWindow menu self.menu = QMenu(translate('ReplayGain', 'ReplayGain / Normalization')) self.menu_action = MainWindow().menuTools.addMenu(self.menu) self.actionGain = QAction(MainWindow()) self.actionGain.triggered.connect(self.gain) self.actionGain.setText(translate('ReplayGain', 'Calculate')) self.menu.addAction(self.actionGain) self.actionReset = QAction(MainWindow()) self.actionReset.triggered.connect(self._reset_all) self.actionReset.setText(translate('ReplayGain', 'Reset all')) self.menu.addAction(self.actionReset) self.actionResetSelected = QAction(MainWindow()) self.actionResetSelected.triggered.connect(self._reset_selected) self.actionResetSelected.setText(translate('ReplayGain', 'Reset selected')) self.menu.addAction(self.actionResetSelected)
Example #11
Source File: main.py From PyQt5-Apps with GNU General Public License v3.0 | 6 votes |
def downloadWidgetContext(self, point): """downloadWidget right click menu """ popMenu = QMenu() startAThread = QAction('开始', self) pauseAThread = QAction('暂停', self) clearAThread = QAction('删除', self) startAThread.triggered.connect(lambda: self.operateAThread(1, point)) pauseAThread.triggered.connect(lambda: self.operateAThread(2, point)) clearAThread.triggered.connect(lambda: self.operateAThread(3, point)) popMenu.addAction(startAThread) popMenu.addAction(pauseAThread) popMenu.addAction(clearAThread) popMenu.exec_(QCursor.pos())
Example #12
Source File: Designer_First_UI.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 6 votes |
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(400, 300) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.actionNew = QtWidgets.QAction(MainWindow) self.actionNew.setObjectName("actionNew") self.menuFile.addAction(self.actionNew) self.menubar.addAction(self.menuFile.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
Example #13
Source File: mainWindow.py From pychemqt with GNU General Public License v3.0 | 6 votes |
def aboutToShow_MenuRecentFiles(self): self.menuRecentFiles.clear() recentFiles = [] for fname in self.recentFiles: if fname not in self.filename and QtCore.QFile.exists(fname): recentFiles.append(fname) if recentFiles: self.menuRecentFiles.addSeparator() for i, fname in enumerate(recentFiles): action = QtWidgets.QAction("&%d %s" % (i + 1, fname), self) action.setData(QtCore.QVariant(fname)) action.triggered.connect(self.loadFile) self.menuRecentFiles.addAction(action) self.menuRecentFiles.addSeparator() self.menuRecentFiles.addAction( QtGui.QIcon(IMAGE_PATH + "button/clear.png"), QtWidgets.QApplication.translate("pychemqt", "Clear"), self.clearRecentFiles) # File Manipulation
Example #14
Source File: speller.py From scudcloud with MIT License | 6 votes |
def populateContextMenu(self, menu, element): word = self.getWord(element) if self.isMisspelled(word): suggests = self.suggest(word) count = Resources.SPELL_LIMIT if len(suggests) < count: count = len(suggests) boldFont = menu.font() boldFont.setBold(True) for i in range(0, count): if isinstance(suggests[i], bytes): suggests[i] = suggests[i].decode('utf8') action = QAction(str(suggests[i]), self) action.triggered.connect(lambda:self.replaceWord(element, word)) action.setData(suggests[i]) action.setFont(boldFont) menu.addAction(action) if count == 0: menu.addAction(menu.tr("No suggestions")).setEnabled(False) menu.addSeparator();
Example #15
Source File: BPView.py From DIE with MIT License | 6 votes |
def OnCreate(self, form): """ Called when the view is created """ self.bp_tree_widget = QtWidgets.QTreeWidget() self.bp_handler = BpHandler.get_bp_handler() self.die_icons = DIE.UI.Die_Icons.get_die_icons() # Get parent widget self.parent = self.FormToPyQtWidget(form) self._add_parser_data() toolbar = QtWidgets.QToolBar() action_refresh = QtWidgets.QAction(self.die_icons.icon_refresh, "Refresh", toolbar) action_refresh.triggered.connect(self.refresh) toolbar.addAction(action_refresh) layout = QtWidgets.QGridLayout() layout.addWidget(toolbar) layout.addWidget(self.bp_tree_widget) self.parent.setLayout(layout)
Example #16
Source File: baidu_translation.py From python-code with MIT License | 6 votes |
def initMenuBar(self): ''' 初始化菜单栏 ''' menubar = self.menuBar() #self.actionExit.triggered.connect(qApp.quit) # 按下菜单栏的Exit按钮会退出程序 #self.actionExit.setStatusTip("退出程序") # 左下角状态提示 #self.actionExit.setShortcut('Ctrl+Q') # 添加快捷键 exitAct = QAction(QIcon('exit.png'), 'Exit', self) exitAct.setShortcut('Ctrl+Q') exitAct.triggered.connect(qApp.quit) fileMenu = menubar.addMenu('&File') fileMenu.addAction(exitAct) fileMenu = menubar.addMenu('&Help')
Example #17
Source File: qt.py From imperialism-remake with GNU General Public License v3.0 | 6 votes |
def create_action(icon: QtGui.QIcon, text, parent: QtWidgets.QWidget, trigger_connection=None, toggle_connection=None, checkable=False) -> QtWidgets.QAction: """ Shortcut for creation of an action and wiring. trigger_connection is the slot if the triggered signal of the QAction is fired toggle_connection is the slot if the toggled signal of the QAction is fired :param icon: :param text: :param parent: :param trigger_connection: :param toggle_connection: :param checkable: :return: The action """ action = QtWidgets.QAction(icon, text, parent) if trigger_connection is not None: action.triggered.connect(trigger_connection) if toggle_connection is not None: action.toggled.connect(toggle_connection) action.setCheckable(checkable) return action
Example #18
Source File: dmenu.py From QMusic with GNU Lesser General Public License v2.1 | 6 votes |
def creatAction(self, submenu, menuaction): if 'checkable' in menuaction: setattr(self, '%sAction' % menuaction['trigger'], QAction( QIcon(QPixmap(menuaction['icon'])), u'%s' % menuaction['name'], self, checkable=menuaction['checkable'])) else: setattr(self, '%sAction' % menuaction['trigger'], QAction( QIcon(QPixmap(menuaction['icon'])), u'%s' % menuaction['name'], self, )) action = getattr(self, '%sAction' % menuaction['trigger']) action.setShortcut(QKeySequence(menuaction['shortcut'])) submenu.addAction(action) self.qactions.update({menuaction['trigger']: action})
Example #19
Source File: QtShim.py From grap with MIT License | 6 votes |
def get_QAction(): """QAction getter.""" try: import PySide.QtGui as QtGui return QtGui.QAction except ImportError: import PyQt5.QtWidgets as QtWidgets return QtWidgets.QAction
Example #20
Source File: sources_dock.py From kite with GNU General Public License v3.0 | 6 votes |
def addSourceDelegate(self, src): def addSource(): source = src.getRepresentedSource(self.sandbox) source.lat = self.sandbox.frame.llLat source.lon = self.sandbox.frame.llLon source.easting = self.sandbox.frame.Emeter[-1] / 2 source.northing = self.sandbox.frame.Nmeter[-1] / 2 source.depth = 4*km if source: self.sandbox.addSource(source) action = QtWidgets.QAction(src.display_name, self) action.setToolTip('<span style="font-family: monospace;">' '%s</span>' % src.__represents__) action.triggered.connect(addSource) self.addAction(action) return action
Example #21
Source File: telemetry.py From sparrow-wifi with GNU General Public License v3.0 | 6 votes |
def createTable(self): # Set up location table self.locationTable = QTableWidget(self) self.locationTable.setColumnCount(10) self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2) self.locationTable.setShowGrid(True) self.locationTable.setHorizontalHeaderLabels(['macAddr','Name', 'RSSI', 'TX Power', 'Est Range (m)', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude']) self.locationTable.resizeColumnsToContents() self.locationTable.setRowCount(0) self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.ntRightClickMenu = QMenu(self) newAct = QAction('Copy', self) newAct.setStatusTip('Copy data to clipboard') newAct.triggered.connect(self.onCopy) self.ntRightClickMenu.addAction(newAct) self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu) self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu)
Example #22
Source File: Designer_First_UI_Exit.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 6 votes |
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(400, 300) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.actionNew = QtWidgets.QAction(MainWindow) self.actionNew.setObjectName("actionNew") self.actionExit = QtWidgets.QAction(MainWindow) self.actionExit.setObjectName("actionExit") self.menuFile.addAction(self.actionNew) self.menuFile.addAction(self.actionExit) self.menubar.addAction(self.menuFile.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
Example #23
Source File: namespace_widget.py From opcua-modeler with GNU General Public License v3.0 | 6 votes |
def __init__(self, view): QObject.__init__(self, view) self.view = view self.model = QStandardItemModel() self.view.setModel(self.model) delegate = MyDelegate(self.view, self) delegate.error.connect(self.error.emit) self.view.setItemDelegate(delegate) self.node = None self.view.header().setSectionResizeMode(1) self.addNamespaceAction = QAction("Add Namespace", self.model) self.addNamespaceAction.triggered.connect(self.add_namespace) self.removeNamespaceAction = QAction("Remove Namespace", self.model) self.removeNamespaceAction.triggered.connect(self.remove_namespace) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.showContextMenu) self._contextMenu = QMenu() self._contextMenu.addAction(self.addNamespaceAction) self._contextMenu.addAction(self.removeNamespaceAction)
Example #24
Source File: refnodesets_widget.py From opcua-modeler with GNU General Public License v3.0 | 6 votes |
def __init__(self, view): QObject.__init__(self, view) self.view = view self.model = QStandardItemModel() self.view.setModel(self.model) self.nodesets = [] self.server_mgr = None self.view.header().setSectionResizeMode(1) addNodeSetAction = QAction("Add Reference Node Set", self.model) addNodeSetAction.triggered.connect(self.add_nodeset) self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model) self.removeNodeSetAction.triggered.connect(self.remove_nodeset) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.showContextMenu) self._contextMenu = QMenu() self._contextMenu.addAction(addNodeSetAction) self._contextMenu.addAction(self.removeNodeSetAction)
Example #25
Source File: cq_object_inspector.py From CQ-editor with Apache License 2.0 | 6 votes |
def __init__(self,parent): super(CQObjectInspector,self).__init__(parent) self.setHeaderHidden(False) self.setRootIsDecorated(True) self.setContextMenuPolicy(Qt.ActionsContextMenu) self.setColumnCount(2) self.setHeaderLabels(['Type','Value']) self.root = self.invisibleRootItem() self.inspected_items = [] self._toolbar_actions = \ [QAction(icon('inspect'),'Inspect CQ object',self,\ toggled=self.inspect,checkable=True)] self.addActions(self._toolbar_actions)
Example #26
Source File: cue_menu_registry.py From linux-show-player with GNU General Public License v3.0 | 5 votes |
def add_item(self, item, ref_class=Cue): if not isinstance(item, (QAction, QMenu)): raise TypeError('items must be QAction(s) or QMenu(s), not {0}' .format(item.__class__.__name__)) if not issubclass(ref_class, Cue): raise TypeError('ref_class must be Cue or a subclass, not {0}' .format(ref_class.__name__)) return super().add_item(item, ref_class)
Example #27
Source File: sources_dock.py From kite with GNU General Public License v3.0 | 5 votes |
def addSection(self, text): action = QtWidgets.QAction(text, self) # action.setSeparator(True) font = action.font() font.setPointSize(9) font.setItalic(True) action.setFont(font) action.setEnabled(False) self.addAction(action) return action
Example #28
Source File: game.py From imperialism-remake with GNU General Public License v3.0 | 5 votes |
def __init__(self, client): super().__init__() self.toolbar = QtWidgets.QToolBar() action_help = QtWidgets.QAction(tools.load_ui_icon('icon.help.png'), 'Show help', self) action_help.triggered.connect(client.show_help_browser) # TODO with partial make reference to specific page self.toolbar.addAction(action_help) action_quit = QtWidgets.QAction(tools.load_ui_icon('icon.back_to_startscreen.png'), 'Exit to main menu', self) action_quit.triggered.connect(client.switch_to_start_screen) self.toolbar.addAction(action_quit) # main map self.main_map = MainMap() # mini map self.mini_map = MiniMap() # info box self.info_box = InfoBox() # layout layout = QtWidgets.QGridLayout(self) layout.addWidget(self.toolbar, 0, 0) layout.addWidget(self.mini_map, 1, 0) layout.addWidget(self.info_box, 2, 0) layout.addWidget(self.main_map, 0, 1, 3, 1) layout.setRowStretch(2, 1) # the info box will take all vertical space left layout.setColumnStretch(1, 1) # the main map will take all horizontal space left
Example #29
Source File: pkwidgets.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _init_menu(self): self.addAction(QtWidgets.QAction('About PKMeter', self, triggered=self.pkmeter.about.show)) self.addAction(QtWidgets.QAction('Preferences', self, triggered=self.pkmeter.config.show)) self.addAction(QtWidgets.QAction('Quit', self, triggered=self.pkmeter.quit)) self.setContextMenuPolicy(Qt.ActionsContextMenu)
Example #30
Source File: cue_menu_registry.py From linux-show-player with GNU General Public License v3.0 | 5 votes |
def add_separator(self, ref_class=Cue): """Register a separator menu-entry for ref_class and return it.""" separator = QAction(None) separator.setSeparator(True) self.add_item(separator, ref_class) return separator