Assign label text en masse

Hi @david1,

depending on your specific use case, you could place all components in a conatainer (proboably they already are)

Then iterate over each element in the container and get the elements from some data source. (list + enumerate ist just to deomonstrate)

values = ['col1text','col2text'...]

for idx,component in enumerate(self.some_panel.get_components()):
    component.label1.text = values[idx]

Alternatively you could populate the panel right from code. This is what I personally do in most cases, since its much more flexible this way.

values = ['col1text','col2text'...]

for value in values:
    new_col = CustomCompoent(value)
    self.colum_panel_1.add_component(now_col)

Or you could use DataBinding instead (I don’t really use it but there is a bunch of stuff in the docs/forum on that)

Greetings,
Mark

1 Like