[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

multi frame image viewer not updating

Raj Sahae

1/19/2007 1:25:00 PM

Hi. I'm relatively new to FXRuby, and Ruby in general, so hopefully I
have just overlooked something simple. I am making a program that has a
image viewer on one side that shows multiple jpg's in a vertical frame.
Unfortunately, when I attempt to change the images in the viewer,
nothing happens. I'll post the relevant code. I may make a type in the
generalization of it, so if you spot one, that's not the solution:

(somewhere in a FXMainWindow class)
@stackViewerWindow = FXScrollWindow.new(@stackViewerFrame,
LAYOUT_FILL_X|LAYOUT_FILL_Y)
@stackViewer = FXVerticalFrame.new(@stackViewerWindow,
LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y, 0, 0, 357)
@pButton2.connect(SEL_COMMAND) do
@stackViewer = FXVerticalFrame.new(@stackViewerWindow,
LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y, 0, 0, 357)
random_object.display(theApp, @stackViewer)
end

(in some random_object class)
def display(theApp, target)
number = @cards.length
image = Array.new
imageView = Array.new
number.times do |number|
filename= @cards.at(number).card_id.to_s + ".jpg"
image[number] = FXJPGImage.new(theApp, nil,
IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
FXFileStream.open(filename, FXStreamLoad) do |stream|
image[number].loadPixels(stream)
end
image[number].create
imageView[number] = FXImageFrame.new(target, image[number])
end
end

Thanks for your help in advance!

--
Posted via http://www.ruby-....

6 Answers

Lyle Johnson

1/19/2007 4:27:00 PM

0

On 1/19/07, Raj Sahae <rajsahae@gmail.com> wrote:

> Hi. I'm relatively new to FXRuby, and Ruby in general, so hopefully I
> have just overlooked something simple.

You seem to have overlooked the FXRuby mailing list, among other things:

http://rubyforge.org/mailman/listinfo/fx...

> def display(theApp, target)
> number = @cards.length
> image = Array.new
> imageView = Array.new
> number.times do |number|
> filename= @cards.at(number).card_id.to_s + ".jpg"
> image[number] = FXJPGImage.new(theApp, nil,
> IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
> FXFileStream.open(filename, FXStreamLoad) do |stream|
> image[number].loadPixels(stream)
> end
> image[number].create
> imageView[number] = FXImageFrame.new(target, image[number])
> end
> end

It looks like you aren't calling create() on the new FXImageFrame
after you instantiate it. Try adding this:

imageView[number] = FXImageFrame.new(target, image[number])
imageView[number].create # add this line

Hope this helps,

Lyle

Raj Sahae

1/19/2007 8:11:00 PM

0

Thanks for the link to the mailing list.

The image viewer example code doesn't ever do that. Are you sure it's
necessary? In my readings so far I never see create called on the
FXImageFrame, only the FXImage. . .after adding that line I get a seg
fault.

Lyle Johnson wrote:

> It looks like you aren't calling create() on the new FXImageFrame
> after you instantiate it. Try adding this:
>
> imageView[number] = FXImageFrame.new(target, image[number])
> imageView[number].create # add this line
>
> Hope this helps,
>
> Lyle


--
Posted via http://www.ruby-....

Lyle Johnson

1/20/2007 12:20:00 AM

0

On 1/19/07, Raj Sahae <rajsahae@gmail.com> wrote:

> The image viewer example code doesn't ever do that. Are you sure it's
> necessary?

Yes. If you are creating any resource, whether it's an image, an icon,
a font, a window, etc. after the application is running, you need to
call create() on that resource to realize it. See this FAQ for more
information:

http://www.fox-toolkit.com/faq.html#C...

> ... after adding that line I get a seg fault.

OK. Without seeing the code in its entirety, I can't say for sure what
the problem is -- can you perhaps send me the program (or another
program that demonstrates the problem) off-line?

Thanks,

Lyle

Raj Sahae

1/20/2007 3:35:00 AM

0

Lyle Johnson wrote:
>
> Yes. If you are creating any resource, whether it's an image, an icon,
> a font, a window, etc. after the application is running, you need to
> call create() on that resource to realize it. See this FAQ for more
> information:
>
> http://www.fox-toolkit.com/faq.html#C...
>

I already call create on the instances of FXJPGImage, I need to call it
on the Image and the ImageFrame? The image viewer example only calls it
on the Image.

>
> OK. Without seeing the code in its entirety, I can't say for sure what
> the problem is -- can you perhaps send me the program (or another
> program that demonstrates the problem) off-line?
>
> Thanks,
>
> Lyle

I might be able to, let me work on altering it so you can use arbitraty
images.

--
Posted via http://www.ruby-....

Raj Sahae

1/20/2007 4:08:00 AM

0

I read the link, nevermind. Let me work on it some more. . .

--
Posted via http://www.ruby-....

Raj Sahae

1/20/2007 10:07:00 AM

0

So I read through that faq, learned a couple things, but I'm still
having the seg fault problem. I agree, I need to call create on a
couple things, and it sounds like I should be calling refresh, or
possibly forceRefresh on my FXApp? None of it helps, and I still have
no idea what could be causing the seg fault. I do know what line is
causing it, it's the create call to the imageFrame array. Numerous
other create calls had no errors, but that method brings the seg fault.

--
Posted via http://www.ruby-....