當前位置: 首頁>>代碼示例>>Python>>正文


Python QKeySequence.keyBindings方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QKeySequence.keyBindings方法的典型用法代碼示例。如果您正苦於以下問題:Python QKeySequence.keyBindings方法的具體用法?Python QKeySequence.keyBindings怎麽用?Python QKeySequence.keyBindings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QKeySequence的用法示例。


在下文中一共展示了QKeySequence.keyBindings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_actions

# 需要導入模塊: from PyQt4.QtGui import QKeySequence [as 別名]
# 或者: from PyQt4.QtGui.QKeySequence import keyBindings [as 別名]
    def create_actions(self):
        new_tab_action = QAction('&New Tab', self)
        new_tab_action.setShortcuts(QKeySequence.AddTab)
        self.connect(new_tab_action, SIGNAL('triggered()'), self.new_tab)
        self.new_tab_action = new_tab_action

        close_tab_action = QAction('&Close Tab', self)
        close_tab_action.setShortcuts(QKeySequence.Close)
        self.connect(close_tab_action, SIGNAL('triggered()'), self.close_tab)
        self.close_tab_action = close_tab_action

        open_action = QAction('&Open...', self)
        open_action.setShortcuts(QKeySequence.Open)
        self.connect(open_action, SIGNAL('triggered()'), self.open_file)
        self.open_action = open_action

        save_as_action = QAction('Save &As...', self)
        save_as_action.setShortcuts(QKeySequence.SaveAs)
        self.connect(save_as_action, SIGNAL('triggered()'), self.save_as_file)
        self.save_as_action = save_as_action

        exit_action = QAction('E&xit', self)
        exit_action.setMenuRole(QAction.QuitRole)
        self.connect(exit_action, SIGNAL('triggered()'),
                     self, SLOT('close()'))
        self.exit_action = exit_action

        next_tab_action = QAction('Next Tab', self)
        bindings = QKeySequence.keyBindings(QKeySequence.NextChild)
        if sys.platform == 'darwin':
            bindings.append('Meta+PgDown')
            bindings.append('Meta+Tab')
        else:
            bindings.append('Ctrl+PgDown')
        next_tab_action.setShortcuts(bindings)
        self.connect(next_tab_action, SIGNAL('triggered()'), self.focus_next_tab);
        self.addAction(next_tab_action)

        previous_tab_action = QAction('Previous Tab', self)
        bindings = QKeySequence.keyBindings(QKeySequence.PreviousChild)
        if sys.platform == 'darwin':
            bindings.append('Meta+PgUp')
            bindings.append('Meta+Shift+Tab')
        else:
            bindings.append('Ctrl+PgUp')
        previous_tab_action.setShortcuts(bindings)
        self.connect(previous_tab_action, SIGNAL('triggered()'), self.focus_previous_tab);
        self.addAction(previous_tab_action)
開發者ID:enoki,項目名稱:bandleader,代碼行數:50,代碼來源:mainwindow.py

示例2: keybinding

# 需要導入模塊: from PyQt4.QtGui import QKeySequence [as 別名]
# 或者: from PyQt4.QtGui.QKeySequence import keyBindings [as 別名]
def keybinding(attr):
    """Return keybinding"""
    ks = getattr(QKeySequence, attr)
    return QKeySequence.keyBindings(ks)[0].toString()
開發者ID:cheesinglee,項目名稱:spyder,代碼行數:6,代碼來源:qthelpers.py


注:本文中的PyQt4.QtGui.QKeySequence.keyBindings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。