I can not find any related posts about this or anything about this in the manual. How do you change the button text color?
Latest posts made by eli_sherwood
Adding additional labels during runtime
I am having an issue in my code that has stumped me for a while.
I want to be able to add labels to my view of varying length during runtime. The issue is that if a label I add exceeds a certain length, the label will not fit all of the contents that I want it to. This is only an issue if I am adding the labels during runtime as labels that are added before the view is presented will always display all of its contents.
It would be great if someone has an idea of why the label is size restricted while being added during runtime.
I was advised to use .size_to_fit() which does fix the sizing issue but for some reason, it changes the way the label fits in the coordinate system.
It would be equally great if someone could explain to me what is going on here as well.
Here is a demonstration of the problem I am experiencing:
import ui def addShortButton(sender): global numButtons label = ui.Label(text = "short title", center = (100, 240 + (20*numButtons)), flex = "w") numButtons+=1 view.add_subview(label) def addLongButton(sender): global numButtons label = ui.Label(text = "this is a long label title", center = (100, 240 + (20*numButtons)), flex = "w") #when this is uncommented, the label is not on the correct coordinate location #label.size_to_fit() numButtons+=1 view.add_subview(label) numButtons = 0 view = ui.View() view.background_color = "white" label = ui.Label(text = "short title", center = (100, 200), flex = "w") view.add_subview(label) label = ui.Label(text = "this is a long label title", center = (100, 220), flex = "w") view.add_subview(label) button = ui.Button(title = "click me to add a short button title", center = (50, 80), action = addShortButton) view.add_subview(button) button = ui.Button(title = "click me to add a long button title", center = (50, 110), action = addLongButton) view.add_subview(button) view.present()
How to add labels to a presented View
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!