當前位置: 首頁>>代碼示例>>Python>>正文


Python NumericProperty.set方法代碼示例

本文整理匯總了Python中kivy.properties.NumericProperty.set方法的典型用法代碼示例。如果您正苦於以下問題:Python NumericProperty.set方法的具體用法?Python NumericProperty.set怎麽用?Python NumericProperty.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy.properties.NumericProperty的用法示例。


在下文中一共展示了NumericProperty.set方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_numericcheck

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_numericcheck(self):
        from kivy.properties import NumericProperty

        a = NumericProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)
        a.set(wid, 99)
        self.assertEqual(a.get(wid), 99)
開發者ID:DanAlbert,項目名稱:kivy,代碼行數:11,代碼來源:test_properties.py

示例2: test_numeric_string_without_units

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_numeric_string_without_units(self):
        from kivy.properties import NumericProperty

        a = NumericProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)

        a.set(wid, '2')
        self.assertEqual(a.get(wid), 2)
開發者ID:13768324554,項目名稱:kivy,代碼行數:12,代碼來源:test_properties.py

示例3: test_propertynone

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_propertynone(self):
        from kivy.properties import NumericProperty

        a = NumericProperty(0, allownone=True)
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)
        try:
            a.set(wid, None)
            self.assertEqual(a.get(wid), None)
        except ValueError, e:
            pass
開發者ID:Coffelius,項目名稱:kivy,代碼行數:14,代碼來源:test_properties.py

示例4: test_numeric_string_with_units_check

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_numeric_string_with_units_check(self):
        from kivy.properties import NumericProperty

        a = NumericProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)

        a.set(wid, '55dp')
        from kivy.core.window import Window
        density = Window._density if hasattr(Window, '_density') else 1
        self.assertEqual(a.get(wid), 55 * density)
        self.assertEqual(a.get_format(wid), 'dp')

        a.set(wid, u'55dp')
        self.assertEqual(a.get(wid), 55 * density)
        self.assertEqual(a.get_format(wid), 'dp')

        a.set(wid, '99in')
        self.assertEqual(a.get(wid), 9504.0 * density)
        self.assertEqual(a.get_format(wid), 'in')

        a.set(wid, u'99in')
        self.assertEqual(a.get(wid), 9504.0 * density)
        self.assertEqual(a.get_format(wid), 'in')
開發者ID:13768324554,項目名稱:kivy,代碼行數:27,代碼來源:test_properties.py

示例5: test_numericcheck

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_numericcheck(self):
        from kivy.properties import NumericProperty

        a = NumericProperty(0)
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)
        a.set(wid, 99)
        self.assertEqual(a.get(wid), 99)

        try:
            a.set(wid, '') # string shouldn't be accepted
            self.fail('number accept string, fail.')
        except ValueError:
            pass
開發者ID:Coffelius,項目名稱:kivy,代碼行數:17,代碼來源:test_properties.py

示例6: test_numeric_string_with_units_check

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_numeric_string_with_units_check(self):
        from kivy.properties import NumericProperty

        a = NumericProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), 0)

        a.set(wid, '55dp')
        self.assertEqual(a.get(wid), 55)
        self.assertEqual(a.get_format(wid), 'dp')

        a.set(wid, u'55dp')
        self.assertEqual(a.get(wid), 55)
        self.assertEqual(a.get_format(wid), 'dp')

        a.set(wid, '99in')
        self.assertEqual(a.get(wid), 9504.0)
        self.assertEqual(a.get_format(wid), 'in')

        a.set(wid, u'99in')
        self.assertEqual(a.get(wid), 9504.0)
        self.assertEqual(a.get_format(wid), 'in')
開發者ID:AWolf81,項目名稱:kivy,代碼行數:25,代碼來源:test_properties.py

示例7: test_reference

# 需要導入模塊: from kivy.properties import NumericProperty [as 別名]
# 或者: from kivy.properties.NumericProperty import set [as 別名]
    def test_reference(self):
        from kivy.properties import NumericProperty, ReferenceListProperty

        x = NumericProperty(0)
        x.link(wid, 'x')
        x.link_deps(wid, 'x')
        y = NumericProperty(0)
        y.link(wid, 'y')
        y.link_deps(wid, 'y')
        pos = ReferenceListProperty(x, y)
        pos.link(wid, 'pos')
        pos.link_deps(wid, 'pos')

        self.assertEqual(x.get(wid), 0)
        self.assertEqual(y.get(wid), 0)
        self.assertEqual(pos.get(wid), [0, 0])

        x.set(wid, 50)
        self.assertEqual(pos.get(wid), [50, 0])

        y.set(wid, 50)
        self.assertEqual(pos.get(wid), [50, 50])

        pos.set(wid, [0, 0])
        self.assertEqual(pos.get(wid), [0, 0])
        self.assertEqual(x.get(wid), 0)
        self.assertEqual(y.get(wid), 0)

        # test observer
        global observe_called
        observe_called = 0

        def observe(obj, value):
            global observe_called
            observe_called = 1
        pos.bind(wid, observe)

        self.assertEqual(observe_called, 0)
        x.set(wid, 99)
        self.assertEqual(observe_called, 1)
開發者ID:DanAlbert,項目名稱:kivy,代碼行數:42,代碼來源:test_properties.py


注:本文中的kivy.properties.NumericProperty.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。