Search code examples
rubyfxruby

fxruby Progressbar width


I don't know if I'm getting the whole documentation totally wrong but there is an issue I'm dealing with since two days and I just don't get what I'm doing wrong. I'm using fxruby to built a small GUI, and I need a progressbar within that. When I initialize it with no parameters its just ridiculously small, so I tried to use the barSize option (which is responsible for the width, at least the documentation says so). This is my source code:

require 'fox16'
require 'pp'

include Fox

class Test < FXMainWindow
  def initialize(app)
    super(app, "Test")

    hFrame1 = FXHorizontalFrame.new(self)

    @progBar = FXProgressBar.new(hFrame1)
    pp @progBar.barSize
    @progBar.barSize=100
    @progBar.setTotal(10)
    @progBar.setProgress(5)
    pp @progBar.barSize


    def create
      super
      show(PLACEMENT_SCREEN)
    end

  end
end

FXApp.new do |app|
    Test.new(app)
    app.create
    app.run
end

But this is what it looks like:

enter image description here(https://imgur.com/Mx7OmyJ)

So obviously the height gets changed. Obviously I also tried things like

:width => 150

in the constructor but it did not work at all. Seems like I'm just to stupid for fxruby. Could anyone point me to the right way please?


Solution

  • You need to learn about layout parameters. Try this modification of your Test class and I think you will know where to go from there:

    class Test < FXMainWindow
      def initialize(app)
        super(app, "Test", :width => 200, :height => 100)
    
        hFrame1 = FXHorizontalFrame.new(self, LAYOUT_FILL)
    
        @progBar = FXProgressBar.new(hFrame1, :opts => LAYOUT_FILL_X)
        pp @progBar.barSize
        @progBar.barSize=10
        @progBar.setTotal(10)
        @progBar.setProgress(5)
        pp @progBar.barSize
    
    
        def create
          super
          show(PLACEMENT_SCREEN)
        end
    
      end
    end