本文整理汇总了Python中PyQt4.QtGui.QShortcut.connect方法的典型用法代码示例。如果您正苦于以下问题:Python QShortcut.connect方法的具体用法?Python QShortcut.connect怎么用?Python QShortcut.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QShortcut
的用法示例。
在下文中一共展示了QShortcut.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_model_buttons
# 需要导入模块: from PyQt4.QtGui import QShortcut [as 别名]
# 或者: from PyQt4.QtGui.QShortcut import connect [as 别名]
def setup_model_buttons(self):
bhbl = QHBoxLayout()
bhbl.setSpacing(default_button_spacing)
for button_item in extra_buttons:
b = QPushButton(button_item["label"])
b.setToolTip(_("Change Note Type to {note_name}.").format(
note_name=button_item["note_name"]))
l = lambda s=self, nn=button_item["note_name"]: change_model_to(s, nn)
try:
s = QShortcut(
QKeySequence(_(button_item["shortcut"])), self.widget)
except KeyError:
pass
else:
s.connect(s, SIGNAL("activated()"), l)
try:
b.setFixedWidth(button_item["button_width"])
except KeyError:
b.setFixedWidth(default_button_width)
bhbl.addWidget(b)
self.connect(b, SIGNAL("clicked()"), l)
self.addLayout(bhbl)
示例2: setup_buttons
# 需要导入模块: from PyQt4.QtGui import QShortcut [as 别名]
# 或者: from PyQt4.QtGui.QShortcut import connect [as 别名]
def setup_buttons(chooser, buttons, text, do_function):
bhbl = QHBoxLayout()
if not isMac:
bhbl.setSpacing(0)
for button_item in buttons:
b = QPushButton(button_item["label"])
b.setToolTip(
_("Change {what} to {name}.").format(
what=text, name=button_item["name"]))
l = lambda s=chooser, nn=button_item["name"]: do_function(s, nn)
try:
s = QShortcut(
QKeySequence(_(button_item["shortcut"])), chooser.widget)
except KeyError:
pass
else:
s.connect(s, SIGNAL("activated()"), l)
if isMac:
b.setStyleSheet("padding: 5px; padding-right: 7px;")
bhbl.addWidget(b)
chooser.connect(b, SIGNAL("clicked()"), l)
chooser.addLayout(bhbl)