当前位置: 首页>>代码示例>>Python>>正文


Python EmitterGroup.em2方法代码示例

本文整理汇总了Python中vispy.util.event.EmitterGroup.em2方法的典型用法代码示例。如果您正苦于以下问题:Python EmitterGroup.em2方法的具体用法?Python EmitterGroup.em2怎么用?Python EmitterGroup.em2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vispy.util.event.EmitterGroup的用法示例。


在下文中一共展示了EmitterGroup.em2方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_group_autoconnect

# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import em2 [as 别名]
    def test_group_autoconnect(self):
        """EmitterGroup auto-connect"""
        class Source:

            def on_em1(self, ev):
                self.result = 1

            def em2_event(self, ev):
                self.result = 2

            def em3_event(self, ev):
                self.result = 3
        src = Source()
        grp = EmitterGroup(source=src, em1=Event, auto_connect=False)
        src.result = None
        grp.em1()
        assert src.result is None

        grp = EmitterGroup(source=src, em1=Event, auto_connect=True)
        src.result = None
        grp.em1()
        assert src.result == 1

        grp.auto_connect_format = "%s_event"
        grp.add(em2=Event)
        src.result = None
        grp.em2()
        assert src.result == 2

        grp.add(em3=Event, auto_connect=False)
        src.result = None
        grp.em3()
        assert src.result is None
开发者ID:LiloD,项目名称:vispy,代码行数:35,代码来源:test_emitter_group.py

示例2: test_group_add_emitter

# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import em2 [as 别名]
    def test_group_add_emitter(self):
        """EmitterGroup.add"""
        grp = EmitterGroup(em1=Event)
        grp.em1.connect(self.record_event)
        self.result = None
        ev = grp.em1()
        self.assert_result(event=ev, type='em1')

        grp.add(em2=BasicEvent)
        grp.em2.connect(self.record_event)
        ev = grp.em2()
        self.assert_result(event=ev, type='em2', event_class=BasicEvent)

        grp.add(em3=TypedEvent)
        grp.em3.connect(self.record_event)
        ev = grp.em3(test_key=2)
        self.assert_result(
            event=ev,
            type='typed_event',
            event_class=TypedEvent,
            test_key=2)

        try:
            grp.add(em3=Event)
            assert False, "Double-added emitter"
        except ValueError:
            pass

        try:
            grp.add(add=Event)
            assert False, "Added event with invalid name"
        except ValueError:
            pass
开发者ID:LiloD,项目名称:vispy,代码行数:35,代码来源:test_emitter_group.py

示例3: test_add_custom_emitter

# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import em2 [as 别名]
    def test_add_custom_emitter(self):
        class Emitter(EventEmitter):

            def _prepare_event(self, *args, **kwds):
                ev = super(Emitter, self)._prepare_event(*args, **kwds)
                ev.test_key = 1
                return ev

        class Source:
            pass
        src = Source()

        grp = EmitterGroup(source=src, em1=Emitter(type='test_event1'))
        grp.em1.connect(self.record_event)
        self.result = None
        ev = grp.em1()
        self.assert_result(
            event=ev,
            test_key=1,
            type='test_event1',
            source=src)

        grp.add(em2=Emitter(type='test_event2'))
        grp.em2.connect(self.record_event)
        self.result = None
        ev = grp.em2()
        self.assert_result(
            event=ev,
            test_key=1,
            type='test_event2',
            source=src)
开发者ID:LiloD,项目名称:vispy,代码行数:33,代码来源:test_emitter_group.py

示例4: test_group_block

# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import em2 [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
开发者ID:LiloD,项目名称:vispy,代码行数:21,代码来源:test_emitter_group.py

示例5: test_group_construction

# 需要导入模块: from vispy.util.event import EmitterGroup [as 别名]
# 或者: from vispy.util.event.EmitterGroup import em2 [as 别名]
    def test_group_construction(self):
        """EmitterGroup basic construction"""
        grp = EmitterGroup(em1=Event, em2=BasicEvent, em3=TypedEvent)

        grp.em1.connect(self.record_event)
        grp.em2.connect(self.record_event)
        grp.em3.connect(self.record_event)
        self.result = None
        ev = grp.em1()
        self.assert_result(event=ev, type="em1", event_class=Event)
        ev = grp.em2()
        self.assert_result(event=ev, type="em2", event_class=BasicEvent)
        ev = grp.em3()
        self.assert_result(event=ev, type="typed_event", event_class=TypedEvent)
开发者ID:Zulko,项目名称:vispy,代码行数:16,代码来源:test_emitter_group.py


注:本文中的vispy.util.event.EmitterGroup.em2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。