def create_label(title):
global label_count
label_count += 1
label_w = 175
label_h = 75
gap = 10
label_w_with_gap = label_w + gap
label_h_with_gap = label_h + gap
labels_per_line = math.floor((v.width-2*gap)/(label_w+gap))
left_margin = (v.width - labels_per_line*label_w_with_gap + gap)/2
line = math.floor(label_count/labels_per_line)
column = label_count - line*labels_per_line
l = ui.Label(
text=title,
background_color='grey',
text_color='white',
alignment=ui.ALIGN_CENTER,
number_of_lines=0,
frame=(
left_margin+column * label_w_with_gap,
gap+line * label_h_with_gap,
label_w, label_h
))
v.add_subview(l)
return l
评论列表
文章目录