Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Just for fun: ui.ButtonItem multi-lines
-
import ui from objc_util import * v = ui.View() def b_action(sender): print(sender) b = ui.ButtonItem() b.action = b_action # set a ButtonItem custom view as an ui.Button where we can, via ObjectiveC # put its title (label text) as multilines vv = ui.Button() vv.title = 'aaa\nbbb' vv.tint_color = 'green' vv.action = b_action vv.frame = (0,0,100,32) vvo = ObjCInstance(vv) for sv in vvo.subviews(): if hasattr(sv,'titleLabel'): tl = sv.titleLabel() tl.numberOfLines = 0 tl.adjustsFontSizeToFitWidth = True # auto resize font to fit break ObjCInstance(b).customView = vvo v.right_button_items = (b,) v.present()
-
this is wonderfull! this should be implemented in the
ui
module as standard functionality! great job @cvp as usual -
@cvp, thanks for the multiline but also for making me aware of
adjustsFontSizeToFitWidth
. I am a bit cunfused, though, as the docs say it only applies to single-line labels. -
@mikael you're right, perhaps is adjustsFontSizeToFitWidth not needed... The doc says
"only intended for use with a single-line label". Not very clear.
Some tests show it does not work.
Thanks for the correction, thus let us keep only the multi-line aspect 🙄 -