0

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?

Nertie
  • 1
  • 1
  • After more investigation, it seems that visible IS working. The problems is coming from the parent container that neither draw the newly visible container, nor resize itself to be able to fit everything. Same thing with a ScrollArea: if I have 40 rows, and then 2, the ScrollArea will still think that there is 40 rows visible (and don't resize the scrollbar). – Nertie Sep 14 '18 at 15:05

1 Answers1

0

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:

enamldef MyPanel(Container):
  attr context
  Label:
    text << str(context.last_row - context.first_row)
  Looper:
    iterable = range(35)
    Conditional:
      condition << loop_index <= context.last_row - context.first_row
      Container:
        Label:
          text << str(context.last_sig - context.first_sig)
Chris Colbert
  • 868
  • 7
  • 12