本文整理汇总了Python中vispy.util.event.EventEmitter.unblock方法的典型用法代码示例。如果您正苦于以下问题:Python EventEmitter.unblock方法的具体用法?Python EventEmitter.unblock怎么用?Python EventEmitter.unblock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vispy.util.event.EventEmitter
的用法示例。
在下文中一共展示了EventEmitter.unblock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_emitter_block
# 需要导入模块: from vispy.util.event import EventEmitter [as 别名]
# 或者: from vispy.util.event.EventEmitter import unblock [as 别名]
def test_emitter_block():
state = [False, False]
def a(ev):
state[0] = True
def b(ev):
state[1] = True
e = EventEmitter(source=None, type='event')
e.connect(a)
e.connect(b)
def assert_state(a, b):
assert state == [a, b]
state[0] = False
state[1] = False
e()
assert_state(True, True)
# test global blocking
e.block()
e()
assert_state(False, False)
e.block()
e()
assert_state(False, False)
# test global unlock, multiple depth
e.unblock()
e()
assert_state(False, False)
e.unblock()
e()
assert_state(True, True)
# test unblock failure
try:
e.unblock()
raise Exception("Expected RuntimeError")
except RuntimeError:
pass
# test single block
e.block(a)
e()
assert_state(False, True)
e.block(b)
e()
assert_state(False, False)
e.block(b)
e()
assert_state(False, False)
# test single unblock
e.unblock(a)
e()
assert_state(True, False)
e.unblock(b)
e()
assert_state(True, False)
e.unblock(b)
e()
assert_state(True, True)
# Test single unblock failure
try:
e.unblock(a)
raise Exception("Expected RuntimeError")
except RuntimeError:
pass
# test global blocker
with e.blocker():
e()
assert_state(False, False)
# test nested blocker
with e.blocker():
e()
assert_state(False, False)
e()
assert_state(False, False)
e()
assert_state(True, True)
# test single blocker
with e.blocker(a):
e()
assert_state(False, True)
# test nested gloabel blocker
with e.blocker():
#.........这里部分代码省略.........