# Multi frame image viewer not updating

**URL:** <https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320>\
**Category:** Ruby\
**Created:** [January 19, 2007, 2:24pm UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320 "2007-01-19T14:24:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 19, 2007, 2:24pm UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/1 "2007-01-19T14:24:59Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 19, 2007, 5:27pm UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/2 "2007-01-19T17:27:17Z")

</div>

On 1/19/07, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/fxruby-users

```

> 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

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 19, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/3 "2007-01-19T21:11:01Z")

</div>

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 J. 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

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 20, 2007, 1:20am UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/4 "2007-01-20T01:20:29Z")

</div>

On 1/19/07, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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#CREATELATER

```

> … 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

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 20, 2007, 5:08am UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/5 "2007-01-20T05:08:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 20, 2007, 4:35am UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/6 "2007-01-20T04:35:04Z")

</div>

Lyle J. 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#CREATELATER
> 
> ```

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.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 20, 2007, 11:06am UTC](https://www.ruby-forum.com/t/multi-frame-image-viewer-not-updating/82320/7 "2007-01-20T11:06:41Z")

</div>

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.
