# Constants not recognized?

**URL:** <https://www.ruby-forum.com/t/constants-not-recognized/161938>\
**Category:** wxRuby\
**Created:** [March 4, 2009, 2:53am UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938 "2009-03-04T02:53:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 2:53am UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/1 "2009-03-04T02:53:40Z")

</div>

I just upgraded to wxRuby 2 and am having the following issue… With  
code like this:

dd = Wx::DirDialog.new(@dialog,  
‘Select the folder to process…’,  
File.join(@home, ‘Desktop’),  
Wx::DD\_DEFAULT\_STYLE | Wx::DD\_DIR\_MUST\_EXIST |  
Wx::DD\_CHANGE\_DIR)  
dd.show\_modal == Wx::ID\_OK ? @basedir = dd.get\_path : exit

I get the following error:

uninitialized constant Wxruby2::DD\_DEFAULT\_STYLE (NameError)

When I remove the style flags I get no such error… Ideas?

I am on Mac OS X and I installed via the rubyforge gem…

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 8:02pm UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/2 "2009-03-04T20:02:26Z")

</div>

Tim F. wrote:

> I just upgraded to wxRuby 2 and am having the following issue… With  
> code like this:

What version did you upgrade from?

> dd = Wx::DirDialog.new(@dialog,  
> ‘Select the folder to process…’,  
> File.join(@home, ‘Desktop’),  
> Wx::DD\_DEFAULT\_STYLE | Wx::DD\_DIR\_MUST\_EXIST |  
> Wx::DD\_CHANGE\_DIR)  
> dd.show\_modal == Wx::ID\_OK ? @basedir = dd.get\_path : exit
> 
> I get the following error:
> 
> uninitialized constant Wxruby2::DD\_DEFAULT\_STYLE (NameError)

Those constants look to be missing, thanks for the report. But I don’t  
believe any recent change has done this.

To work around this for now you can add the defines yourself:

Wx::DD\_DEFAULT\_STYLE = Wx::DEFAULT\_DIALOG\_STYLE|Wx::RESIZE\_BORDER  
Wx::DD\_CHANGE\_DIR = 0x0100  
Wx::DD\_DIR\_MUST\_EXIST = 0x0200

a

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 8:09pm UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/3 "2009-03-04T20:09:55Z")

</div>

Alex F. wrote:

> What version did you upgrade from?

1.9.5 I think … but this is new code anyway. I do know that the FD\_\*  
constants were working and are not now as well… maybe that helps?

> Those constants look to be missing, thanks for the report. But I don’t  
> believe any recent change has done this.
> 
> To work around this for now you can add the defines yourself:
> 
> Wx::DD\_DEFAULT\_STYLE = Wx::DEFAULT\_DIALOG\_STYLE|Wx::RESIZE\_BORDER  
> Wx::DD\_CHANGE\_DIR = 0x0100  
> Wx::DD\_DIR\_MUST\_EXIST = 0x0200

Great - thanks for that!

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/4 "2009-03-04T20:13:57Z")

</div>

Tim F. wrote:

> 1.9.5 I think … but this is new code anyway. I do know that the FD\_\*  
> constants were working and are not now as well… maybe that helps?

Correction - only Wx::FD\_DEFAULT\_STYLE seems to be undefined…

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 8:47pm UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/5 "2009-03-04T20:47:52Z")

</div>

Tim F. wrote:

> > 1.9.5 I think … but this is new code anyway. I do know that the FD\_\*  
> > constants were working and are not now as well… maybe that helps?

I don’t think these have ever existed in wxRuby 1.9.x (though they  
should have).

> Correction - only Wx::FD\_DEFAULT\_STYLE seems to be undefined…

Thanks again:

Wx::FD\_DEFAULT\_STYLE = Wx::FD\_OPEN

alex

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 4, 2009, 8:51pm UTC](https://www.ruby-forum.com/t/constants-not-recognized/161938/6 "2009-03-04T20:51:18Z")

</div>

Alex F. wrote:

> I don’t think these have ever existed in wxRuby 1.9.x (though they  
> should have).

That is probably the case … I went back and looked at a deployed app I  
had and I had used Wx::FD\_OPEN instead of Wx::FD\_DEFAULT\_STYLE then  
anyway…

Thanks!  
Tim
