Forum: wxRuby wxruby2::DefaultValidator not defined

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
760e5c90000057a6860986b69b77c400?d=identicon&s=25 John Griffiths (indiehead)
on 2009-01-14 13:24
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-01-14 14:08
(Received via mailing list)
John Griffiths 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
760e5c90000057a6860986b69b77c400?d=identicon&s=25 John Griffiths (indiehead)
on 2009-01-14 14:17
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,
This topic is locked and can not be replied to.