# Xrc loading in xrcise-generated base classes

**URL:** <https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573>\
**Category:** wxRuby\
**Created:** [February 29, 2008, 3:09pm UTC](https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573 "2008-02-29T15:09:48Z")\
**Posts on this page:** 4\
**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:** [February 29, 2008, 3:09pm UTC](https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573/1 "2008-02-29T15:09:48Z")

</div>

Just a small suggestion… after generating a dialog base class with  
xrcise, I end up having to modify the line to load the xrc file to the  
following:

```
xml.load(File.join(File.dirname( __FILE__ ),

```

“progress\_dialog\_base.xrc”))

in order to make sure the base class can still load the xrc if the  
working directory is not the app root - and this also enables me to keep  
all of your xrc files and generated classes in a project subdirectory…

Could something like this be added xrcise so this would be the default?  
It also might be nice to have xml.load search the ruby $LOAD\_PATH if  
that is possible…

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:** [February 29, 2008, 10:46pm UTC](https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573/2 "2008-02-29T22:46:10Z")

</div>

Hi Tim

Tim F. wrote:

> 

It’s a good point you raise …

> Could something like this be added xrcise so this would be the default?  
> It also might be nice to have xml.load search the ruby $LOAD\_PATH if  
> that is possible…

… but I’m not sure I’m wild about your exact solution, at least as the  
default. I personally to keep XRC files in share/, along with icons,  
translations etc, and only .rb files in lib/. It’s just a matter of  
preference.

Maybe the solution is a xrcise command-line option - or better, I should  
get around to finishing the XRC-\>pure ruby translator which removes the  
need for the XRC file at all at runtime. There’s a heap of code checked  
in to do this, I just never got around to hooking it up to the  
command-line tool.

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:** [February 29, 2008, 11:01pm UTC](https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573/3 "2008-02-29T23:01:22Z")

</div>

Alex F. wrote:

> It’s a good point you raise …
> 
> … but I’m not sure I’m wild about your exact solution, at least as the  
> default. I personally to keep XRC files in share/, along with icons,  
> translations etc, and only .rb files in lib/. It’s just a matter of  
> preference.

Agreed … and I like the idea of there being flexibility in whatever  
way this is approached. To each his own, and all that… 🙂

> Maybe the solution is a xrcise command-line option - or better, I should  
> get around to finishing the XRC-\>pure ruby translator which removes the  
> need for the XRC file at all at runtime. There’s a heap of code checked  
> in to do this, I just never got around to hooking it up to the  
> command-line tool.

A command line option would be cool … something like “append  
(interpolated) path”, maybe…

The thought occurs to me, though, that I could just just wire up the  
substitution as part of the rake task that generates the base classes…  
I just wasn’t sure if anyone else had a similar request…

As for the translator, do you intend to have it work in both directions  
or just from XRC to ruby? Sounds interesting in any case…

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:** [February 29, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/xrc-loading-in-xrcise-generated-base-classes/130573/4 "2008-02-29T23:35:11Z")

</div>

Tim F. wrote:

> > Maybe the solution is a xrcise command-line option - or better, I should  
> > get around to finishing the XRC-\>pure ruby translator which removes the  
> > need for the XRC file at all at runtime. There’s a heap of code checked  
> > in to do this, I just never got around to hooking it up to the  
> > command-line tool.
> 
> A command line option would be cool … something like “append  
> (interpolated) path”, maybe…

I’ll give it some thought, definitely in favour of this.

> The thought occurs to me, though, that I could just just wire up the  
> substitution as part of the rake task that generates the base classes…  
> I just wasn’t sure if anyone else had a similar request…

Actually, that’s probably an easier solution - should only be a few  
lines in Rake. You don’t want to see the extensive mangling that the  
wxRuby build process does to SWIG’s output.

> As for the translator, do you intend to have it work in both directions  
> or just from XRC to ruby? Sounds interesting in any case…

LOL - just XRC to ruby. Ruby to XRC would be … wild.

alex
