当前位置: 首页>>代码示例>>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;未经允许,请勿转载。