[wxruby-users] Xrc Q ; using mulitple layouts(Frames , dialogs , panels)
Alex Fenton
alex at pressure.to
Fri Nov 21 05:08:04 EST 2008
Jn Jn wrote:
> ./TestXrc.rb:69:in `find_window_by_id': Error wrapping object; class
> `wxFilePickerCtrl' is not supported in wxRuby (NotImplementedError)
> from ./TestXrc.rb:69:in `initialize'
>
>
...
> As wxruby does not support wxFilePicker, is there an alternative (
> and FileDialog (Which I suppose I could have used, is not there on
> wxFormbuilder) is there any other alternative?
>
The alternative is to do what you've done below. In fact, this is what
wxWidgets does anyway on Windows and OS X; the "wxFilePicker" is only a
native control on GTK. This is the main reason the class isn't ported.
> Problem 2.
> I put a textbox+button combo to work around the unavailablity of
> filepickerctrl. but now I am in a sort of design issue due lack
> understanding on how I can make the dialog a child of frame and from
> there I can catch its events
>
I'm not clear which dialog you mean, or where the FilePicker goes. If
all you want to do is allow the user to choose a file to open (like an
"Open" item in a menu), you don't need FilePicker. The simplest way is
just to use Wx::file_selector function
evt_menu(Wx::ID_OPEN) do
file_to_open = Wx::file_selector('Choose a file')
# .... note that file_to_open will be an empty string if the user
chose Cancel
end
For more control, use Wx::FileDialog - see the docs and the dialog sample.
> Here is the design
> TestXrcWrapperClass << TestXrc(BaseFrame) and
> BrowseFileWrapperClass << Browsefile(OpenfileDialog)
> TestApp creats TestXrcWrapperClass which create
> BrowsefilewarraperClass.
>
> Q. How will I get the close events from dialog to the Frame?
dlg = MyDialog.new(self, ...)
dlg.evt_close { | evt | puts 'my child dialog has closed'; evt.skip }
But conventionally, modal (blocking) dialogs communicate the user's
selection back to the calling frame through the return value of
show_modal, eg:
dlg = Wx::FileDialog.newl(self, ...)
result = dlg.show_modal
if result = Wx::ID_OK
puts 'you chose' + dlg.file
else
puts 'you cancelled'
end
end
> Q. How do I put it into a parent child framework(the Dialog and Base
> Frame). ?Is that a better way to go?
You should definitely make a modal dialog a child of the calling frame.
I'd suggest you have a look at the dialogs.rb sample to see how it's done.
alex
More information about the wxruby-users
mailing list