本文整理匯總了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')