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


Python QMenu.actions方法代码示例

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


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

示例1: __showContextMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
 def __showContextMenu(self):
     """
     Private slot to show the context menu.
     """
     menu = QMenu()
     act = menu.addAction(self.tr("Object blocked by ClickToFlash"))
     font = act.font()
     font.setBold(True)
     act.setFont(font)
     menu.addAction(
         self.tr("Show information about object"), self.__showInfo)
     menu.addSeparator()
     menu.addAction(self.tr("Load"), self.__load)
     menu.addAction(self.tr("Delete object"), self.__hideAdBlocked)
     menu.addSeparator()
     host = self.__url.host()
     add = menu.addAction(
         self.tr("Add '{0}' to Whitelist").format(host),
         self.__addToWhitelist)
     remove = menu.addAction(
         self.tr("Remove '{0}' from Whitelist").format(host),
         self.__removeFromWhitelist)
     onWhitelist = self.__plugin.onWhitelist(host)
     add.setEnabled(not onWhitelist)
     remove.setEnabled(onWhitelist)
     menu.addSeparator()
     menu.addAction(self.tr("Configure Whitelist"), self.__configure)
     menu.actions()[0].setEnabled(False)
     
     menu.exec_(QCursor.pos())
开发者ID:testmana2,项目名称:test,代码行数:32,代码来源:ClickToFlash.py

示例2: show

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
def show(position, panel, link, cursor):
    """Shows a context menu.

    position: The global position to pop up
    panel: The music view panel, giving access to mainwindow and view widget
    link: a popplerqt5 LinkBrowse instance or None
    cursor: a QTextCursor instance or None

    """
    m = QMenu(panel)

    # selection? -> Copy
    if panel.widget().view.surface().hasSelection():
        if panel.widget().view.surface().selectedText():
            m.addAction(panel.actionCollection.music_copy_text)
        m.addAction(panel.actionCollection.music_copy_image)

    if cursor:
        a = m.addAction(icons.get("document-edit"), _("Edit in Place"))
        @a.triggered.connect
        def edit():
            import editinplace
            editinplace.edit(panel.widget(), cursor, position)
    elif link:
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))
        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))
        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())

    # no actions yet? insert Fit Width/Height
    if not m.actions():
        m.addAction(panel.actionCollection.music_fit_width)
        m.addAction(panel.actionCollection.music_fit_height)
        m.addAction(panel.actionCollection.music_zoom_original)
        m.addSeparator()
        m.addAction(panel.actionCollection.music_sync_cursor)

    # help
    m.addSeparator()
    a = m.addAction(icons.get("help-contents"), _("Help"))
    @a.triggered.connect
    def help():
        import userguide
        userguide.show("musicview")

    # show it!
    if m.actions():
        m.exec_(position)
    m.deleteLater()
开发者ID:19joho66,项目名称:frescobaldi,代码行数:57,代码来源:contextmenu.py

示例3: updatePlotPersoButton

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
    def updatePlotPersoButton(self):
        menu = QMenu(self.mw)

        menus = []
        for i in [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]:
            m = QMenu(i, menu)
            menus.append(m)
            menu.addMenu(m)

        mpr = QSignalMapper(menu)
        for i in range(self.mw.mdlCharacter.rowCount()):
            a = QAction(self.mw.mdlCharacter.name(i), menu)
            a.setIcon(self.mw.mdlCharacter.icon(i))
            a.triggered.connect(mpr.map)
            mpr.setMapping(a, int(self.mw.mdlCharacter.ID(i)))

            imp = toInt(self.mw.mdlCharacter.importance(i))

            menus[2 - imp].addAction(a)

        # Disabling empty menus
        for m in menus:
            if not m.actions():
                m.setEnabled(False)

        mpr.mapped.connect(self.addPlotPerso)
        self.mw.btnAddPlotPerso.setMenu(menu)
开发者ID:olivierkes,项目名称:manuskript,代码行数:29,代码来源:plotModel.py

示例4: menu_sessions

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
def menu_sessions(parent):
    m = QMenu(parent)
    m.setTitle(_('menu title', '&Session'))
    m.triggered.connect(slot_session_action)
    import sessions
    for name in sessions.sessionNames():
        a = m.addAction(name.replace('&', '&&'))
        a.setObjectName(name)
    qutil.addAccelerators(m.actions())
    return m
开发者ID:19joho66,项目名称:frescobaldi,代码行数:12,代码来源:globalmenu.py

示例5: menu_file_open_recent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
def menu_file_open_recent(parent):
    m = QMenu(parent)
    m.setTitle(_("Open &Recent"))
    m.triggered.connect(slot_file_open_recent_action)
    import recentfiles
    for url in recentfiles.urls():
        f = url.toLocalFile()
        dirname, basename = os.path.split(f)
        text = "{0}  ({1})".format(basename, util.homify(dirname))
        m.addAction(text).url = url
    qutil.addAccelerators(m.actions())
    return m
开发者ID:19joho66,项目名称:frescobaldi,代码行数:14,代码来源:globalmenu.py

示例6: createStandardContextMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
    def createStandardContextMenu(self):
        popup_menu = QTextEdit.createStandardContextMenu(self)

        if not self.spellcheck:
            return popup_menu

        # Select the word under the cursor.
        # But only if there is no selection (otherwise it's impossible to select more text to copy/cut)
        cursor = self.textCursor()
        if not cursor.hasSelection():
            cursor.select(QTextCursor.WordUnderCursor)
            self.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        if self._dict and cursor.hasSelection():
            text = str(cursor.selectedText())
            valid = self._dict.check(text)
            selectedWord = cursor.selectedText()
            if not valid:
                spell_menu = QMenu(self.tr('Spelling Suggestions'), self)
                spell_menu.setIcon(F.themeIcon("spelling"))
                for word in self._dict.suggest(text):
                    action = self.SpellAction(word, spell_menu)
                    action.correct.connect(self.correctWord)
                    spell_menu.addAction(action)
                # Only add the spelling suggests to the menu if there are
                # suggestions.
                if len(spell_menu.actions()) != 0:
                    popup_menu.insertSeparator(popup_menu.actions()[0])
                    # Adds: add to dictionary
                    addAction = QAction(self.tr("&Add to dictionary"), popup_menu)
                    addAction.setIcon(QIcon.fromTheme("list-add"))
                    addAction.triggered.connect(self.addWordToDict)
                    addAction.setData(selectedWord)
                    popup_menu.insertAction(popup_menu.actions()[0], addAction)
                    # Adds: suggestions
                    popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
                    # popup_menu.insertSeparator(popup_menu.actions()[0])

            # If word was added to custom dict, give the possibility to remove it
            elif valid and self._dict.is_added(selectedWord):
                popup_menu.insertSeparator(popup_menu.actions()[0])
                # Adds: remove from dictionary
                rmAction = QAction(self.tr("&Remove from custom dictionary"), popup_menu)
                rmAction.setIcon(QIcon.fromTheme("list-remove"))
                rmAction.triggered.connect(self.rmWordFromDict)
                rmAction.setData(selectedWord)
                popup_menu.insertAction(popup_menu.actions()[0], rmAction)

        return popup_menu
开发者ID:olivierkes,项目名称:manuskript,代码行数:53,代码来源:textEditView.py

示例7: menu_file_new_from_template

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
def menu_file_new_from_template(parent):
    m = QMenu(parent)
    m.setTitle(_("New from &Template"))
    m.triggered.connect(slot_file_new_from_template_action)
    from snippet import model, actions, snippets
    groups = {}
    for name in sorted(model.model().names()):
        variables = snippets.get(name).variables
        group = variables.get('template')
        if group:
            action = actions.action(name, m)
            if action:
                groups.setdefault(group, []).append(action)
    for group in sorted(groups):
        for action in groups[group]:
            m.addAction(action)
        m.addSeparator()
    qutil.addAccelerators(m.actions())
    return m
开发者ID:19joho66,项目名称:frescobaldi,代码行数:21,代码来源:globalmenu.py

示例8: __init__

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
 def __init__(self):
     # We need this to load the GUI
     super(mapEditorWindow, self).__init__()
     uic.loadUi(os.path.join(GUI_FOLDER, 'mapEditor.ui'), self)
     # Defining radio buttons
     self.brushRadio.setText('Brush')
     self.rectangleRadio.setText('Rectangle')
     # A button for filling the whole map with a tile
     self.fillButton.setText('Fill Map')
     # Let's also define labels
     self.columnLabel.setText('Columns: -')
     self.rowLabel.setText('Rows: -')
     # This should take the brush as the default 
     self.brushRadio.setChecked(True)
     # I will instance this here because I fucked up
     self.triggerEditorInstance = triggerEditorWindow()
     # A Tool Button for loading tilemaps and stuff
     self.toolButton.setPopupMode(2)
     # Since I don't know how to load this stuff properly, I'll improvise.
     menu = QMenu()
     actions = ['Load Tilemap', 'Load map', 'Triggers', 'Save Map',
               'Load Old Map']
     for i in actions:
         menu.addAction(i)
     del(actions)
     menuActions = menu.actions()
     self.loadTmAction = menuActions[0]
     self.loadMapAction = menuActions[1]
     self.triggersAction = menuActions[2]
     self.saveMap = menuActions[3]
     self.pickOldMapAction = menuActions[4]
     self.toolButton.setMenu(menu)
     self.toolButton.setArrowType(Qt.DownArrow)
     self.tileMapFlag = False
     self.mapFileFlag = False
     # Signals
     self.loadTmAction.triggered.connect(self.pickTilemap)
     self.loadMapAction.triggered.connect(self.pickMap)
     self.triggersAction.triggered.connect(self.triggerEditor)
     self.saveMap.triggered.connect(self.saveMapFile)
     self.pickOldMapAction.triggered.connect(self.pickOldMap)
     self.mapFileViewer.itemSelectionChanged.connect(self.paint)
开发者ID:mratmartinez,项目名称:Mapuche,代码行数:44,代码来源:mapEditor.py

示例9: slotShowContextMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
 def slotShowContextMenu(self, pos):
     hit = self.webview.page().currentFrame().hitTestContent(pos)
     menu = QMenu()
     if hit.linkUrl().isValid():
         a = self.webview.pageAction(QWebPage.CopyLinkToClipboard)
         a.setIcon(icons.get("edit-copy"))
         a.setText(_("Copy &Link"))
         menu.addAction(a)
         menu.addSeparator()
         a = menu.addAction(icons.get("window-new"), _("Open Link in &New Window"))
         a.triggered.connect((lambda url: lambda: self.slotNewWindow(url))(hit.linkUrl()))
     else:
         if hit.isContentSelected():
             a = self.webview.pageAction(QWebPage.Copy)
             a.setIcon(icons.get("edit-copy"))
             a.setText(_("&Copy"))
             menu.addAction(a)
             menu.addSeparator()
         a = menu.addAction(icons.get("window-new"), _("Open Document in &New Window"))
         a.triggered.connect((lambda url: lambda: self.slotNewWindow(url))(self.webview.url()))
     if menu.actions():
         menu.exec_(self.webview.mapToGlobal(pos))
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:24,代码来源:browser.py

示例10: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
    def contextMenuEvent(self, event):
        popup_menu = self.createStandardContextMenu()
        # color: rgb(154, 190, 154);
        menu_style = "QMenu { background-color: rgb(38,38,38);selection-color: black; selection-background-color: grey;}"
        popup_menu.setStyleSheet(menu_style)

        # Select the word under the cursor.
        cursor = self.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        if enchant and self.dict:
            if self.textCursor().hasSelection():
                text = str(self.textCursor().selectedText())
                if self.dict.check(text):
                    self.gotoHelp = QAction('Goto in Help', self)
                    self.gotoHelp.triggered.connect(self.showInHelpFile)
                    popup_menu.insertAction(popup_menu.actions()[0], self.gotoHelp)
                    popup_menu.insertSeparator(popup_menu.actions()[1])
                if not self.dict.check(text):
                    spell_menu = QMenu(QCoreApplication.translate('app', 'Spelling Suggestions'), self)
                    spell_menu.setStyleSheet(menu_style)
                    for word in self.dict.suggest(text):
                        # print('word is ',word)
                        action = SpellAction(word, spell_menu)
                        action.correct.connect(self.correctWord)
                        spell_menu.addAction(action)
                    # Only add the spelling suggests to the menu if there are
                    # suggestions.
                    if len(spell_menu.actions()) != 0:
                        popup_menu.insertSeparator(popup_menu.actions()[0])
                        popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)

        # FIXME: add change dict and disable spellcheck options

        popup_menu.exec_(event.globalPos())
开发者ID:hovo1990,项目名称:GROM,代码行数:40,代码来源:textedit.py

示例11: SystemTrayIcon

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
class SystemTrayIcon(QSystemTrayIcon):
    def __init__(self, basedir, app, parent=None):
        if PLATFORM == 'OSX':
            if app.devicePixelRatio() == 2:
                self.icon = QtGui.QIcon(BASEDIR+'Assets/aether-black-tray.svg')
                self.iconActive = QtGui.QIcon(BASEDIR+'Assets/aether-white-tray.svg')
                self.iconHighlight =  QtGui.QIcon(BASEDIR+'Assets/aether-blue-tray.svg')
            else:
                self.icon = QtGui.QIcon(BASEDIR+'Assets/aether-black-tray.png')
                self.iconActive = QtGui.QIcon(BASEDIR+'Assets/aether-white-tray.png')
                self.iconHighlight =  QtGui.QIcon(BASEDIR+'Assets/aether-blue-tray.png')
        elif PLATFORM == 'WIN':
            self.icon = QtGui.QIcon(BASEDIR+'Assets/aether-white-tray-win.svg')
            self.iconActive = self.icon
            self.iconHighlight = QtGui.QIcon(BASEDIR+'Assets/aether-green-tray-win.svg')
        else:
            pass

        QSystemTrayIcon.__init__(self, self.icon, parent)

        self.menu = QMenu(parent)
        if globals.appIsPaused:
            self.menu.addAction('Paused').setDisabled(True)
        else:
            self.menu.addAction('Online').setDisabled(True)
        self.globalStatusMenuItem = self.menu.actions()[0]

        self.menu.addSeparator() # 1
        self.menu.addAction('You have no replies.').setDisabled(True)
        self.messagesMenuItem = self.menu.actions()[2]
        def goToMessages():
            self.messagesMenuItem.setText('You have no replies.')
            self.messagesMenuItem.setDisabled(True)
            parent.show()
            parent.raise_()
            jsString = \
            ("firstFrameScope = angular.element(document.getElementById('first-frame-contents')).scope();"
             "firstFrameScope.repliesButtonClick();"
             "firstFrameScope.$apply();"
            )
            self.webView.JSContext(jsString)
            # reach out to jscontext and
            # Here, I need to call qtwebkit and tell it to open messages.
        self.messagesMenuItem.triggered.connect(goToMessages)
        self.menu.addSeparator() # 3
        if globals.appIsPaused:
            self.menu.addAction('Resume')
        else:
            self.menu.addAction('Pause')
        self.togglePauseMenuItem = self.menu.actions()[4]
        def togglePause():
            if globals.appIsPaused:
                globals.appIsPaused = False
                self.togglePauseMenuItem.setText('Pause')
                self.globalStatusMenuItem.setText('Online')
            else:
                globals.appIsPaused = True
                self.togglePauseMenuItem.setText('Resume')
                self.globalStatusMenuItem.setText('Paused')
        self.togglePauseMenuItem.triggered.connect(togglePause)
        self.menu.addAction('Show Aether')
        self.toggleVisibilityMenuItem = self.menu.actions()[5]
        def makeVisible():
            parent.show()
            parent.raise_()
            if PLATFORM == 'OSX':
                globals.raiseAndFocusApp()

        self.toggleVisibilityMenuItem.triggered.connect(makeVisible)

        self.menu.addAction('Email the developer')
        self.emailDevMenuItem = self.menu.actions()[6]
        def emailDev():
            mailInitialiser = \
                QUrl('mailto:[email protected]'
                     '?subject=Feedback for Aether'
                     '&body=Hello there! Thanks for taking time to give feedback, I really appreciate it. '
                     'If you are having problems, please follow the directions at www.getaether.net/sending_logs, '
                     'and send me the produced logs. Thanks! You can delete this text before sending. '
                     'You can find my PGP key here: pgp.mit.edu:11371/pks/lookup?search=Burak+Nehbit')
            QtGui.QDesktopServices.openUrl(mailInitialiser)
        self.emailDevMenuItem.triggered.connect(emailDev)

        self.menu.addSeparator() # 5

        self.menu.addAction('Settings')
        self.settingsMenuItem = self.menu.actions()[8]
        def goToSettings():
            self.settingsMenuItem.setText('Settings')
            self.settingsMenuItem.setDisabled(False)
            if parent.isHidden():
                parent.show()
                parent.raise_()
            jsString = \
            ("firstFrameScope = angular.element(document.getElementById('first-frame-contents')).scope();"
             "firstFrameScope.settingsButtonClick();"
             "firstFrameScope.$apply();"
            )
            self.webView.JSContext(jsString)
        self.settingsMenuItem.triggered.connect(goToSettings)
#.........这里部分代码省略.........
开发者ID:anastiel,项目名称:aether-public,代码行数:103,代码来源:guiElements.py

示例12: SystemTrayIcon

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
class SystemTrayIcon(QSystemTrayIcon):
    def __init__(self, basedir, app, parent=None):
        self.basedir = basedir
        if globals.PLATFORM == 'OSX':
            if app.devicePixelRatio() == 2:
                self.icon = QtGui.QIcon(basedir+'Assets/aether-black-tray.svg')
                self.iconActive = QtGui.QIcon(basedir+'Assets/aether-white-tray.svg')
                self.iconHighlight =  QtGui.QIcon(self.basedir+'Assets/aether-blue-tray.svg')
            else:
                self.icon = QtGui.QIcon(basedir+'Assets/aether-black-tray.png')
                self.iconActive = QtGui.QIcon(basedir+'Assets/aether-white-tray.png')
                self.iconHighlight =  QtGui.QIcon(self.basedir+'Assets/aether-blue-tray.png')
        elif globals.PLATFORM == 'LNX':
            self.icon = QtGui.QIcon(basedir+'Assets/aether-white-tray.png')
            self.iconActive = self.icon
            self.iconHighlight = self.icon
        elif globals.PLATFORM == 'WIN':
            self.icon = QtGui.QIcon(basedir+'Assets/aether-black-tray-win.svg')
            self.iconActive = self.icon
            self.iconHighlight = self.icon
        else:
            pass

        QSystemTrayIcon.__init__(self, self.icon, parent)

        self.menu = QMenu(parent)
        if globals.appIsPaused:
            self.menu.addAction('Aether is paused.').setDisabled(True)
        else:
            self.menu.addAction('Aether is connected.').setDisabled(True)
        globalStatusMenuItem = self.menu.actions()[0]

        self.menu.addSeparator() # 1
        self.menu.addAction('You have no replies.').setDisabled(True)
        self.messagesMenuItem = self.menu.actions()[2]
        def goToMessages():
            self.messagesMenuItem.setText('You have no replies.')
            self.messagesMenuItem.setDisabled(True)
            if parent.isHidden():
                parent.show()
                parent.raise_()
            jsString = \
            ("firstFrameScope = angular.element(document.getElementById('first-frame-contents')).scope();"
             "firstFrameScope.repliesButtonClick();"
             "firstFrameScope.$apply();"
            )
            self.webView.JSContext(jsString)
            # reach out to jscontext and
            # Here, I need to call qtwebkit and tell it to open messages.
        self.messagesMenuItem.triggered.connect(goToMessages)
        self.menu.addSeparator() # 3
        if globals.appIsPaused:
            self.menu.addAction('Resume')
        else:
            self.menu.addAction('Pause')
        self.togglePauseMenuItem = self.menu.actions()[4]
        def togglePause():
            if globals.appIsPaused:
                globals.appIsPaused = False
                self.togglePauseMenuItem.setText('Pause')
                globalStatusMenuItem.setText('Aether is connected.')
            else:
                globals.appIsPaused = True
                self.togglePauseMenuItem.setText('Resume')
                self.globalStatusMenuItem.setText('Aether is paused.')
        self.togglePauseMenuItem.triggered.connect(togglePause)

        if not globals.appStartedAtBoot:
            self.menu.addAction('Show Aether')
        else:
            self.menu.addAction('Hide Aether')
        self.toggleVisibilityMenuItem = self.menu.actions()[5]
        def toggleVisibility():
            if parent.isHidden():
                parent.show()
                parent.raise_()
                # if globals.PLATFORM == 'OSX':
                #     globals.raiseAndFocusApp() #FIXME BEFORE RELEASE
                self.toggleVisibilityMenuItem.setText('Hide Aether')

            else:
                parent.hide()
                parent.lower()
                self.toggleVisibilityMenuItem.setText('Show Aether')
        self.toggleVisibilityMenuItem.triggered.connect(toggleVisibility)

        self.menu.addAction('Email the developer')
        self.emailDevMenuItem = self.menu.actions()[6]
        def emailDev():
            mailInitialiser = \
                QUrl('mailto:[email protected]'
                     '?subject=Feedback for Aether'
                     '&body=<i><br><br>Hello there! Thanks for taking time to give feedback, I really appreciate it. '
                     'If you are having problems, please right click on Aether.app on your Applications folder, '
                     'click Show Package Contents, go to Contents/MacOS/Logs and attach the network.log file there to '
                     'this email. <br><br>'
                     'You can delete this text before sending.'
                     '<br><br>You can find my PGP key here:</i> '
                     'http://pgp.mit.edu:11371/pks/lookup?search=Burak+Nehbit')
            QtGui.QDesktopServices.openUrl(mailInitialiser)
#.........这里部分代码省略.........
开发者ID:gordol,项目名称:aether-public,代码行数:103,代码来源:guiElements.py

示例13: FontWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]

#.........这里部分代码省略.........
            "<p>{n} is a cross-platform, modular typeface design "
            "application.</p><p>{n} is built on top of "
            "<a href='http://ts-defcon.readthedocs.org/en/ufo3/'>defcon</a> "
            "and includes scripting support "
            "with a <a href='http://robofab.com/'>robofab</a>-like API.</p>"
            "<p>Version {} {} – Python {}.").format(
            __version__, gitShortHash, platform.python_version(), n=name)
        if domain:
            text += self.tr("<br>See <a href='http://{d}'>{d}</a> for more "
                            "information.</p>").format(d=domain)
        else:
            text += "</p>"
        QMessageBox.about(self, self.tr("About {}").format(name), text)

    # update methods

    def setCurrentFile(self, path):
        if path is None:
            return
        recentFiles = settings.recentFiles()
        if path in recentFiles:
            recentFiles.remove(path)
        recentFiles.insert(0, path)
        while len(recentFiles) > MAX_RECENT_FILES:
            del recentFiles[-1]
        settings.setRecentFiles(recentFiles)
        for window in QApplication.topLevelWidgets():
            if isinstance(window, FontWindow):
                window.updateRecentFiles()

    def updateRecentFiles(self):
        recentFiles = settings.recentFiles()
        count = min(len(recentFiles), MAX_RECENT_FILES)
        actions = self.recentFilesMenu.actions()
        for index, recentFile in enumerate(recentFiles[:count]):
            action = actions[index]
            shortName = os.path.basename(recentFile.rstrip(os.sep))

            action.setText(shortName)
            action.setToolTip(recentFile)
            action.setVisible(True)
        for index in range(count, MAX_RECENT_FILES):
            actions[index].setVisible(False)

        self.recentFilesMenu.setEnabled(len(recentFiles))

    def updateMarkColors(self):
        entries = settings.readMarkColors()
        self.markColorMenu.clear()
        pixmap = QPixmap(24, 24)
        none = self.markColorMenu.addAction("None", self.markColor)
        none.setData(None)
        for name, color in entries.items():
            action = self.markColorMenu.addAction(name, self.markColor)
            pixmap.fill(color)
            action.setIcon(QIcon(pixmap))
            action.setData(color)

    def _updateGlyphActions(self):
        currentGlyph = self.glyphCellView.lastSelectedGlyph()
        # disconnect eventual signal of previous glyph
        self._undoAction.disconnect()
        self._undoAction.triggered.connect(self.undo)
        self._redoAction.disconnect()
        self._redoAction.triggered.connect(self.redo)
        # now update status
开发者ID:madig,项目名称:trufont,代码行数:70,代码来源:fontWindow.py

示例14: AceEditor

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]
class AceEditor(QWidget):
    """ Embbeded Ace javascript web editor """
    
    
    def __init__(self, file_info, parent=None):
        super(AceEditor, self).__init__(parent)
        self.parent = parent
        self.file_info = file_info
        self.editor_actions = {}
        self.language = EditorHelper.lang_from_file_info(file_info)
        
        self.editor = Ace(self.file_info, self)
        
        self.status_bar = StatusBar(self)
        
        self.editor.modificationChanged.connect(
            self.modification_changed)
        self.editor.cursorPositionChanged.connect(self.on_cursor_changed)
        
        self.v_box = QVBoxLayout(self)
        self.v_box.setSpacing(0)
        self.v_box.setContentsMargins(0, 0, 0, 0)
        
        self.v_box.addWidget(self.editor, 1)
        self.v_box.addWidget(self.status_bar, 0)
        
        self.setLayout(self.v_box)
        
        self.status_bar.menu_button.clicked.connect(
            self.on_menu_button_clicked)
        
        self.menu = QMenu(self)
        self.add_action('Save', 'ctrl+s', self.editor.save)
        self.add_separator()
        self.add_action(
            'Show hidden', 'ctrl+i', self.editor.toggle_hidden,checkable=True
        )
        self.add_action(
            'Use soft tabs', 'ctrl+shift+alt+s', self.editor.toggle_soft_tabs,
            checkable=True
        )
        self.setFocusPolicy(Qt.NoFocus)
        self.setFocusProxy(self.editor)
        
        Alter.invoke_all('editor_widget_init', self)
    
    @pyqtSlot(bool, name='modificationChanged')
    def modification_changed(self, b):
        if self.parent:
            self.parent.on_current_modified(b)
    
    @pyqtSlot(int, int, name='cursorPositionChanged')
    def on_cursor_changed(self, line, index):
        self.status_bar.showMessage(
            self.tr("Line {0}, column {1}".format(line + 1, index))
        )
    
    def on_menu_button_clicked(self):
        pos = self.status_bar.mapToGlobal(self.status_bar.menu_button.pos())
        menu_size = self.menu.sizeHint()
        menu_height = menu_size.height()
        menu_width = menu_size.width()
        pos.setY(pos.y() - menu_height)
        pos.setX(pos.x() - menu_width + self.status_bar.menu_button.width())
        if len(self.menu.actions()) > 0:
            self.menu.exec(pos)
    
    def add_action(self, name, shortcut, callback, **kwargs):
        """
        Ajoute une action au context menu et au widget navigation lui même.
        Créer une fonction à la volé pour fournir des arguments aux fonctions
        associé aux actions.
        """
        action = QAction(self.tr(name), self)
        if 'icon' in kwargs:
            action.setIcon(kwargs['icon'])
        if 'checkable' in kwargs and kwargs['checkable']:
            action.setCheckable(True)
            if 'checked' in kwargs:
                checked = True if kwargs['checked'] == 'true' else False
                action.setChecked(
                    checked
                )
        
        action.setShortcut(shortcut)
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        
        if 'wrapped' in kwargs and kwargs['wrapped'] is False:
            action.triggered.connect(callback)
        else:
            action.triggered.connect(self.__wrapper(callback))
        
        self.addAction(action)
        self.menu.addAction(action)
        self.editor_actions[name] = action
        
    def add_separator(self):
        """Simple abstraction of self.context_menu.addSeparator()"""
        self.menu.addSeparator()

#.........这里部分代码省略.........
开发者ID:FlorianPerrot,项目名称:Mojuru,代码行数:103,代码来源:ace_editor.py

示例15: EditorWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import actions [as 别名]

#.........这里部分代码省略.........
            self.editor.indent_current_line
        )
        self.add_action(
            self.tr('Unindent current line'),
            'ctrl+shift+i',
            self.editor.unindent_current_line
        )
        self.add_separator()
        self.add_action(
            self.tr('Auto close brackets and quotes'),
            'ctrl+alt+a',
            EditorHelper.auto_close_brackets_quotes,
            checkable=True,
            checked=ModuleManager.core['settings'].Settings.value(
                EditorHelper.SETTINGS_AUTO_CLOSE_BRACKETS,
                'true'
            )
        )
        self.add_action(
            self.tr('Use tabs to indent/unindent'),
            'ctrl+shift+alt+&',
            EditorHelper.use_tabs_to_indent,
            checkable=True,
            checked=ModuleManager.core['settings'].Settings.value(
                EditorHelper.SETTINGS_USE_TABS_TO_INDENT,
                'true'
            )
        )
        self.add_action(
            self.tr('Comment/Uncomment line(s)'),
            'ctrl+e',
            self.editor.comment_lines
        )
        
        self.setFocusPolicy(Qt.NoFocus)
        self.setFocusProxy(self.editor)
        
        Alter.invoke_all('editor_widget_init', self)
    
    def on_modification_changed(self, modified):
        if self.parent:
            self.parent.on_current_modified(modified)
    
    def on_cursor_changed(self, line, index):
        self.status_bar.showMessage(
            self.tr("Line {0}, column {1}".format(line + 1, index))
        )
    
    def on_menu_button_clicked(self):
        pos = self.status_bar.mapToGlobal(self.status_bar.menu_button.pos())
        menu_size = self.menu.sizeHint()
        menu_height = menu_size.height()
        menu_width = menu_size.width()
        pos.setY(pos.y() - menu_height)
        pos.setX(pos.x() - menu_width + self.status_bar.menu_button.width())
        if len(self.menu.actions()) > 0:
            self.menu.exec(pos)
    
    def add_action(self, name, shortcut, callback, **kwargs):
        """
        Ajoute une action au context menu et au widget navigation lui même.
        Créer une fonction à la volé pour fournir des arguments aux fonctions
        associé aux actions.
        """
        action = QAction(name, self)
        if 'icon' in kwargs:
            action.setIcon(kwargs['icon'])
        if 'checkable' in kwargs and kwargs['checkable']:
            action.setCheckable(True)
            if 'checked' in kwargs:
                checked = True if kwargs['checked'] == 'true' else False
                action.setChecked(
                    checked
                )
        
        action.setShortcut(shortcut)
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        
        if 'wrapped' in kwargs and kwargs['wrapped'] is False:
            action.triggered.connect(callback)
        else:
            action.triggered.connect(self.__wrapper(callback))
        
        self.addAction(action)
        self.menu.addAction(action)
        
    def add_separator(self):
        """Simple abstraction of self.context_menu.addSeparator()"""
        self.menu.addSeparator()

    def __wrapper(self, callback):
        def __new_function():
            """
            __new_function représente la forme de tous les callbacks connecté
            à une action pour pouvoir utiliser les raccourcis en même temps que
            le menu contextuel.
            """
            action = self.sender()
            callback(self, action)
        return __new_function
开发者ID:FlorianPerrot,项目名称:Mojuru,代码行数:104,代码来源:editor_widget.py


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