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

コードからわかるように、テキストの最後からアプリケーション ウィンドウの右端まで進行状況バーを表示しようとしています。テキストの長さが固定されている場合、このソリューションは機能しますが、上記のフラグメントでテキストの長さが変わると機能しません。進行状況バーのスペースが少なすぎるか多すぎます。

この問題の解決策はありますか?

para要素に幅を尋ねてみましたが、0ですか???

4

1 に答える 1

1

前に述べたように、計算後にテキストブロックの幅を取得する必要があります。これを試して:

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
于 2009-08-18T15:19:28.930 に答える