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