From: Alex Fenton Date: 2008-04-01T06:10:04+09:00 Subject: Re: Displaying gruff graphs Victor Reyes wrote: > I finally got this working with wx by hard-coding the file path. That other first error looks like an ImageMagick problem. Sorry I can't help with that as I'm too lazy to install it; I just used wxRuby's own image file writing features to test it out quickly. > The graphs > (pie) is displayed, but now I have a small glitch, of course. > The frame is a about 1/4 of what it needs to be, and so I have to resize it > with the mouse. > Perhaps I need to make the frame where the graph is displayed a bit larger. > Is there anyway to make the size of the frame "dynamic" based on the size of > the image to be displayed? You can either constrain the frame to be a particular size, and prevent it being resized, or dynamically resize the graph image as the frame is resized by the user's use of the mouse. For the former, when you call super in the GruffFrame constructor, add the argument :style => Wx::DEFAULT_FRAME_STYLE ^ Wx::RESIZE_BORDER (i.e. use the default frame style, minus the mouse-draggable resize handle in the corner) Then in the GruffFrame#initialize method, set the Frame's client_size to the size you want the image, e.g. self.client_size = [480, 320] (The "client size" is the space within the Frame that is available for drawing on - its total pixel size minus the window borders, title bar etc. This way of setting the frame size will given consistent results across Linux, Windows and OS X) If you want the latter, a resizeable frame, on each refresh, tell Gruff what size of PNG you want. According to the docs, you can pass the Gruff Graph constructor a size as a string. So call new like this: graph = Gruff::Lines.new("#{client_size.width}x#{client_size.height}") If you go down this route, you'll probably also want to refresh the graph if the Frame is resized; use evt_size in the frame constructor for this: evt_size { | evt | refresh; evt.skip } > In the mean time I will look in the wx documentation. I expect you've found http://wxruby.rubyforge.org/doc/ If you've got further questions about wxRuby, there's a friendly mailing list which is a better place than c.l.r. for specifically wxRuby questions: http://rubyforge.org/mail/?group_id=35 alex