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


Python QKeySequence.mnemonic方法代码示例

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


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

示例1: build_ui

# 需要导入模块: from PyQt4.QtGui import QKeySequence [as 别名]
# 或者: from PyQt4.QtGui.QKeySequence import mnemonic [as 别名]

#.........这里部分代码省略.........
        if self.show_navigation is True:
            self.navigation_bar = QToolBar("Navigation")
            self.navigation_bar.setObjectName("navigation")
            self.addToolBar(Qt.TopToolBarArea, self.navigation_bar)
            self.navigation_bar.setMovable(False)
            self.navigation_bar.setFloatable(False)

            #Standard navigation tools
            self.nav_items = {}
            self.nav_items["back"] = self.browser_window.pageAction(QWebPage.Back)
            self.nav_items["forward"] = self.browser_window.pageAction(QWebPage.Forward)
            self.nav_items["refresh"] = self.browser_window.pageAction(QWebPage.Reload)
            self.nav_items["stop"] = self.browser_window.pageAction(QWebPage.Stop)
            #The "I'm finished" button.
            self.nav_items["quit"] = self.createAction(
                self.quit_button_text,
                qb_mode_callbacks.get(self.quit_button_mode, self.reset_browser),
                QKeySequence("Alt+F"),
                None,
                self.quit_button_tooltip)
            #Zoom buttons
            self.nav_items["zoom_in"] = self.createAction(
                "Zoom In",
                self.zoom_in,
                QKeySequence("Alt++"),
                "zoom-in",
                "Increase the size of the text and images on the page")
            self.nav_items["zoom_out"] = self.createAction(
                "Zoom Out",
                self.zoom_out,
                QKeySequence("Alt+-"),
                "zoom-out",
                "Decrease the size of text and images on the page")
            if self.allow_printing:
                self.nav_items["print"] = self.createAction("Print", self.browser_window.print_webpage, QKeySequence("Ctrl+p"), "document-print", "Print this page")

            #Add all the actions to the navigation bar.
            for item in self.navigation_layout:
                if item == "separator":
                    self.navigation_bar.addSeparator()
                elif item == "spacer":
                    #an expanding spacer.
                    spacer = QWidget()
                    spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
                    self.navigation_bar.addWidget(spacer)
                elif item == "bookmarks":
                    #Insert bookmarks buttons here.
                    self.bookmark_buttons = []
                    if configuration.get("bookmarks"):
                        for bookmark in configuration.get("bookmarks").items():
                            debug("Bookmark:\n" + bookmark.__str__())
                            #bookmark name will use the "name" attribute, if present
                            #or else just the key:
                            bookmark_name = bookmark[1].get("name") or bookmark[0]
                            #Create a button for the bookmark as a QAction,
                            #which we'll add to the toolbar
                            button = self.createAction(
                                bookmark_name,
                                lambda url=bookmark[1].get("url"): self.browser_window.load(QUrl(url)),
                                QKeySequence.mnemonic(bookmark_name),
                                None,
                                bookmark[1].get("description")
                                )
                            self.navigation_bar.addAction(button)
                            self.navigation_bar.widgetForAction(button).setObjectName("navigation_button")
                else:
                    action = self.nav_items.get(item, None)
                    if action:
                        self.navigation_bar.addAction(action)
                        self.navigation_bar.widgetForAction(action).setObjectName("navigation_button")

            #This removes the ability to toggle off the navigation bar:
            self.nav_toggle = self.navigation_bar.toggleViewAction()
            self.nav_toggle.setVisible(False)
            #End "if show_navigation is True" block

        # set hidden quit action
        # For reasons I haven't adequately ascertained,
        #this shortcut fails now and then claiming "Ambiguous shortcut overload".
        # No idea why, as it isn't consistent.
        self.really_quit = self.createAction("", self.close, QKeySequence("Ctrl+Alt+Q"), None, "")
        self.addAction(self.really_quit)

        #Call a reset function after timeout
        if inactivity_timeout != 0:
            self.event_filter = InactivityFilter(inactivity_timeout)
            QCoreApplication.instance().installEventFilter(self.event_filter)
            self.browser_window.page().installEventFilter(self.event_filter)
            self.connect(self.event_filter, SIGNAL("timeout()"),
                         to_mode_callbacks.get(timeout_mode, self.reset_browser))
        else:
            self.event_filter = None

        if self.refresh_timer != 0:
            # Create a QTimer
            self.timer = QTimer()
            # Connect it to self.refresh_browser
            self.timer.timeout.connect(self.refresh_browser)
            # Call refresh_browser() every self.refresh_timer seconds
            self.timer.start(self.refresh_timer*1000)
开发者ID:totalretribution,项目名称:wcgbrowser,代码行数:104,代码来源:browser.py


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