I’m looking for info about how to best implement conditional formatting in the Tree Lister. I’ve done some research looking for related posts here. this was the only thing i could find, and it seems like it might be based on an earlier version of the lister.
If someone smart could maybe point me at the right callbacks that would be very much appreciated.
The textFormat row in the colDefine table lets you do Python f-string formatting for a column. You can also use the technique described in the post you linked to and it will work for treelister.
If you can be more specific about the task, I can give you better pointers.
The example in the thread is a list being assigned to an item. I can’t really tell from the code snippet what object in the class the list of objects is being assigned to. Moreover the list is a mixture of numbers and strings. If there is a class reference available that explains what’s happening in this example code I could probably make it a bit further on my own, but as it is, it just seems like “forensic programming”
The case I was specifically trying to solve is changing the font color, or weight/italics for the text based on conditional evaluation of the Lister inputs.
Also, I might be wrong, but doesn’t py f-string interpretation just allow you to modify the string? I don’t see how it could be used to actually affect the formatting (at least as far is the font/colors are concerned).
Ah, sorry I didn’t understand you meant look formatting not text formatting. This is an advanced lister concept, but here’s how you do it:
- On “Advanced” page, switch on Do Advanced Callbacks. (This change won’t take effect until the next time you change your callbacks)
- Use this callback to set the look depending on input text
if info[‘text’] != ‘pickyourconditional’:
info[‘ownerComp’].SetCellLookName(info[‘row’], info[‘col’], ‘button’)
‘button’ refers to the name of three button textCOMPs in the listerConfig (button, buttonRoll, buttonPress) that hold the info for how to format “button” cells in their parameters. You can make as many of these formats as you like, and you only need Rollover and Press versions if you want those looks to be different.
Note that the textCOMPs are just holding areas for data, not directly related to rendering the text. The readOnly parameters have no effect on lister.
Thanks for the info. I was looking at the onSetCell() callback but the docs indicate that the advanced callbacks incur a greater performance penalty so I wanted to see if it was possible with the normal set.
hey @Ivan one more on this: do know how I can keep the row striping when using other look COMPs?
That should just work as long as your strip color has transparency. if it’s not working, post example or send to firstname.lastname@example.org
@flowb when using SetCellLookName with row striping, there is a bug where the row color is overwritten. I’ll address that in a future build. For now a workaround is adding this line after the SetCellLookName call:
This fix will be built in starting with the next experimental release of TouchDesigner