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.
Image after String in UI
-
I'm making a today widget that shows a number (unknown number of digits) with an image beside the number.
Using frames, I can place the ImageView next to my Label, but I'd like the image to hug the contents of the label.
I've tried adding the image view as a subview to the label, using flex, and hard coded paths. Can anyone please help me out on this?If I know how to get the width in pixels of the number string, I can adjust the frame accordingly, but I don't know how to do that either.
-
@psyFi Try ui.measure_string
-
@psyFi, call
size_to_fit
on the label. Your enclosing view probably needs to be custom so that you can implement thelayout
method where you first size the label and then position the image. If your text changes a lot, you might also implement atext
property for the enclosing class, where you can set the label text and then callsize_to_fit
on the enclosing view, or just the repositioning code directly.