Hi, folks - Having some amazing fun with FXRuby, but not getting all the way there despite Lyle''s docs and book. Please see extracted example in DATA following __END__. I''m constructing a tab page of a block of TextFields plus sliders in construct_slider, but I don''t have the info-passing correct yet. I can trigger the puts with any SEL_COMMAND, but I''m not getting data back. I don''t get the value from the #{@in_vals[ targ ].value }, nor do I get updated screen contents. Please help an FXR noob get it right. All help appreciated!!! -- Don __END__ class VMDemoWindow < FXMainWindow def initialize( app ) image = VMImage.new( "wildebeest.jpg" ) @in_vals = { :u_1 => FXDataTarget.new } super( app, "Statistics Tool", :width => 550, :height => 450 ) splitter = FXSplitter.new( self, :opts => SPLITTER_HORIZONTAL|LAYOUT_FILL ) data_view = FXTabBook.new(splitter, :opts => LAYOUT_FILL ) image_view = VMImageView.new( splitter, image ) used_tab = FXTabItem.new( data_view, " % Used " ) used_page = FXHorizontalFrame.new( data_view, :opts => FRAME_RAISED | LAYOUT_FILL | PACK_UNIFORM_WIDTH ) construct_used_page( used_page ) end def construct_used_page( page ) construct_slider( page, :u_1, "usage" ) end def construct_slider( p, targ, str ) s = FXVerticalFrame.new( p, :opts => FRAME_RAISED | LAYOUT_FILL ) FXTextField.new( s, 3, :target => @in_vals[ targ ], :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_X ) do | t | t.justify = JUSTIFY_CENTER_X | JUSTIFY_CENTER_Y t.tipText = "Value for " + str end FXSlider.new( s, @in_vals[ targ ], :selector => FXDataTarget::ID_VALUE, :opts => SLIDER_VERTICAL | SLIDER_TICKS_LEFT | LAYOUT_FILL ) do | aSlider | aSlider.range = Range.new( 1,.100 ) aSlider.increment = 1 aSlider.tickDelta = 10 aSlider.tipText = "Value for " + str aSlider.height = 100 aSlider.slotSize = 10 aSlider.padTop = 10 aSlider.padBottom = 10 end @in_vals[ targ ].connect( SEL_COMMAND ) do | sender, sel, data | puts "\"#{ str }\" is now #{ @in_vals[ targ ].value }." end end end -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20080926/6edd2d1e/attachment.html>
On Sep 26, 2008, at 9:09 PM, Don Wilde wrote:> Please see extracted example in DATA following __END__. I''m > constructing a tab page of a block of TextFields plus sliders in > construct_slider, but I don''t have the info-passing correct yet. I > can trigger the puts with any SEL_COMMAND, but I''m not getting data > back. I don''t get the value from the #{@in_vals[ targ ].value }, nor > do I get updated screen contents.I''ve had to make some substitutions since the code you sent doesn''t run (missing classes VMImage and VMImageFrame), but I think the main problem is that you never initialized the data target to any particular value. The main change I made was just to initialize it to 0.5 (arbitrarily picked): @in_vals = { :u_1 => FXDataTarget.new(0.5) } When I do this, both the text field and the slider start out with this value, and changing either the text field or slider value updates the data target''s value as expected. Hope this helps, Lyle --- "FXRuby: Create Lean and Mean GUIs with Ruby" Now available from the Pragmatic Bookshelf! http://www.pragprog.com/titles/fxruby
Lyle - Bingo, you''ve got it. On Tue, Sep 30, 2008 at 8:17 PM, Lyle Johnson <lyle at lylejohnson.name> wrote:> > On Sep 26, 2008, at 9:09 PM, Don Wilde wrote: > > Please see extracted example in DATA following __END__. I''m constructing a >> tab page of a block of TextFields plus sliders in construct_slider, but I >> don''t have the info-passing correct yet. I can trigger the puts with any >> SEL_COMMAND, but I''m not getting data back. I don''t get the value from the >> #{@in_vals[ targ ].value }, nor do I get updated screen contents. >> > > I''ve had to make some substitutions since the code you sent doesn''t run > (missing classes VMImage and VMImageFrame), but I think the mainApologies. I stripped a lot more, should have left enough to let it run. problem is that you never initialized the data target to any particular> value. The main change I made was just to initialize it to 0.5 (arbitrarily > picked): > > @in_vals = { > :u_1 => FXDataTarget.new(0.5) > } >You bet, that did it. Thank you!!! :D> > When I do this, both the text field and the slider start out with this > value, and changing either the text field or slider value updates the data > target''s value as expected. > > Hope this helps, > > Lyle > > --- > "FXRuby: Create Lean and Mean GUIs with Ruby" > Now available from the Pragmatic Bookshelf! > http://www.pragprog.com/titles/fxruby > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20080930/bc7fa99c/attachment.html>