Forum: FXRuby Need hellp to position 4 images in fxfuby main window

B96a542ba3969981493f90081bf63958?d=identicon&s=25 John S. (jhs408)
on 2009-09-27 00:23
Please suggest how chart4.rb can be modified,  to position the 4
image
in the four corners of the main window.  Desired layout shown below.

  |------------------------|
  | chart1 | chart2 |
  |------------------------|
  |  chart3 | chart4 |
  |------------------------|


Thanks,
John


#  Chart4.rb
require 'fox16'
require 'google_chart'
require 'open-uri'


include Fox


class ChartsWindow < FXMainWindow
  def initialize(app)
    super(app, "Google Charts Demo", :width => 650, :height => 450)
    FXImageFrame.new(self, nil, :opts => FRAME_SUNKEN) do |f|
      f.image = FXPNGImage.new(app, open(pie_chart.to_escaped_url,
"rb").read)
    end
    FXImageFrame.new(self, nil ) do |f|
      f.image = FXPNGImage.new(app, open(line_chart.to_escaped_url,
"rb").read)
    end
    FXImageFrame.new(self, nil ) do |f|
      f.image = FXPNGImage.new(app, open(ven_chart.to_escaped_url,
"rb").read)
    end
    FXImageFrame.new(self, nil ) do |f|
      f.image = FXPNGImage.new(app, open(scatter_chart.to_escaped_url,
"rb").read)
    end
  end


  def pie_chart
    # Pie Chart
    GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
      pc.data "Apples", 40
      pc.data "Banana", 20
      pc.data "Peach", 30
      pc.data "Orange", 60
    end
  end


 def line_chart
    GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
      lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
      lc.show_legend = true
      lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
      lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
      lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size =>
16, :alignment => :center
      lc.axis :x, :range => [0,6], :color => '00ffff', :font_size =>
16, :alignment => :center
      lc.grid :x_step => 100.0/6.0, :y_step =>
100.0/6.0, :length_segment => 1, :length_blank => 0
    end
  end


 def ven_chart
    GoogleChart::VennDiagram.new("320x200", 'Venn Diagram') do |vd|
      vd.data "Blue", 100, '0000ff'
      vd.data "Green", 80, '00ff00'
      vd.data "Red",   60, 'ff0000'
      vd.intersections 30,30,30,10
    end
 end


 def scatter_chart
   GoogleChart::ScatterChart.new('320x200',"Scatter Chart") do |sc|
      sc.data "Scatter Set", [[1,1,], [2,2], [3,3], [4,4]]
      sc.max_value [5,5] # Setting the max value
      sc.axis :x, :range => [0,5]
      sc.axis :y, :range => [0,5], :labels => [0,1,2,3,4,5]
      sc.point_sizes [10,15,30,55] # Optional
    end
end


  def create
    super
    show(PLACEMENT_SCREEN)
  end
end


if __FILE__ == $0
  FXApp.new do |app|
    ChartsWindow.new(app)
    app.create
    app.run
  end
end
37ee5fa90f5eaeef62553629382497f7?d=identicon&s=25 Leslie Viljoen (leslieviljoen)
on 2009-11-11 21:07
You should try an FX4Splitter instead of the four frames. In your gems
directory, under your Ruby installation, you should find fxruby's
directory, and inside an examples directory. There should be an example
fxfold.rb which demonstrates how to use a FX4Splitter.
This topic is locked and can not be replied to.