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