当前位置: 首页>>代码示例>>Python>>正文


Python QMenu.addSeparator方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QMenu.addSeparator方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addSeparator方法的具体用法?Python QMenu.addSeparator怎么用?Python QMenu.addSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QMenu的用法示例。


在下文中一共展示了QMenu.addSeparator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def __init__(self, parent=None):
        super().__init__(parent)

        self.editor = PythonEditor(self)
        self.resize(650, 500)

        fileMenu = QMenu(self.tr("&File"), self)
        fileMenu.addAction(self.tr("&New…"), self.newFile, QKeySequence.New)
        fileMenu.addAction(self.tr("&Open…"), self.openFile, QKeySequence.Open)
        fileMenu.addAction(self.tr("&Save"), self.saveFile, QKeySequence.Save)
        fileMenu.addAction(self.tr("Save &As…"), self.saveFileAs, QKeySequence.SaveAs)
        fileMenu.addSeparator()
        fileMenu.addAction(self.tr("&Run…"), self.runScript, "Ctrl+R")
        fileMenu.addSeparator()
        fileMenu.addAction(self.tr("&Close"), self.close, platformSpecific.closeKeySequence())
        self.menuBar().addMenu(fileMenu)

        self.fileChooser = FileChooser(self)
        self.fileChooser.fileOpened.connect(self.openFile)
        splitter = QSplitter(self)
        splitter.addWidget(self.fileChooser)
        splitter.addWidget(self.editor)
        splitter.setStretchFactor(0, 2)
        splitter.setStretchFactor(1, 5)
        splitter.setSizes([0, 1])
        self.setCentralWidget(splitter)
        self.newFile()
        self.editor.modificationChanged.connect(self.setWindowModified)
开发者ID:madig,项目名称:trufont,代码行数:30,代码来源:scriptingWindow.py

示例2: layercontextmenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
def layercontextmenu(layer, pos, parent=None):
    """Show a context menu to manipulate properties of layer.

    layer -- a volumina layer instance
    pos -- QPoint

    """
    menu = QMenu("Menu", parent)

    # Title
    title = QAction("%s" % layer.name, menu)
    title.setEnabled(False)
    menu.addAction(title)

    # Export
    global _has_lazyflow
    if _has_lazyflow:
        export = QAction("Export...", menu)
        export.setStatusTip("Export Layer...")
        export.triggered.connect(partial(prompt_export_settings_and_export_layer, layer, menu))
        menu.addAction(export)

    menu.addSeparator()
    _add_actions(layer, menu)

    # Layer-custom context menu items
    menu.addSeparator()
    for item in layer.contexts:
        if isinstance(item, QAction):
            menu.addAction(item)
        elif isinstance(item, QMenu):
            menu.addMenu(item)

    menu.exec_(pos)
开发者ID:ilastik,项目名称:volumina,代码行数:36,代码来源:layercontextmenu.py

示例3: on_header_sectionClicked

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
   def on_header_sectionClicked(self, logicalIndex):
       """opens a dialog to choose between all unique values for this column,
       or revert to 'All'
       """
       self.log.debug("Header clicked: column {}".format(logicalIndex))
       self.logicalIndex = logicalIndex
       menuValues = QMenu(self)
       self.signalMapper = QSignalMapper(self)  
 
       self.filter_cb.setCurrentIndex(self.logicalIndex)
       self.filter_cb.blockSignals(True)
       self.proxy.setFilterKeyColumn(self.logicalIndex)
       
       valuesUnique = [str(self.model.index(row, self.logicalIndex).data())
                       for row in range(self.model.rowCount())
                       ]
       
       actionAll = QAction("All", self)
       actionAll.triggered.connect(self.on_actionAll_triggered)
       menuValues.addAction(actionAll)
       menuValues.addSeparator()
       
       for actionNumber, actionName in enumerate(sorted(list(set(valuesUnique)))):              
           action = QAction(actionName, self)
           self.signalMapper.setMapping(action, actionNumber)  
           action.triggered.connect(self.signalMapper.map)  
           menuValues.addAction(action)
 
       self.signalMapper.mapped.connect(self.on_signalMapper_mapped)  
 
       headerPos = self.table.mapToGlobal(self.header.pos())        
       posY = headerPos.y() + self.header.height()
       posX = headerPos.x() + self.header.sectionViewportPosition(self.logicalIndex)
 
       menuValues.exec_(QPoint(posX, posY))
开发者ID:DKMS-LSL,项目名称:typeloader,代码行数:37,代码来源:GUI_overviews.py

示例4: create_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def create_context_menu(self) -> QMenu:
        menu = QMenu(self)
        index = self.model().mapToSource(self.currentIndex())  # type: QModelIndex
        if index.isValid():
            current_index_info = self.model().sourceModel().fileInfo(index)  # type: QFileInfo
            if current_index_info.isDir():
                if os.path.isfile(os.path.join(current_index_info.filePath(), constants.PROJECT_FILE)):
                    open_action = menu.addAction("Open project")
                    open_action.setIcon(QIcon(":/icons/data/icons/appicon.png"))
                else:
                    open_action = menu.addAction("Open folder")
                    open_action.setIcon(QIcon.fromTheme("folder-open"))
                open_action.triggered.connect(self.on_open_action_triggered)

        new_dir_action = menu.addAction("New folder")
        new_dir_action.setIcon(QIcon.fromTheme("folder"))
        new_dir_action.triggered.connect(self.create_directory)

        del_action = menu.addAction("Delete")
        del_action.setIcon(QIcon.fromTheme("edit-delete"))
        del_action.triggered.connect(self.remove)

        menu.addSeparator()
        open_in_explorer_action = menu.addAction("Open in file manager...")
        open_in_explorer_action.triggered.connect(self.on_open_explorer_action_triggered)

        return menu
开发者ID:Cyber-Forensic,项目名称:urh,代码行数:29,代码来源:DirectoryTreeView.py

示例5: cb_backends

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def cb_backends(self):
        self.cb_backends = QComboBox()

        self.cb_backends.addItem('Auto')

        menuLyricSource = QMenu(self.ui.menuEdit)
        menuLyricSource.setTitle('Lyric source')

        self.lyricGroup = QActionGroup(self)

        def addAction(name, checked=False):
            action = QAction(name, self)
            action.setText(name)
            action.setCheckable(True)
            action.setChecked(checked)
            action.setActionGroup(self.lyricGroup)

            return action

        menuLyricSource.addAction(addAction('Auto', True))
        menuLyricSource.addSeparator()
        menuLyricSource.triggered.connect(self._menu_backend_change)

        for backend in Pyrics.get_backends():
            menuLyricSource.addAction(addAction(backend.__name__))
            self.cb_backends.addItem(backend.__name__)

        self.ui.menuEdit.addMenu(menuLyricSource)
        self.ui.toolBar.addWidget(self.cb_backends)

        self.cb_backends.currentIndexChanged.connect(self._cb_backend_change)
开发者ID:xcution,项目名称:pyrics,代码行数:33,代码来源:qpyrics.py

示例6: onContextMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def onContextMenu(self, pt: QPoint):
        index = self.ui.projectTree.indexAt(pt)
        newDocAction = QAction("New document", None)
        newDocAction.triggered.connect(self.window.on_actionNew_triggered)
        menu = QMenu()
        menu.addAction(newDocAction)
        if index.isValid():
            obj = index.data(Qt.UserRole)

            def newPage():
                obj.doc.appendNewPage()
                self.onDocsChanged()

            def newSym():
                obj.doc.appendNewSymbol()
                self.onDocsChanged()

            addPageAction = QAction("Add page", None)
            addPageAction.triggered.connect(newPage)
            addSymAction = QAction("Add symbol", None)
            addSymAction.triggered.connect(newSym)
            rmPageAction = QAction("Delete page", None)
            menu.addAction(addPageAction)
            menu.addAction(addSymAction)
            menu.addSeparator()
            if obj.page is not None:
                menu.addAction(rmPageAction)
        menu.exec(self.ui.projectTree.mapToGlobal(pt))
开发者ID:olegizyumin1987,项目名称:pyschem,代码行数:30,代码来源:projectdock.py

示例7: build_tree_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
 def build_tree_context_menu(self, point):
     # print(point)
     self.itemClicked = self.itemAt(point)
     if self.itemClicked is None:
         return
     # parent = self.itemClicked.parent()
     # if not parent:
     #     print(1)
     #     return
     # if parent.parent():
     #     print(2)
     #     return
     # print(self.itemClicked.get_res_data(), "()()()", self.itemClicked)
     menu = QMenu(self)
     action = QAction("查看C++类", self)
     action.triggered.connect(self.build_cpp_class)
     menu.addAction(action)
     action = QAction("查看C#类", self)
     action.triggered.connect(self.build_csharp_class)
     menu.addAction(action)
     menu.addSeparator()
     action = QAction("转换成二进制数据", self)
     action.triggered.connect(self.build_binrary_data)
     menu.addAction(action)
     action = QAction("转换成xml数据", self)
     action.triggered.connect(self.build_xml_data)
     menu.addAction(action)
     menu.popup(self.viewport().mapToGlobal(point))
     pass
开发者ID:tylerzhu,项目名称:ExcelConvert,代码行数:31,代码来源:convertlistUi.py

示例8: createSubMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
 def createSubMenu(self, menu, view, hitTestResult):
     """
     Public method to create the personal information sub-menu.
     
     @param menu reference to the main menu (QMenu)
     @param view reference to the view (HelpBrowser)
     @param hitTestResult reference to the hit test result
         (QWebHitTestResult)
     """
     self.__view = view
     self.__element = hitTestResult.element()
     
     if not hitTestResult.isContentEditable():
         return
     
     if not self.__loaded:
         self.__loadSettings()
     
     submenu = QMenu(self.tr("Insert Personal Information"), menu)
     submenu.setIcon(UI.PixmapCache.getIcon("pim.png"))
     
     for key, info in sorted(self.__allInfo.items()):
         if info:
             act = submenu.addAction(
                 self.__translations[key], self.__insertData)
             act.setData(info)
     
     submenu.addSeparator()
     submenu.addAction(self.tr("Edit Personal Information"),
                       self.showConfigurationDialog)
     
     menu.addMenu(submenu)
     menu.addSeparator()
开发者ID:testmana2,项目名称:test,代码行数:35,代码来源:PersonalInformationManager.py

示例9: get_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def get_context_menu(self) -> QMenu:
        """
        Create the context menu.
        It shows up on left click.

        Note: icons will not be displayed on every GNU/Linux
        distributions, it depends on the graphical environment.
        """

        style = QApplication.style()
        menu = QMenu()
        menu.addAction(
            style.standardIcon(QStyle.SP_FileDialogInfoView),
            Translator.get("SETTINGS"),
            self.application.show_settings,
        )
        menu.addSeparator()
        menu.addAction(
            style.standardIcon(QStyle.SP_MessageBoxQuestion),
            Translator.get("HELP"),
            self.application.open_help,
        )
        menu.addSeparator()
        menu.addAction(
            style.standardIcon(QStyle.SP_DialogCloseButton),
            Translator.get("QUIT"),
            self.application.quit,
        )

        return menu
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:32,代码来源:systray.py

示例10: initUI

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
 def initUI(self):
     """
     Initialize the System Tray Icon user interface.
     """
     self.setIcon(QIcon(B3_ICON_SMALL))
     #### SHOW ACTION
     show = QAction('Show', self.parent())
     show.triggered.connect(self.parent().make_visible)
     show.setVisible(True)
     #### START ALL ACTION
     start = QAction('Start all', self.parent())
     start.triggered.connect(B3App.Instance().start_all)
     start.setVisible(True)
     #### STOP ALL ACTION
     stop = QAction('Stop all', self.parent())
     stop.triggered.connect(B3App.Instance().stop_all)
     stop.setVisible(True)
     #### QUIT ACTION
     terminate = QAction('Quit', self.parent())
     terminate.triggered.connect(B3App.Instance().shutdown)
     terminate.setVisible(True)
     ## CREATE THE MENU
     menu = QMenu(self.parent())
     menu.addAction(show)
     menu.addSeparator()
     menu.addAction(start)
     menu.addAction(stop)
     menu.addSeparator()
     menu.addAction(terminate)
     ## ADD THE MENU
     self.setContextMenu(menu)
     self.activated.connect(self.onActivated)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:34,代码来源:system.py

示例11: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def contextMenuEvent(self, event):
        menu = QMenu()
        removeAction = menu.addAction(QA.translate('QOcrWidget', "Remove"))
        #Action = menu.addAction(self.scene().tr("Remove"))
        menu.addSeparator()
        textAction = menu.addAction(QA.translate('QOcrWidget', "Text"))
        graphicsAction = menu.addAction(QA.translate('QOcrWidget', "Graphics"))

        ## verification of the type of the selection and
        ## setting a check box near the type that is in use
        textAction.setCheckable(True)
        graphicsAction.setCheckable(True)

        if self.kind == 1:
            textAction.setChecked(True)
        elif self.kind == 2:
            graphicsAction.setChecked(True)

        selectedAction = menu.exec_(event.screenPos())

        if selectedAction == removeAction:
            self.scene().removeArea(self)
        elif selectedAction == textAction:
            self.kind = 1
        elif selectedAction == graphicsAction:
            self.kind = 2
开发者ID:correosdelbosque,项目名称:lector,代码行数:28,代码来源:ocrarea.py

示例12: WorkbenchWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
class WorkbenchWindow(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self)

        self.mainMenu = QMenu(' Window ')
        layMenu1 = self.mainMenu.addAction('Default Layout')
        layMenu1.triggered.connect(lambda: self.loadLayoutPreset())
        self.mainMenu.addSeparator()
        layMenu2 = self.mainMenu.addAction('Import Layout')
        layMenu2.triggered.connect(lambda: self.importLayoutPreset())
        layMenu3 = self.mainMenu.addAction('Save Layout')
        layMenu3.triggered.connect(lambda: self.saveLayoutPreset())

        self.menuBar().addMenu(self.mainMenu)
        self.mainMenu.setLayoutDirection(Qt.LeftToRight)
        self.menuBar().setLayoutDirection(Qt.RightToLeft)

        self.tabWidget = WorkbenchTabWidget(self)
        self.setCentralWidget(self.tabWidget)

        self.tabWidget.newPage()

    def loadLayoutPreset(self):
        print 'loadLayoutPreset'

    def importLayoutPreset(self):
        print 'importLayoutPreset'

    def saveLayoutPreset(self):
        print 'saveLayoutPreset'
开发者ID:nkpatro,项目名称:pipewidgets,代码行数:32,代码来源:workbenchwindow.py

示例13: create_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
    def create_context_menu(self) -> QMenu:
        menu = QMenu()
        if self.context_menu_pos is None:
            return menu

        selected_label_index = self.model().get_selected_label_index(row=self.rowAt(self.context_menu_pos.y()),
                                                                     column=self.columnAt(self.context_menu_pos.x()))

        if self.model().row_count > 0:
            if selected_label_index == -1:
                label_action = menu.addAction("Create label...")
                label_action.setIcon(QIcon.fromTheme("list-add"))
            else:
                label_action = menu.addAction("Edit label...")
                label_action.setIcon(QIcon.fromTheme("configure"))

            label_action.triggered.connect(self.on_create_or_edit_label_action_triggered)
            menu.addSeparator()

            zoom_menu = menu.addMenu("Zoom font size")
            zoom_menu.addAction(self.zoom_in_action)
            zoom_menu.addAction(self.zoom_out_action)
            zoom_menu.addAction(self.zoom_original_action)
            menu.addSeparator()

        return menu
开发者ID:jopohl,项目名称:urh,代码行数:28,代码来源:TableView.py

示例14: __customContextMenuRequested

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
 def __customContextMenuRequested(self, pos):
     """
     Private slot to handle the context menu request for the bookmarks tree.
     
     @param pos position the context menu was requested (QPoint)
     """
     itm = self.feedsTree.currentItem()
     if itm is None:
         return
     
     if self.feedsTree.indexOfTopLevelItem(itm) != -1:
         return
     
     urlString = itm.data(0, FeedsManager.UrlStringRole)
     if urlString:
         menu = QMenu()
         menu.addAction(
             self.tr("&Open"), self.__openMessageInCurrentTab)
         menu.addAction(
             self.tr("Open in New &Tab"), self.__openMessageInNewTab)
         menu.addSeparator()
         menu.addAction(self.tr("&Copy URL to Clipboard"),
                        self.__copyUrlToClipboard)
         menu.exec_(QCursor.pos())
     else:
         errorString = itm.data(0, FeedsManager.ErrorDataRole)
         if errorString:
             menu = QMenu()
             menu.addAction(
                 self.tr("&Show error data"), self.__showError)
             menu.exec_(QCursor.pos())
开发者ID:Darriall,项目名称:eric,代码行数:33,代码来源:FeedsManager.py

示例15: __init__

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSeparator [as 别名]
	def __init__(self, **kwargs):
		super(SearchOptionsButton, self).__init__(**kwargs)

		self.setText(self.tr('Options'))

		menu = QMenu()
		self.actionCi = menu.addAction(self.tr('Case insensitive'))

		menu.addSeparator()
		self.actionFormat = QActionGroup(self)
		self.actionPlain = menu.addAction(self.tr('Plain text'))
		self.actionPlain.setEnabled(False)
		self.actionRe = menu.addAction(self.tr('Regular expression'))
		self.actionGlob = menu.addAction(self.tr('Glob pattern'))
		self.actionGlob.setEnabled(False)
		self.actionFormat.addAction(self.actionPlain)
		self.actionFormat.addAction(self.actionRe)
		self.actionFormat.addAction(self.actionGlob)

		self.actionRoot = menu.addAction(self.tr('Search in best root dir'))

		for act in [self.actionCi, self.actionRe, self.actionPlain, self.actionGlob, self.actionRoot]:
			act.setCheckable(True)
		self.actionRe.setChecked(True)

		self.setMenu(menu)
开发者ID:hydrargyrum,项目名称:eye,代码行数:28,代码来源:search.py


注:本文中的PyQt5.QtWidgets.QMenu.addSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。