本文整理汇总了Python中ui.Label方法的典型用法代码示例。如果您正苦于以下问题:Python ui.Label方法的具体用法?Python ui.Label怎么用?Python ui.Label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ui
的用法示例。
在下文中一共展示了ui.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self, lcd, phone, backfn, label = 'Weather'):
self.phone = phone
super().__init__(lcd,backfn,label,ui.WHITE,ui.BLACK,ui.GREY)
y = const(30)
self.city = ui.Label(self,10,y-10,108,10,self.fg,self.bg,"City",1,1)
self.weather = ui.Label(self,10,y,108,10,self.fg,self.bg,"Weather",1,0)
self.icon = ui.Image(self,72,y+15,50,50,None)
self.temperature = ui.Label(self,10,y+15,54,20,self.fg,self.bg,"Temp",3,1,False)
self.humidity = ui.Label(self,10,y+35,54,10,self.fg,self.bg,"Humidity",1,0,False)
self.pressure = ui.Label(self,10,y+45,54,10,self.fg,self.bg,"Pressure",1,0,False)
self.wind = ui.Label(self,10,y+55,54,10,self.fg,self.bg,"Wind",1,0,False)
self.sunrise = ui.Label(self,10,y+75,80,10,self.fg,self.bg,"Sunrise",1,0,False)
self.sunset = ui.Label(self,10,y+85,80,10,self.fg,self.bg,"Sunset",1,0,False)
self.location1 = ui.Button(self,0,135,30,20,self.fg,self.bb,'Lon')
self.location1.callback(lambda x = 'GB/London': self.do_update(x))
self.location2 = ui.Button(self,40,135,30,20,self.fg,self.bb,'Ros')
self.location2.callback(lambda x = 'FR/Roscoff': self.do_update(x))
示例2: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self):
RootView.__init__(self)
self.t1=ui.Label(frame=(0,60,400,20))
self.t2=ui.Label(frame=(0,90,400,20))
self.t3=ui.TextView( frame=(0,120,700,200),bg_color=(0.7,0.7,0.7,0.5))
self.t3.text='textview for kb'
# the first time the keyboard appears, get kbframe is wrong...
# so, show then hide keyboard.
self.t3.begin_editing()
ui.delay(self.t3.end_editing,0.5)
# finally, show kbframe again
ui.delay(self.t3.begin_editing,1.0)
self.t1.text='touch to begin'
[self.add_subview(s) for s in [self.t1,self.t2,self.t3]]
示例3: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self, default_user_name='Name'):
self.name = 'Enter your username:'
self.background_color = 0.40, 0.80, 1.00
self.frame=(0, 0, 500, 500)
self.label = ui.Label(frame=(12, 100, 2000, 55))
self.label.text = 'What is your name?'
self.label.text_color = 'black'
self.label.font = ('Avenir-Black', 55)
self.add_subview(self.label)
self.text_field = ui.TextField(frame=(155, 175, 200, 32))
self.text_field.text = default_user_name
self.text_field.text_color = 'grey'
self.text_field.clear_button_mode = 'while_editing'
self.add_subview(self.text_field)
button = ui.Button(background_color='white',
frame=(360, 175, 75, 36),
image=ui.Image.named('ionicons-arrow-right-a-32'))
self.add_subview(button)
示例4: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self):
# Init
self.views = []
self.curview = None
self.root = ui.View(name="Multipanel")
self.close = ui.Button()
self.close.name = "close"
self.close.enabled = False
self.close.image = ui.Image.named("ionicons-close-round-32")
self.close.action = self.close_tapped
self.root.add_subview(self.close)
self.close.frame = self.root.width - 32, 0, 32, 32
self.close.flex = "LB"
self.tabs = ui.SegmentedControl()
self.tabs.name = "tabs"
self.tabs.enabled = False
self.tabs.selected_index = -1
self.tabs.segments = [PLACEHOLDER_TEXT]
self.tabs.action = self.segment_changed
self.root.add_subview(self.tabs)
self.tabs.frame = 0, 0, self.root.width - self.close.width, self.tabs.height
self.tabs.flex = "WB"
self.placeholder = ui.View()
self.placeholder.background_color = "lightgray"
self.ph_label = ui.Label()
self.ph_label.font = ("<system-bold>", 24)
self.ph_label.text_color = "gray"
self.ph_label.text = "No View Selected"
self.placeholder.add_subview(self.ph_label)
self.ph_label.size_to_fit()
self.ph_label.center = self.placeholder.center
self.ph_label.flex = "TBLR"
self.update_view()
示例5: tableview_cell_for_row
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def tableview_cell_for_row(self, tv, section, row):
cell = ui.TableViewCell()
entry = self.flat_entries[row]
level = entry.level - 1
image_view = ui.ImageView(frame=(44 + 20*level, 5, 34, 34))
label_x = 44+34+8+20*level
label_w = cell.content_view.bounds.w - label_x - 8
if entry.subtitle:
label_frame = (label_x, 0, label_w, 26)
sub_label = ui.Label(frame=(label_x, 26, label_w, 14))
sub_label.font = ('<System>', 12)
sub_label.text = entry.subtitle
sub_label.text_color = '#999'
cell.content_view.add_subview(sub_label)
else:
label_frame = (label_x, 0, label_w, 44)
label = ui.Label(frame=label_frame)
if entry.subtitle:
label.font = ('<System>', 15)
else:
label.font = ('<System>', 18)
label.text = entry.title
label.flex = 'W'
cell.content_view.add_subview(label)
if entry.leaf and not entry.enabled:
label.text_color = '#999'
cell.content_view.add_subview(image_view)
if not entry.leaf:
has_children = entry.expanded
btn = ui.Button(image=ui.Image.named('CollapseFolder' if has_children else 'ExpandFolder'))
btn.frame = (20*level, 0, 44, 44)
btn.action = self.expand_dir_action
cell.content_view.add_subview(btn)
if entry.icon_name:
image_view.image = ui.Image.named(entry.icon_name)
else:
image_view.image = None
cell.selectable = entry.enabled
return cell
示例6: display_toast
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def display_toast(view, help_text, width = 220, height = 110, show_duration=2, fade_duration=0.5, background_colour=(.42, .42, .42), text_colour= (.96, .96, .96), corner_radius=10):
w, h = ui.get_screen_size()
help_view = ui.View(frame=((w/2)-(width/2),(h/2)-height, width, height))
help_view.background_color = background_colour
help_view.corner_radius = corner_radius
label = ui.Label()
label.text = help_text
label.flex = 'H'
label.width = help_view.width * 0.9
label.alignment = ui.ALIGN_CENTER
label.x = (help_view.width / 2) - (label.width / 2)
label.y = (help_view.height / 2) - (label.height / 2)
label.number_of_lines = 3
label.text_color = text_colour
help_view.add_subview(label)
def animation_fade_in():
help_view.alpha = 1.0
def animation_fade_out():
help_view.alpha = 0.0
help_view.alpha = 0.0
view.add_subview(help_view)
ui.animate(animation_fade_in, duration=fade_duration)
time.sleep(show_duration+fade_duration)
ui.animate(animation_fade_out, duration=fade_duration)
time.sleep(fade_duration)
view.remove_subview(help_view)
示例7: make_labels
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def make_labels(self, cell, text, pos):
label = ui.Label()
label.border_color = 'lightgrey'
label.border_width = 0.5
if pos == 2:
label.text = str(datetime.datetime.fromtimestamp(text))
else:
label.text = str(text)
label.frame = (pos*self.width/3,0,self.width/3,self.row_height)
label.alignment = ui.ALIGN_CENTER
cell.content_view.add_subview(label)
示例8: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self):
w,h = ui.get_screen_size()
self.ty = ui.Label()
self.ty.text = 'Hello'
self.ty.text_color = 'black'
self.ty.font = ('<system>', 60)
self.ty.frame = (0, 0, w, h*0.25)
self.ty.bg_color = 'yellow'
self.sv = ui.ScrollView()
self.sv.width = w
self.sv.height = h*0.25
self.sv.content_size = (2*w, h*0.25)
self.sv.add_subview(self.ty)
self.add_subview(self.sv)
示例9: add
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def add(self, sender, text='Labeltext'):
self.labelcounter += 1
label = ui.Label(name='Label')
label.text = text
label.x = label.y = self.labelcounter * 20
self.add_subview(label)
示例10: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self):
self.view = ui.load_view('SpecialButton')
self.view.present('fullscreen')
self.label = ui.Label(frame=(120,100,100,100))
self.btn = MyButtonClass(self.label)
self.view.add_subview(self.btn) #watch the order, first button and then the label
self.view.add_subview(self.label)
示例11: _make_label
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def _make_label(name, text, font, color):
lb = ui.Label(name ='head')
lb.text = text
lb.font = font
lb.text_color = color
lb.size_to_fit()
return lb
示例12: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self, default=(0.0, 0.0, 0.0)):
self.r, self.g, self.b, = default
self.view = ui.View()
self.view.background_color = "#ffffff"
self.rslider = ui.Slider()
self.rslider.continuous = True
self.rslider.value = default[0]
self.rslider.tint_color = "#ff0000"
self.gslider = ui.Slider()
self.gslider.continuous = True
self.gslider.value = default[1]
self.gslider.tint_color = "#00ff00"
self.bslider = ui.Slider()
self.bslider.continuous = True
self.bslider.value = default[2]
self.bslider.tint_color = "#0000ff"
self.preview = ui.View()
self.preview.background_color = self.rgb
self.preview.border_width = 1
self.preview.border_color = "#000000"
self.preview.corner_radius = 5
self.rslider.action = self.gslider.action = self.bslider.action = self.slider_action
self.colorlabel = ui.Label()
self.colorlabel.text = self.hexcode
self.colorlabel.alignment = ui.ALIGN_CENTER
self.view.add_subview(self.rslider)
self.view.add_subview(self.gslider)
self.view.add_subview(self.bslider)
self.view.add_subview(self.preview)
self.view.add_subview(self.colorlabel)
w = self.view.width / 2.0
self.preview.width = w - (w / 10.0)
self.preview.x = w / 10.0
hd = self.view.height / 10.0
self.preview.height = (self.view.height / 3.0) * 2.0 - (hd * 2)
self.preview.y = hd
self.preview.flex = "BRWH"
self.colorlabel.x = self.preview.x
self.colorlabel.y = (hd * 2) + self.preview.height
self.colorlabel.height = (self.view.height / 3.0) * 2.0 - (hd * 2)
self.colorlabel.width = self.preview.width
self.colorlabel.flex = "BRWH"
self.rslider.x = self.gslider.x = self.bslider.x = w * 1.1
self.rslider.width = self.gslider.width = self.bslider.width = w * 0.8
self.rslider.flex = self.gslider.flex = self.bslider.flex = "LWHTB"
h = self.view.height / 9.0
self.rslider.y = h * 2
self.gslider.y = h * 4
self.bslider.y = h * 6
self.rslider.height = self.gslider.height = self.bslider.height = h
示例13: tableview_cell_for_row
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def tableview_cell_for_row(self, tv, section, row):
if section == self._folder_section:
item = self.items[row]
node = item['node']
else:
item = self._files[row]
node = None
cell = ui.TableViewCell()
cvb = cell.content_view.bounds
x = 15 + cvb.x + item['level'] * 15
if node and node.children_exists:
image_view = ui.ImageView()
image_view.frame = (x, 10, 24, 24)
image_view.image = ui.Image.named(
'iob:arrow_down_b_24' if node.path in self._expanded_node_paths else 'iob:arrow_right_b_24'
)
cell.content_view.add_subview(image_view)
x += 24 + 8
image_view = ui.ImageView()
image_view.frame = (x, 10, 24, 24)
image_view.image = ui.Image.named('iob:folder_24' if node else 'iob:document_24')
cell.content_view.add_subview(image_view)
x += 24 + 8
title_label = ui.Label(flex='W')
title_label.text = item['title']
title_label.size_to_fit()
title_label.frame = (
x, cvb.y + (cvb.height - title_label.height) / 2.0,
cvb.width - (x - cvb.x) - 8, title_label.height
)
cell.content_view.add_subview(title_label)
separator = ui.View(flex='W')
separator.background_color = (0, 0, 0, 0.05)
x = title_label.frame.x - 12 - 8
separator.frame = (
x, cvb.y + cvb.height - 1,
cvb.width - (x - cvb.x), 1
)
cell.content_view.add_subview(separator)
cell_objc = ObjCInstance(cell)
cell_objc.setSelectionStyle(0)
return cell
示例14: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self, container, state):
self._container = container
self._touch_began_location = None
self._initial_container_frame = None
self._container_superview = ObjCInstance(container).superview()
label = LayoutProxy(ui.Label())
label.font = ('<system>', 13.0)
label.alignment = ui.ALIGN_CENTER
label.text_color = get_theme_value('bar_title_color')
label.touch_enabled = False
self.add_subview(label)
label.layout.align_left_with_superview.equal = 0
label.layout.align_right_with_superview.equal = 0
label.layout.align_center_y_with_superview.equal = 0
self.title_label = label
button = LayoutProxy(ui.Button(title='x', tint_color=get_theme_value('tint_color')))
self.add_subview(button)
button.layout.align_left_with_superview.equal = 0
button.layout.align_top_with_superview.equal = 0
button.layout.align_bottom_with_superview.equal = 0
button.layout.width.equal = _OVERLAY_BAR_HEIGHT
self.close_button = button
button = LayoutProxy(ui.Button(title='-', tint_color=get_theme_value('tint_color')))
self.add_subview(button)
button.layout.align_right_with_superview.equal = 0
button.layout.align_top_with_superview.equal = 0
button.layout.align_bottom_with_superview.equal = 0
button.layout.width.equal = _OVERLAY_BAR_HEIGHT
self.collapse_button = button
separator = LayoutProxy(ui.View(background_color=get_theme_value('separator_color')))
self.add_subview(separator)
separator.layout.height.equal = 1
separator.layout.align_left_with_superview.equal = 0
separator.layout.align_bottom_with_superview.equal = 0
separator.layout.align_right_with_superview.equal = 0
self.separator = separator
self.update_appearance(state)
示例15: __init__
# 需要导入模块: import ui [as 别名]
# 或者: from ui import Label [as 别名]
def __init__(self, **kwargs):
super().__init__(**kwargs)
if 'background_color' not in kwargs:
self.background_color = 'white'
if 'frame' not in kwargs:
self.width = min(ui.get_window_size()[0] * 0.8, 700)
self.height = ui.get_window_size()[1] * 0.8
self._tableview = ui.TableView()
self._textfield = ui.TextField()
self._help_label = ui.Label()
self._datasource = None
self._handlers = None
self.shift_enter_enabled = True
self.did_select_item_action = None
tf = LayoutProxy(self._textfield)
self.add_subview(tf)
tf.layout.align_left_with_superview.equal = 8
tf.layout.align_top_with_superview.equal = 8
tf.layout.align_right_with_superview.equal = -8
tf.layout.height.equal = 31
tf.delegate = self
tv = LayoutProxy(self._tableview)
self.add_subview(tv)
tv.layout.align_left_to(tf).equal = 0
tv.layout.align_right_to(tf).equal = 0
tv.layout.top_offset_to(tf).equal = 8
tv.allows_selection = True
tv.allows_multiple_selection = False
hl = LayoutProxy(self._help_label)
self.add_subview(hl)
hl.layout.align_left_to(tv).equal = 0
hl.layout.align_right_to(tv).equal = 0
hl.layout.top_offset_to(tv).equal = 8
hl.layout.align_bottom_with_superview.equal = -8
hl.layout.height.max = 66
hl.font = ('<system>', 13.0)
hl.alignment = ui.ALIGN_CENTER
hl.text_color = (0, 0, 0, 0.5)
hl.number_of_lines = 2
if is_in_hardware_keyboard_mode:
tf.view.begin_editing()
self._register_key_event_handlers()