本文整理汇总了Python中kivy.properties.NumericProperty.link方法的典型用法代码示例。如果您正苦于以下问题:Python NumericProperty.link方法的具体用法?Python NumericProperty.link怎么用?Python NumericProperty.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.properties.NumericProperty
的用法示例。
在下文中一共展示了NumericProperty.link方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_numeric_string_with_units_check
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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')
示例2: test_numericcheck
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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)
示例3: test_numeric_string_without_units
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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)
示例4: test_propertynone
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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
示例5: test_numericcheck
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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
示例6: test_reference_child_update
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [as 别名]
def test_reference_child_update(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')
pos.get(wid)[0] = 10
self.assertEqual(pos.get(wid), [10, 0])
pos.get(wid)[:] = (20, 30)
self.assertEqual(pos.get(wid), [20, 30])
示例7: test_reference
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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)
示例8: test_numeric_string_with_units_check
# 需要导入模块: from kivy.properties import NumericProperty [as 别名]
# 或者: from kivy.properties.NumericProperty import link [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')