[fxruby-users] Multiple feeds to one data target
Don Wilde
dwilde1 at gmail.com
Fri Sep 26 22:09:34 EDT 2008
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>
More information about the fxruby-users
mailing list