當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。