当前位置: 首页>>代码示例>>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;未经允许,请勿转载。