[BUG]Grouped Labels with Font Binding

I have bindings on the font property of multiple labels for different sizes and styles (italic, bold, etc.). However, when I group multiple labels together they all end up with the same font style, despite having different individual properties. Attempting to re-bind the properties does nothing.

I don’t think this is a bug. Most likely this is intended design. Any software I have used for pretty much anything works this way.

Consider grouped items as a way to select multiple things.

Not sure why you need to group them?

If multiple items are selected and you change something it effects everything selected, not just one item.

So i’m assuming it is causing conflict per intention.

I don’t see a huge need to actually group, for design purposes you can select multiple items for moving around. I’d only group if i intended to impose the same thing on all grouped “selected” items.

Can you show exactly what you mean by ‘font binding’? You can’t directly attach a binding to a font property, at least on a standard label component.

A Container public style could be useful. I mean, configure a group of style first, then every components in that container get the styles.
Sometimes,we need to configure styles many times.

I have a binding directly to a font on EVERY label in my project so I can update all text font in an instant at the client’s request. To get it to work I temporarily bind to a different text property until the format string matches the format that I want, and then right-click copy binding and right-click paste binding on the font property. It works for me.

For instance concat({[default]Styles/textFont},", Plain, 18")

That seems silly. I should be able to group any independent objects any way I like and it the properties of every object should be unchanged.

I mean… so the actual issue here is that you’re allowed to do that, not what happens on grouping. You’ve essentially discovered undefined behavior - it happens to work, until we do the grouping operation and recreate the components, at which point your manually injected bindings happen to disappear.

What I would do to accomplish the same goal, but faster (for you as a developer) is use a script to recursively walk the component tree and change every label component’s font at once.

Starting from the code I posted here:

You just need a different filter function:

from com.inductiveautomation.factorypmi.application.components import PMILabel
isLabel = lambda component: isinstance(component, PMILabel)

And then your modification is as simple as setting the font:

from java.awt import Font
win = system.gui.getWindow("yourWindow")
for label in filter(isLabel, getComponents(win)):
	label.font = Font("name", Font.PLAIN, 18)
2 Likes