tags:

views:

29

answers:

1
Shoes.app do
  flow do
    file = "something with variable length"
    para "Loading #{file}: "
    progress :width => -300
  end
end

As you can see from the code I am trying to display a progress bar that goes from the end of the text until the right edge of the application window. When the text has a fixed length this solution works but it doesn't once the text changes length in the above fragment: there will be either too little or too much space for the progress bar.

Is there a solution to this problem?

I tried asking the para element it's width but it is 0???

+1  A: 

As I mentioned before, you have to get the width of the textblock after it is calculated. Try this:

Shoes.app do
  flow do
    file = "something with variable length"
    @p = para "Loading #{file}: "
    @prog = progress
    start do
      @prog.width = @prog.parent.width - @p.width
    end
  end
  button 'Change text!' do
    text = @p.text
    @p.text = text + '1'
    @prog.width = @prog.parent.width - @p.width    
  end
end
Pesto
As you said: you solved my problem by answering the other question. Thank you.
Simon