本文整理汇总了Python中vispy.util.event.EmitterGroup.connect方法的典型用法代码示例。如果您正苦于以下问题:Python EmitterGroup.connect方法的具体用法?Python EmitterGroup.connect怎么用?Python EmitterGroup.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vispy.util.event.EmitterGroup
的用法示例。
在下文中一共展示了EmitterGroup.connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_group_disconnect
# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import connect [as 别名]
def test_group_disconnect(self):
"""EmitterGroup.disconnect"""
grp = EmitterGroup(em1=Event)
assert len(grp.em1.callbacks) == 0, grp.em1.callbacks
grp.connect(self.record_event)
assert len(grp.em1.callbacks) == 1
grp.add(em2=Event)
assert len(grp.em2.callbacks) == 1
grp.disconnect()
assert len(grp.em1.callbacks) == 0
assert len(grp.em2.callbacks) == 0
示例2: test_group_connect
# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import connect [as 别名]
def test_group_connect(self):
grp = EmitterGroup(source=self, em1=Event)
grp.connect(self.record_event)
self.result = None
ev = grp.em1(test_key=1)
self.assert_result(
event=ev,
source=self,
sources=[
self,
self],
test_key=1)
示例3: test_group_block
# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import connect [as 别名]
def test_group_block(self):
"""EmitterGroup.block_all"""
grp = EmitterGroup(em1=Event, em2=Event)
def cb(ev):
self.result = 1
grp.em1.connect(self.record_event)
grp.em2.connect(self.record_event)
grp.connect(cb)
self.result = None
grp.block_all()
try:
grp.em1()
grp.em2()
grp(type='test_event')
finally:
grp.unblock_all()
assert self.result is None