當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。