Databindings if statement and formating

Hello,

I have two questions about data bindings:

  1. Can you have an if statement in the data binding, something like:
    image

  2. Can you use string formating:
    image

Yes to both of these but use the single line version of the if statement ie:
self.item['carbohydrates'] if self.item['carbohydrates'] != -1 else "None listed"

You can also use f strings or any other python expression in data bindings.

3 Likes

Note that this may make writeback impossible.

1 Like