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


Python Signal.disconnect方法代码示例

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


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

示例1: method_test

# 需要导入模块: from pyanaconda.core.signal import Signal [as 别名]
# 或者: from pyanaconda.core.signal.Signal import disconnect [as 别名]
 def method_test(self):
     """Test if a method can be correctly connected to a signal."""
     signal = Signal()
     foo = FooClass()
     self.assertIsNone(foo.var)
     # connect the signal
     signal.connect(foo.set_var)
     # trigger the signal
     signal.emit("bar")
     # check if the callback triggered correctly
     self.assertEqual(foo.var, "bar")
     # try to trigger the signal again
     signal.emit("baz")
     self.assertEqual(foo.var, "baz")
     # now try to disconnect the signal
     signal.disconnect(foo.set_var)
     # check that calling the signal again
     # no longer triggers the callback
     signal.emit("anaconda")
     self.assertEqual(foo.var, "baz")
开发者ID:rvykydal,项目名称:anaconda,代码行数:22,代码来源:signal_test.py

示例2: lambda_test

# 需要导入模块: from pyanaconda.core.signal import Signal [as 别名]
# 或者: from pyanaconda.core.signal.Signal import disconnect [as 别名]
 def lambda_test(self):
     """Test if a lambda can be correctly connected to a signal."""
     foo = FooClass()
     signal = Signal()
     self.assertIsNone(foo.var)
     # connect the signal
     # pylint: disable=unnecessary-lambda
     lambda_instance = lambda x: foo.set_var(x)
     signal.connect(lambda_instance)
     # trigger the signal
     signal.emit("bar")
     # check if the callback triggered correctly
     self.assertEqual(foo.var, "bar")
     # try to trigger the signal again
     signal.emit("baz")
     self.assertEqual(foo.var, "baz")
     # now try to disconnect the signal
     signal.disconnect(lambda_instance)
     # check that calling the signal again
     # no longer triggers the callback
     signal.emit("anaconda")
     self.assertEqual(foo.var, "baz")
开发者ID:rvykydal,项目名称:anaconda,代码行数:24,代码来源:signal_test.py

示例3: function_test

# 需要导入模块: from pyanaconda.core.signal import Signal [as 别名]
# 或者: from pyanaconda.core.signal.Signal import disconnect [as 别名]
    def function_test(self):
        """Test if a local function can be correctly connected to a signal."""

        # create a local function
        def set_var(value):
            self.var = value

        signal = Signal()
        self.assertIsNone(self.var)
        # connect the signal
        signal.connect(set_var)
        # trigger the signal
        signal.emit("bar")
        # check if the callback triggered correctly
        self.assertEqual(self.var, "bar")
        # try to trigger the signal again
        signal.emit("baz")
        self.assertEqual(self.var, "baz")
        # now try to disconnect the signal
        signal.disconnect(set_var)
        # check that calling the signal again
        # no longer triggers the callback
        signal.emit("anaconda")
        self.assertEqual(self.var, "baz")
开发者ID:rvykydal,项目名称:anaconda,代码行数:26,代码来源:signal_test.py


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