# Static bitmap - set\_bitmap

**URL:** <https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230>\
**Category:** wxRuby\
**Created:** [January 3, 2011, 12:07pm UTC](https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230 "2011-01-03T12:07:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 3, 2011, 12:07pm UTC](https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230/1 "2011-01-03T12:07:27Z")

</div>

Hi all,  
I need to change at runtime the bitmap label of a Static Bitmap  
control.  
I use this code:

def change\_img\_at\_click  
img = File.join(File.dirname( **FILE** ), “/immagini/03\_muro\_RETT.png”)  
@m\_bitmap1.set\_bitmap(Wx::Bitmap.new(img))  
end

It works good, but every click the new image translate upward… why?

---

<div class="post-metadata">

**Author:** ![maidireale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@maidireale](https://www.ruby-forum.com/u/maidireale)\
**Post date:** [January 4, 2011, 9:15am UTC](https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230/2 "2011-01-04T09:15:59Z")

</div>

up

---

<div class="post-metadata">

**Author:** ![maidireale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@maidireale](https://www.ruby-forum.com/u/maidireale)\
**Post date:** [January 6, 2011, 4:04pm UTC](https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230/3 "2011-01-06T16:04:47Z")

</div>

On 03/01/2011 11:07, Alessandro B. wrote:

> I need to change at runtime the bitmap label of a Static Bitmap  
> control.  
> I use this code:
> 
> def change\_img\_at\_click  
> img = File.join(File.dirname( **FILE** ), “/immagini/03\_muro\_RETT.png”)  
> @m\_bitmap1.set\_bitmap(Wx::Bitmap.new(img))  
> end
> 
> But avery click the new image translate upward… why?

Looks OK. Are the images the same size?

I don’t remember needing to do this, but you might try calling  
sizer.layout on the containing sizer

a

---

<div class="post-metadata">

**Author:** ![maidireale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@maidireale](https://www.ruby-forum.com/u/maidireale)\
**Post date:** [January 6, 2011, 4:36pm UTC](https://www.ruby-forum.com/t/static-bitmap-set-bitmap/201230/4 "2011-01-06T16:36:10Z")

</div>

On 04/01/2011 08:15, Alessandro B. wrote:

> up

PS - please don’t do this. You might think you’re looking at a forum,  
but this is primarily a mailing list which a third party mirrors onto a  
forum. This kind of message is annoying to the m.l. users.

Happy to help in the future, but you may find you get a quicker response  
if you provide more detail about what you’re trying to do, what you  
expected to happen that didn’t, and a complete, simplified runnable  
sample.

cheers  
alex
