# wxruby2::DefaultValidator not defined

**URL:** <https://www.ruby-forum.com/t/wxruby2-defaultvalidator-not-defined/157689>\
**Category:** wxRuby\
**Created:** [January 14, 2009, 1:24pm UTC](https://www.ruby-forum.com/t/wxruby2-defaultvalidator-not-defined/157689 "2009-01-14T13:24:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 1:24pm UTC](https://www.ruby-forum.com/t/wxruby2-defaultvalidator-not-defined/157689/1 "2009-01-14T13:24:48Z")

</div>

Hi, trying to display a bitmap button, don’t have a validator at the  
moment so using wxruby’s defaultvalidator method,

```
b = Wx::BitmapButton.new(self, 10, 'assets/images_only_btn.jpg',

```

Wx::Point.new(170,210), Wx::Size.new(120,80), 0, Wx::DefaultValidator,  
‘Import Data’)

should work but just returns me with…

“uninitialized constant Wxruby2::DefaultValidator (NameError)”

any ideas?

can’t find any examples anywhere, bit stuck

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 2:08pm UTC](https://www.ruby-forum.com/t/wxruby2-defaultvalidator-not-defined/157689/2 "2009-01-14T14:08:39Z")

</div>

John G. wrote:

> Hi, trying to display a bitmap button, don’t have a validator at the  
> moment so using wxruby’s defaultvalidator method,
> 
> ```
> b = Wx::BitmapButton.new(self, 10, 'assets/images_only_btn.jpg',
> 
> ```

This should be Wx::Bitmap.new(‘assets/images\_only\_btn.jpg’)

> Wx::Point.new(170,210), Wx::Size.new(120,80), 0, Wx::DefaultValidator,  
> ‘Import Data’)
> 
> should work but just returns me with..
> 
> “uninitialized constant Wxruby2::DefaultValidator (NameError)”

It’s not a method, it’s a constant, and its name is  
Wx::DEFAULT\_VALIDATOR. I’ve corrected the wrong naming of this in the  
documentation, sorry for the trouble.

By the way, this isn’t going to do what I’m guessing you want - display  
a button with an image and some text. The ‘name’ parameter only provides  
an internal reference name to any Window; I’ve never seen it used.

There’s no default widget to draw a bitmap + text button in wxRuby,  
because there isn’t one in wxWidgets 2.8. The reason given for this is  
that that button style isn’t part of the desktop standard on either  
Windows or OS X. It happens in Windows because there is little interface  
consistency, but it would look quite wrong on OS X.

If you give an ordinary Wx::Button a ‘stock id’ eg Wx::ID\_OPEN, it will  
be given the appropriate theme image on Linux/GTK.

I think that the wx developers have given in to people frequently asking  
for this and intend to add a bitmap + text button to wx 3.0

alex

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/wxruby2-defaultvalidator-not-defined/157689/3 "2009-01-14T14:17:15Z")

</div>

thanks, i sorted the problem below…

```
b_import_bmp_on = Wx::Bitmap.new('assets/images_only_btn_on.gif', 

```

BITMAP\_TYPE\_GIF)  
b = Wx::BitmapButton.new(self, 10, b\_import\_bmp\_off,  
Wx::Point.new(60,50), Wx::Size.new(73,21))  
b.bitmap\_selected = b\_import\_bmp\_on

works well, agree the documentation needs a bit of an overhaul, if only  
for more examples

may try adding to it after i get this task done.

great work and thanks again Alex,
