 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Rodrigo Gnoatto Amaral
RE: Gruff and Gtk [ reply ] 2007-01-12 14:27
|
Well, thats just not me then.
Today I was trying to do the same thing, use gruff with gtk, but when I call the methods write or to_blob, it returns the same error:
ruby: fccache.c:423: FcCacheFini: Assertion `fcCacheChains[i] == ((void *)0)' failed.
Did you find a solution?
There's not many information about that on the web.
|
By: Jay Bradley
Gruff and Gtk [ reply ] 2006-12-05 22:35
|
I'm trying to use gruff and Gtk but am running into a problem I haven't seen before. When I try to do a write('blah.png') I get the message:
ruby: fccache.c:412: FcCacheFini: Assertion `fcCacheChains[i] == ((void *)0)' failed.
Does anybody know where I should look for solving this issue. I can run ruby gruff programs by themselves and Gtk programs by themselves but mixing the two bits of code leads to this problem. Simply require'ing both gruff and gtk2 is okay and adding some simple buttons and the Gtk.main loop is okay but when I add more Gtk stuff I get the error. Below is the entire code for anyone more interested. It should run if you have Gtk and gruff installed. Some stuff is commented out but it shows the error if you click on the "New Plot" button.
I have the following gems installed:
gruff (0.2.8), rmagick (1.14.1)
I've manually installed gnome2. I've tried 0.15 and a recent CVS version.
Cheers,
Jay
#!/usr/bin/ruby
require 'rubygems'
require 'gruff'
require 'gtk2'
$stdout.sync = true
$plots = Array.new
$numberOfPlots = 0
$tempFile = ".TorqueInteractivePlotterTempFile.png"
class Plot
attr_reader :gtkImage, :plotVBox, :file
def initialize(plotFilenameEntry, plotOrSplotComboBox, plotWithComboBox, columnOneComboBox, columnTwoComboBox, columnThreeComboBox)
@timeoutTag = Gtk.timeout_add( 100000 ) do
draw
end
@gtkImage = Gtk::Image.new
@plotFilenameEntry = plotFilenameEntry
@plotFilenameEntry = plotFilenameEntry
@plotOrSplotComboBox = plotOrSplotComboBox
@plotWithComboBox = plotWithComboBox
@columnOneComboBox = columnOneComboBox
@columnTwoComboBox = columnTwoComboBox
@columnThreeComboBox = columnThreeComboBox
deleteButton = Gtk::Button.new("Delete")
deleteButton.signal_connect("clicked") do
Gtk.timeout_remove(@timeoutTag)
@plotVBox.destroy
$numberOfPlots -= 1
$plots.delete(self)
end
plotHBox = Gtk::HBox.new(false)
@plotVBox = Gtk::VBox.new
@plotFilenameEntry.reparent(plotHBox)
@plotOrSplotComboBox.reparent(plotHBox)
@plotWithComboBox.reparent(plotHBox)
@columnOneComboBox.reparent(plotHBox)
@columnTwoComboBox.reparent(plotHBox)
@columnThreeComboBox.reparent(plotHBox)
plotHBox.add(deleteButton, {"expand" => false})
@plotVBox.add(plotHBox, {"expand" => false})
@plotVBox.add(@gtkImage)
$topWindowsVBox.add(@plotVBox)
end
def draw
@plotFilenameEntry.text.gsub("\"", "\'")
print @plotFilenameEntry.text + "\n"
if File.file?(@plotFilenameEntry.text)
@file = File.new(@plotFilenameEntry.text, "r")
g = Gruff::Line.new
g.title = "My Graph"
g.data("Apples", [1, 2, 3, 4, 4, 3])
g.data("Oranges", [4, 8, 7, 9, 8, 9])
g.data("Watermelon", [2, 3, 1, 5, 6, 8])
g.data("Peaches", [9, 9, 10, 8, 7, 9])
g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
g.write($tempFile)
@gtkImage.file=($tempFile)
puts "Drawing done"
else
print "File: " + @plotFilenameEntry.text + " does not exist\n"
end
$topWindowsVBox.show_all
end
end
# widgets
addNewPlotButton = Gtk::Button.new("New Plot")
addNewPlotButton.signal_connect("clicked") do
#$plots[$numberOfPlots] = Plot.new(plotOrSplotComboBox.active_text, plotFilenameEntry.text, columnOneComboBox.active_text, columnTwoComboBox.active_text, columnThreeComboBox.active_text, plotWithComboBox.active_text)
$plots[$numberOfPlots] = Plot.new($plotFilenameEntry, $plotOrSplotComboBox, $plotWithComboBox, $columnOneComboBox, $columnTwoComboBox, $columnThreeComboBox)
$numberOfPlots += 1
drawPlots
addButtons
end
def addButtons
$plotFilenameEntry = Gtk::Entry.new()
$plotFilenameEntry.text=("/mnt/data/jay/development/torque/SocietyLearning/localTest/0learningPerformance.txt")
#$plotFilenameEntry.text=("/mnt/data/jay/development/torque/SocietyLearning/localTest/0Jay.getOutput");
$plotOrSplotComboBox = Gtk::ComboBox.new
$plotWithComboBox = Gtk::ComboBox.new
$columnOneComboBox = Gtk::ComboBox.new
$columnTwoComboBox = Gtk::ComboBox.new
$columnThreeComboBox = Gtk::ComboBox.new
#$plotOrSplotComboBox.append_text("plot")
#$plotOrSplotComboBox.append_text("splot")
$plotOrSplotComboBox.active=(0)
#$plotWithComboBox.append_text("lines")
#$plotWithComboBox.append_text("dots")
$plotWithComboBox.active=(0)
#(1..50).each do | number |
# $columnOneComboBox.append_text(number.to_s)
#end
$columnOneComboBox.active=(0)
#(1..50).each do | number |
# $columnTwoComboBox.append_text(number.to_s)
#end
$columnTwoComboBox.active=(0)
#(1..50).each do | number |
# $columnThreeComboBox.append_text(number.to_s)
#end
$columnThreeComboBox.active=(0)
$addNewPlotHbox.add($plotFilenameEntry, {"expand" => true})
$addNewPlotHbox.add($plotOrSplotComboBox, {"expand" => false})
$addNewPlotHbox.add($plotWithComboBox, {"expand" => false})
$addNewPlotHbox.add($columnOneComboBox, {"expand" => false})
$addNewPlotHbox.add($columnTwoComboBox, {"expand" => false})
$addNewPlotHbox.add($columnThreeComboBox, {"expand" => false})
$addNewPlotHbox.show_all
end
def drawPlots
$plots.each do | plot |
plot.draw
end
end
$addNewPlotHbox = Gtk::HBox.new
$addNewPlotHbox.add(addNewPlotButton, {"expand" => false})
# Initial commands
addButtons
drawPlots
# Main window
topWindow = Gtk::Window.new
topWindow.signal_connect("delete_event") {
#puts "delete event occurred"
#true
false
}
topWindow.signal_connect("destroy") {
#puts "destroy event occurred"
Gtk.main_quit
}
$topWindowsVBox = Gtk::VBox.new
topScrolledWindow = Gtk::ScrolledWindow.new
extraTopWindowsVBox = Gtk::VBox.new
topWindow.add(extraTopWindowsVBox)
topScrolledWindow.add_with_viewport($topWindowsVBox)
topScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
extraTopWindowsVBox.add($addNewPlotHbox, {"expand" => false})
extraTopWindowsVBox.add(topScrolledWindow)
# Run forever
topWindow.show_all
Gtk.main
|
|
 |