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.
How to add labels to a presented View
-
Hello!
I am experiencing an issue inside of an application I built that is really annoying me.I want to add a label to an already presented view. This happens but if the label text is too big, the label is presented like: “this is m…”.
Here is my code:
labelText = textfield.text label = ui.Label(text = labelText) label.center = (125, h) label.flex = "w" viewTasks.add_subview(label)
I want the label to be sized to fit whatever is necessary. I use the exact code to set up the view before it is presented and it works fine but for some reason if I’m adding to an already presented view it doesn’t want to work the same.
Any suggestions are helpful!
-
@eli_sherwood try
label.size_to_fit()
-
@eli_sherwood said:
for some reason if I’m adding to an already presented view it doesn’t want to work the same
As soon a view is presented, you can't change its dimensions
-
@cvp thanks for the response!
Since I’m creating a new label why does it not just make the label the correct size?
I might not completely understand the view-sub view relationship.
-
@cvp thank you this is getting me closer. Do you know why this would change the coordinate system origin?
The labels no longer go where I want them to go…
-
@eli_sherwood could you post your full code relative to this, as we could check what you do and what you get. And, please, with indentation, use </> button when you write your post.