Forum Archive

Button title text wrap

donnieh

Can a ui.button have text that wraps many lines? I can only get it to be one line...

JonB

little known fact: buttons are views, and can have subviews.
use a Label, as a subview of a button. see for example:

# coding: utf-8
import ui,faker
f=faker.Faker()

v=ui.View(frame=(0,0,576,576))
b=ui.Button(frame=(100,200,200,100),bg_color='#ffede7')
lbl=ui.Label(frame=(0,0,200,100),name='button_label')
lbl.number_of_lines=0
lbl.alignment=ui.ALIGN_CENTER

def a(sender):
   sender['button_label'].text=f.sentence()

b.action=a
b.add_subview(lbl)
v.add_subview(b)

v.present('sheet')
donnieh

Ooooh. Now that's interesting....