[wxruby-users] Problems loading .xrc file
Max Salov
lists at ruby-forum.com
Wed Aug 27 07:36:28 EDT 2008
Magnus Engström wrote:
> Hi Magnus,
>
> I'm using XRC on both Windows and Linux, and I'm usually building
> applications the same way, so I wrote a template to have a quick
> starting point. It should work fine on Windows too I think.
> Make sure to start it from the right directory though (double-clicking
> on wxtemplate should work), currently it looks for ui/ui.xrc relative to
> starting directory.
>
> /Magnus
Hi Magnus,
I've found Your template very helpful for me. I have few ideas that can
be used in wxhelper::map_events
def map_events parent
parent.instance_variables.each do |variable|
object = parent.instance_variable_get(variable)
case object
when Wx::Button
method = variable.gsub(/^@(.+)$/,'\1_click').to_sym
parent.evt_button object, method if parent.respond_to? method
# and so on
end
end
end
Changes are:
1. find controls not by name, but by class
2. associate event handler only if it is present
I hope idea is clear.
Max
--
Posted via http://www.ruby-forum.com/.
More information about the wxruby-users
mailing list