I am building a GUI that is separated in 3 columns, and in 1+ row.s. The number of row is decided by the user through an IntField.
Since every (displayed) row will contains plots, I don't want to detach them from the window in order to avoid recreating them. So I want to hide rows that aren't supposed to be displayed, keeping the already created, and attached, plots. I was thinking of the visible attribute of a container in order to do this.
Unfortunately the subscription doesn't seem to work on the visible field in my case.
Here is the code:
enamldef MyMenu(Container):
attr context
IntField:
minimum = 1
value := context.first_row
IntField:
minimum = 1
value := context.last_row
enamldef MyPanel(Container):
attr context
Label:
text << str(context.last_row - context.first_row)
# subscription will work and label is updated
Looper:
iterable = range(35)
Container:
visible << loop_index <= context.last_row - context.first_row
# visible won't update.
# Only the init value of last_row and first_row will have an impact
contraints = [height == 150]
Label:
text << str(context.last_sig - context.first_sig)
# subscription will work and label is updated even in the loop & the container
Does anyone have an idea?
Hmmm, not sure why
visible
isn't working for you. It should be. I don't have time to debug it right now.You could try using a
Conditional
object as the parent of the container: