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


Python QAction.setText方法代码示例

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


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

示例1: on_tab_add_clicked

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
 def on_tab_add_clicked(self):
     pos = QCursor.pos()
     planets = self.world.get_planets()
     # logger.debug('tab bar add clicked, cursor pos = ({0}, {1})'.format(pos.x(), pos.y()))
     menu = QMenu(self)
     # galaxy view
     galaxy_action = QAction(menu)
     galaxy_action.setText(self.tr('Add galaxy view'))
     galaxy_action.setData(QVariant('galaxy'))
     menu.addAction(galaxy_action)
     # planets
     menu.addSection(self.tr('-- Planet tabs: --'))
     for planet in planets:
         action = QAction(menu)
         action.setText('{0} {1}'.format(planet.name, planet.coords.coords_str()))
         action.setData(QVariant(planet.planet_id))
         menu.addAction(action)
     action_ret = menu.exec(pos)
     if action_ret is not None:
         # logger.debug('selected action data = {0}'.format(str(action_ret.data())))
         if action_ret == galaxy_action:
             logger.debug('action_ret == galaxy_action')
             self.add_tab_for_galaxy()
             return
         # else consider this is planet widget
         planet_id = int(action_ret.data())
         self.on_request_open_planet_tab(planet_id)
开发者ID:minlexx,项目名称:xnovacmd,代码行数:29,代码来源:main.py

示例2: updateRecentFiles

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
    def updateRecentFiles(self, menu):
        # bootstrap
        actions = menu.actions()
        for i in range(MAX_RECENT_FILES):
            try:
                action = actions[i]
            except IndexError:
                action = QAction(menu)
                menu.addAction(action)
            action.setVisible(False)
            action.triggered.connect(self.openRecentFile)
        # fill
        actions = menu.actions()
        recentFiles = settings.recentFiles()
        count = min(len(recentFiles), MAX_RECENT_FILES)
        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)

        menu.setEnabled(len(recentFiles))
开发者ID:yodamaster,项目名称:trufont,代码行数:28,代码来源:application.py

示例3: register_cue_options_ui

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
    def register_cue_options_ui(self, name, options_ui, category='',
                                shortcut=''):
        '''
            Register a new-cue choice for the edit-menu

            @param name: The name for the MenuAction
            @param options_ui: A method that provide the options for the new
                               cue(s) (e.g. show a file-dialog)
            @param category: The optional menu where insert the MenuAction
            @param shortcut: An optional shortcut for the MenuAction
        '''
        action = QAction(self)
        action.setText(name)
        action.triggered.connect(lambda: self._add_cues(options_ui()))
        if shortcut != '':
            action.setShortcut(shortcut)

        if category != '':
            if category not in self._cue_add_menus:
                menu = QMenu(category, self)
                self._cue_add_menus[category] = menu
                self.menuEdit.insertMenu(self.cueSeparator, menu)

            self._cue_add_menus[category].addAction(action)
        else:
            self.menuEdit.insertAction(self.cueSeparator, action)
开发者ID:tornel,项目名称:linux-show-player,代码行数:28,代码来源:mainwindow.py

示例4: MediaInfo

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class MediaInfo(Plugin):

    Name = 'MediaInfo'

    def __init__(self):
        self.app = Application()

        self.actionMediaInfo = QAction(None, triggered=self.showInfo)
        self.actionMediaInfo.setText("Media Info")

        self.separator = self.app.layout.add_context_separator(MediaCue)
        self.app.layout.add_context_item(self.actionMediaInfo, MediaCue)

    def reset(self):
        self.app.layout.remove_context_item(self.actionMediaInfo)
        self.app.layout.remove_context_item(self.separator)

    def showInfo(self, clicked):
        media_uri = self.app.layout.get_context_cue().media.input_uri()
        if not media_uri:
            QMessageBox.critical(None, 'Error Message', 'Invalid Media!')
        else:
            gst_info = uri_metadata(media_uri)
            info = {"Uri": unquote(gst_info.get_uri())}

            # Audio streams info
            for stream in gst_info.get_audio_streams():
                name = stream.get_stream_type_nick().capitalize()
                info[name] = {"Bitrate": str(stream.get_bitrate() // 1000) +
                              " Kb/s",
                              "Channels": str(stream.get_channels()),
                              "Sample rate": str(stream.get_sample_rate()) +
                              " Hz",
                              "Sample size": str(stream.get_depth()) + " bit"
                              }

            # Video streams info
            for stream in gst_info.get_video_streams():
                name = stream.get_stream_type_nick().capitalize()
                framerate = round(stream.get_framerate_num() /
                                  stream.get_framerate_denom())
                info[name] = {"Height": str(stream.get_height()) + " px",
                              "Width": str(stream.get_width()) + " px",
                              "Framerate": str(framerate)
                              }

            # Media tags
            info["Tags"] = {}
            tags = parse_gst_tag_list(gst_info.get_tags())
            for tag_name in tags:
                if(not str(tags[tag_name]).startswith("<Gst")):
                    info["Tags"][tag_name.capitalize()] = str(tags[tag_name])

            if len(info["Tags"]) == 0:
                info.pop("Tags")

            # Show the dialog
            dialog = InfoDialog(self.app.mainWindow, info,
                                self.app.layout.get_context_cue()['name'])
            dialog.exec_()
开发者ID:tornel,项目名称:linux-show-player,代码行数:62,代码来源:media_info.py

示例5: addShowActions

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
    def addShowActions(self):
        """Adds a submenu giving access to the (other)
        opened viewer documents"""
        mds = self._actionCollection.viewer_document_select
        docs = mds.viewdocs()
        document_actions = {}
        multi_docs = len(docs) > 1
        if self._panel.widget().currentViewdoc():
            current_doc_filename = self._panel.widget().currentViewdoc().filename()

        m = self._menu
        sm = QMenu(m)
        sm.setTitle(_("Show..."))
        sm.setEnabled(multi_docs)
        ag = QActionGroup(m)
        ag.triggered.connect(self._panel.slotShowViewdoc)

        for d in docs:
            action = QAction(sm)
            action.setText(d.name())
            action._document_filename = d.filename()
            # TODO: Tooltips aren't shown by Qt (it seems)
            action.setToolTip(d.filename())
            action.setCheckable(True)
            action.setChecked(d.filename() == current_doc_filename)

            ag.addAction(action)
            sm.addAction(action)

        m.addSeparator()
        m.addMenu(sm)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:33,代码来源:contextmenu.py

示例6: addAction

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
        def addAction(name, checked=False):
            action = QAction(name, self)
            action.setText(name)
            action.setCheckable(True)
            action.setChecked(checked)
            action.setActionGroup(self.lyricGroup)

            return action
开发者ID:xcution,项目名称:pyrics,代码行数:10,代码来源:qpyrics.py

示例7: setupLabel

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
 def setupLabel(self, actionText, actionName):
     action = QAction(self)
     if actionText != None:
         action.setText(QApplication.translate("MainWindow", actionText, None))
     if actionName != None:
         action.setObjectName(actionName)
     self.addAction(action)
     return action
开发者ID:alyosharomanov,项目名称:cadnano2.5,代码行数:10,代码来源:parttoolbar.py

示例8: Actions

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class Actions(actioncollection.ActionCollection):
    name = "matchingpair"
    def createActions(self, parent):
        self.view_matching_pair = QAction(parent)
        self.view_matching_pair_select = QAction(parent)

    def translateUI(self):
        self.view_matching_pair.setText(_("Matching Pai&r"))
        self.view_matching_pair_select.setText(_("&Select Matching Pair"))
开发者ID:19joho66,项目名称:frescobaldi,代码行数:11,代码来源:matcher.py

示例9: Actions

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class Actions(actioncollection.ActionCollection):
    name = 'autocomplete'
    def createActions(self, parent):
        self.autocomplete = QAction(parent, checkable=True)
        self.popup_completions = QAction(parent)
        self.popup_completions.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Space))
    
    def translateUI(self):
        self.autocomplete.setText(_("Automatic &Completion"))
        self.popup_completions.setText(_("Show C&ompletions Popup"))
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:12,代码来源:__init__.py

示例10: Actions

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class Actions(actioncollection.ActionCollection):
    name = 'scorewiz'
    def createActions(self, parent=None):
        self.scorewiz = QAction(parent)
        self.scorewiz.setIcon(icons.get("tools-score-wizard"))
        self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N"))
        self.scorewiz.setMenuRole(QAction.NoRole)

    def translateUI(self):
        self.scorewiz.setText(_("Score &Wizard..."))
开发者ID:19joho66,项目名称:frescobaldi,代码行数:12,代码来源:__init__.py

示例11: MediaInfo

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class MediaInfo(Module):
    Name = 'MediaInfo'

    def __init__(self):
        self.menuAction = QAction(None)
        self.menuAction.triggered.connect(self.show_info)
        self.menuAction.setText("Media Info")

        CueLayout.cm_registry.add_separator(MediaCue)
        CueLayout.cm_registry.add_item(self.menuAction, MediaCue)

    def show_info(self, clicked):
        media_uri = Application().layout.get_context_cue().media.input_uri()
        if not media_uri:
            QMessageBox.critical(None, 'Error Message', 'Invalid Media!')
        else:
            gst_info = gst_uri_metadata(media_uri)
            info = {"Uri": unquote(gst_info.get_uri())}

            # Audio streams info
            for stream in gst_info.get_audio_streams():
                name = stream.get_stream_type_nick().capitalize()
                info[name] = {"Bitrate": str(stream.get_bitrate() // 1000) +
                                         " Kb/s",
                              "Channels": str(stream.get_channels()),
                              "Sample rate": str(stream.get_sample_rate()) +
                                             " Hz",
                              "Sample size": str(stream.get_depth()) + " bit"
                              }

            # Video streams info
            for stream in gst_info.get_video_streams():
                name = stream.get_stream_type_nick().capitalize()
                framerate = round(stream.get_framerate_num() /
                                  stream.get_framerate_denom())
                info[name] = {"Height": str(stream.get_height()) + " px",
                              "Width": str(stream.get_width()) + " px",
                              "Framerate": str(framerate)
                              }

            # Media tags
            info["Tags"] = {}
            tags = gst_parse_tag_list(gst_info.get_tags())
            for tag_name in tags:
                if (not str(tags[tag_name]).startswith("<Gst")):
                    info["Tags"][tag_name.capitalize()] = str(tags[tag_name])

            if not info["Tags"]:
                info.pop("Tags")

            # Show the dialog
            dialog = InfoDialog(MainWindow(), info,
                                Application().layout.get_context_cue().name)
            dialog.exec_()
开发者ID:chippey,项目名称:linux-show-player,代码行数:56,代码来源:media_info.py

示例12: createActions

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
def createActions(actions, target):
    # actions = [(name, shortcut, icon, desc, func)]
    for name, shortcut, icon, desc, func in actions:
        action = QAction(target)
        if icon:
            action.setIcon(QIcon(QPixmap(':/' + icon)))
        if shortcut:
            action.setShortcut(shortcut)
        action.setText(desc)
        action.triggered.connect(func)
        setattr(target, name, action)
开发者ID:Arasy,项目名称:dupeguru,代码行数:13,代码来源:util.py

示例13: action

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
 def action(filename):
     url = QUrl.fromLocalFile(filename)
     a = QAction(menu)
     a.setText(_("Open \"{url}\"").format(url=util.homify(filename)))
     a.setIcon(icons.get('document-open'))
     @a.triggered.connect
     def open_doc():
         d = mainwindow.openUrl(url)
         if d:
             browseriface.get(mainwindow).setCurrentDocument(d)
     return a
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:13,代码来源:contextmenu.py

示例14: OSFOfflineMenu

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
class OSFOfflineMenu(QMenu):
    push_status = pyqtSignal((str,))

    def __init__(self, parent):
        super().__init__()
        self.status = QAction('Up to Date', self)
        self.status.setDisabled(True)

        self.addAction(QAction('Open OSF Folder', self, triggered=self.open_folder))
        self.addAction(QAction('Launch OSF', self, triggered=self.open_osf))
        self.addSeparator()
        self.addAction(QAction('Sync Now', self, triggered=parent.sync_now))
        self.addAction(self.status)
        self.addSeparator()
        self.addAction(QAction('Settings', self, triggered=self.open_settings))
        self.addAction(QAction('About', self, triggered=self.open_about))
        self.addSeparator()

        self.addAction(QAction('Quit', self, triggered=parent.quit))

        self.parent = parent
        self.preferences = Preferences()
        self.push_status.connect(self.update_status)

    def update_status(self, val):
        self.status.setText(str(val))

    def open_folder(self):
        with Session() as session:
            user = session.query(User).one()
        logger.debug("containing folder is :{}".format(user.folder))
        if validate_containing_folder(user.folder):
            if sys.platform == 'win32':
                os.startfile(user.folder)
            elif sys.platform == 'darwin':
                subprocess.Popen(['open', user.folder])
            else:
                try:
                    subprocess.Popen(['xdg-open', user.folder])
                except OSError:
                    pass

    def open_osf(self):
        webbrowser.open_new_tab(settings.OSF_URL)

    def open_settings(self):
        self.preferences.open_window(tab=Preferences.GENERAL)

    def open_about(self):
        self.preferences.open_window(tab=Preferences.ABOUT)
开发者ID:CenterForOpenScience,项目名称:osf-sync,代码行数:52,代码来源:menu.py

示例15: _get_menu

# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setText [as 别名]
 def _get_menu(self):
     # main menu
     menu = QMenu()
     main_menu_action_group = QActionGroup(menu)
     main_menu_action_group.setObjectName("main")
     # character menu
     map_action = QAction(menu)
     map_action.setText("Toggle Map")
     main_menu_action_group.addAction(map_action)
     separator = QAction(menu)
     separator.setSeparator(True)
     main_menu_action_group.addAction(separator)
     characters_action = QAction(menu)
     characters_action.setText("Switch Characters")
     main_menu_action_group.addAction(characters_action)
     separator = QAction(menu)
     separator.setSeparator(True)
     main_menu_action_group.addAction(separator)
     settings_action = QAction(menu)
     settings_action.setText("Settings")
     main_menu_action_group.addAction(settings_action)
     quit_action = QAction(menu)
     quit_action.setText("Quit")
     main_menu_action_group.addAction(quit_action)
     menu.addActions(main_menu_action_group.actions())
     menu.triggered[QAction].connect(self._menu_actions)
     return menu
开发者ID:nomns,项目名称:Parse99,代码行数:29,代码来源:parse99.py


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