# How to dynamically change style (Button)

**URL:** <https://www.ruby-forum.com/t/how-to-dynamically-change-style-button/169620>\
**Category:** wxRuby\
**Created:** [June 5, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/how-to-dynamically-change-style-button/169620 "2009-06-05T23:10:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nonybd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@nonybd](https://www.ruby-forum.com/u/nonybd)\
**Post date:** [June 5, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/how-to-dynamically-change-style-button/169620/1 "2009-06-05T23:10:56Z")

</div>

Hello, world!

How does one go about changing the style of a button after it has  
already been made? Or if there is none, is there some way to highlight  
a button? The button can’t be a ToggleButton, it must be a  
BitmapButton.

Thanks!

---

<div class="post-metadata">

**Author:** ![nonybd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@nonybd](https://www.ruby-forum.com/u/nonybd)\
**Post date:** [June 17, 2009, 12:44pm UTC](https://www.ruby-forum.com/t/how-to-dynamically-change-style-button/169620/2 "2009-06-17T12:44:30Z")

</div>

Hi Jonah

Jonah D. wrote:

> How does one go about changing the style of a button after it has  
> already been made? Or if there is none, is there some way to highlight  
> a button? The button can’t be a ToggleButton, it must be a  
> BitmapButton.

I’m not sure exactly what you mean by style - if you just mean the  
bitmap that is shown, you can use set\_bitmap\_label (and also other  
set\_bitmap\_xxx methods for other states like hover, focus) to change the  
image that’s displayed. Using set\_bitmap\_focus and set\_bitmap\_selected  
will automatically deal with highlighted images for those states - you  
don’t need to managed this yourself.

If you need to change the formal “style” argument (eg Wx::BU\_AUTODRAW)  
then you have to swap two different widgets in and out, and show and  
hide them.

alex
