# Multi FXDataTarget

**URL:** <https://www.ruby-forum.com/t/multi-fxdatatarget/209963>\
**Category:** FXRuby\
**Created:** [July 27, 2011, 11:00am UTC](https://www.ruby-forum.com/t/multi-fxdatatarget/209963 "2011-07-27T11:00:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 27, 2011, 11:00am UTC](https://www.ruby-forum.com/t/multi-fxdatatarget/209963/1 "2011-07-27T11:00:15Z")

</div>

Hello There  
I’m trying to create a window that will display a line similar to what  
datatarget.rb exemple does, except it would do it for an unknown number  
of items, stocked in a given array.

Here is the code I would like to use except it doesn’t work:

#@repartition is a hash {string =\> [int,int]}  
#tech is the array of items & item.name is one of the keys of  
@repartition

@sum\_current=FXDataTarget.new(0)

@current\_techname=FXDataTarget.new("")

@sum\_current.connect(SEL\_CHANGED){  
@sum=@sum\_current.value  
}

@repartition.each{|key,val|  
@sum\_current.value=@sum\_current.value+val[1]  
}

datas=[]  
k=0

tech.each{|t|

```
  FXLabel.new(mtrix,"#{t.name}:")

  @repartition["#{t.name}"][0]=1

  datas.push(FXDataTarget.new(@repartition["#{t.name}"][1]))

  datas[k]

  datas[k].connect(SEL_CHANGED){

     @sum_current.value=@sum_current.value-@repartition["#{t.name}"][1]+datas[k].value
     @sum=@sum_current.value
     @repartition["#{t.name}"][1]= datas[k].value
  }

  FXSlider.new(mtrix, datas[k], FXDataTarget::ID_VALUE,
  LAYOUT_CENTER_Y|LAYOUT_FILL_ROW|LAYOUT_FIX_WIDTH, :width => 100)

  FXSpinner.new(mtrix,5, datas[k], FXDataTarget::ID_VALUE,
  SPIN_CYCLIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_FILL_ROW)

  FXProgressBar.new(mtrix, datas[k], FXDataTarget::ID_VALUE,
  (LAYOUT_CENTER_Y|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK|
  PROGRESSBAR_PERCENTAGE|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW))

k+=1

```

}

Thanks a lot for the time you will spend on this

EDIT: I tried to redefine a @data=FXDataTarget for each item, but this  
way the messaging is all messed up…
