本文整理汇总了Python中kivy.metrics.sp方法的典型用法代码示例。如果您正苦于以下问题:Python metrics.sp方法的具体用法?Python metrics.sp怎么用?Python metrics.sp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.metrics
的用法示例。
在下文中一共展示了metrics.sp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_touch_move
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def on_touch_move(self, touch):
if self._get_uid('svavoid') in touch.ud or\
self._drag_touch is not touch:
return super(DragBehavior, self).on_touch_move(touch) or\
self._get_uid() in touch.ud
if touch.grab_current is not self:
return True
uid = self._get_uid()
ud = touch.ud[uid]
mode = ud['mode']
if mode == 'unknown':
ud['dx'] += abs(touch.dx)
ud['dy'] += abs(touch.dy)
if ud['dx'] > sp(self.drag_distance):
mode = 'drag'
if ud['dy'] > sp(self.drag_distance):
mode = 'drag'
ud['mode'] = mode
if mode == 'drag':
self.x += touch.dx
self.y += touch.dy
return True
示例2: _toggle_dropdown
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def _toggle_dropdown(self, *largs):
self.is_open = not self.is_open
ddn = self._dropdown
ddn.size_hint_x = None
if not ddn.container:
return
children = ddn.container.children
if children:
ddn.width = max([self.width, children[0].minimum_width])
else:
ddn.width = self.width
for item in children:
item.size_hint_y = None
item.height = max([self.height, sp(48)])
示例3: generate_new_data
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def generate_new_data(self):
# Create a data set
contacts = []
names = ["Robert", "George", "Joseph", "Donald", "Mark", "Anthony", "Gary"]
medias = [
"http://www.geglobalresearch.com/media/Alhart-Todd-45x45.jpg",
"http://www.geglobalresearch.com/media/Alhart-Todd-45x45.jpg",
]
for x in range(1000):
if x % 100 == 0:
contacts.append({
"viewclass": "ContactSeparator",
"height": sp(20)
})
contacts.append({
"index": x,
"viewclass": "ContactItem",
"contact_media": random.choice(medias),
"contact_name": "{} {}".format(
random.choice(names),
random.choice(names)
)
})
self.root.ids.rv.data = contacts
示例4: editor_popup
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def editor_popup(title, content, answerCallback, size_hint=(None, None), size=(dp(500), dp(220)), hide_ok=False, auto_dismiss_time=None):
def auto_dismiss(*args):
popup.dismiss()
def on_title(instance, title):
popup.title = title
content.bind(on_title=on_title)
content = EditorPopup(content=content, hide_ok=hide_ok)
content.bind(on_answer=answerCallback)
popup = Popup(title=title,
content=content,
size=size, size_hint=size_hint,
auto_dismiss=True,
title_size=sp(18))
popup.open()
if auto_dismiss_time:
Clock.create_trigger(auto_dismiss, auto_dismiss_time)()
return popup
示例5: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(MDCheckbox, self).__init__(**kwargs)
self.register_event_type('on_active')
self.check_anim_out = Animation(font_size=0, duration=.1, t='out_quad')
self.check_anim_in = Animation(font_size=sp(24), duration=.1,
t='out_quad')
self.check_anim_out.bind(
on_complete=lambda *x: self.check_anim_in.start(self))
示例6: on_font_style
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def on_font_style(self, instance, style):
info = self._font_styles[style]
self.font_name = info[0]
self.bold = info[1]
if DEVICE_TYPE == 'desktop' and info[3] is not None:
self.font_size = sp(info[3])
else:
self.font_size = sp(info[2])
示例7: on_pos
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def on_pos(self, *args):
self.hint_anim_in = Animation(_hint_y=dp(34),
_hint_lbl_font_size=sp(12), duration=.2,
t='out_quad')
self.hint_anim_out = Animation(_hint_y=dp(10),
_hint_lbl_font_size=sp(16),
duration=.2,
t='out_quad')
示例8: apply_distance
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def apply_distance(self, distance):
os = abs(self.overscroll)
if os:
distance /= 1. + os / sp(200.)
super(DampedScrollEffect, self).apply_distance(distance)
示例9: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(FieldLabel, self).__init__(**kwargs)
self.bind(width=self.width_changed)
self.spacing = (20, 3)
self.font_name = "resource/fonts/ASL_regular.ttf"
self.font_size = sp(20)
self.shorten = True
self.shorten_from = 'right'
示例10: spct
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def spct(pct):
scale = sp(1)
scale = scale * 0.9 if scale > 1 else scale
return (pct * scale)
示例11: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(TextWidget, self).__init__(**kwargs)
self.bind(width=self.width_changed)
self.spacing = (20,3)
self.font_name = "resource/fonts/ASL_light.ttf"
self.font_size = sp(20)
示例12: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(PulseChannelsView, self).__init__(**kwargs)
self.channel_title = 'Timer '
self.accordion_item_height = sp(150)
示例13: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(GPIOChannelsView, self).__init__(**kwargs)
self.channel_title = 'Digital Input/Output '
self.accordion_item_height = sp(120)
示例14: set_error
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def set_error(self, error):
if self.warn_bubble is None:
warn = CenteredBubble()
warn.add_widget(WarnLabel(text=str(error), font_size=sp(12)))
warn.background_color = (1, 0, 0, 1.0)
warn.auto_dismiss_timeout(self.WARN_LONG_TIMEOUT)
control = kvFind(self, 'rcid', 'control')
warn.size = (control.width, dp(50))
warn.size_hint = (None, None)
self.add_widget(warn)
warn.center_below(control)
self.warn_bubble = warn
Clock.schedule_once(lambda dt: self.clear_error(), self.WARN_LONG_TIMEOUT)
示例15: __init__
# 需要导入模块: from kivy import metrics [as 别名]
# 或者: from kivy.metrics import sp [as 别名]
def __init__(self, **kwargs):
super(MDCheckbox, self).__init__(**kwargs)
self.register_event_type('on_active')
self.check_anim_out = Animation(font_size=0, duration=.1, t='out_quad')
self.check_anim_in = Animation(font_size=sp(24), duration=.1,
t='out_quad')
self.check_anim_out.bind(
on_complete=lambda *x: self.check_anim_in.start(self))