本文整理汇总了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)
示例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()