[wxPython] validators & xml resources

i want to use validators for my xml generated dialogs.

within the manual i found this:

../docs/wx/wx476.htm#validatoroverview
--- snip ---
So if using validators and a normal OK button, you may not even need to
write any code for handling dialog dismissal.
If you load your dialog from a resource file, you will need to iterate
through the controls setting validators, since validators can't be
specified in a dialog resource.
--- snip ---

could someone please give me a hint how to do this?

thanks in advance.

/achim

../docs/wx/wx476.htm#validatoroverview
--- snip ---
So if using validators and a normal OK button, you may not even need to
write any code for handling dialog dismissal.
If you load your dialog from a resource file, you will need to iterate
through the controls setting validators, since validators can't be
specified in a dialog resource.
--- snip ---

could someone please give me a hint how to do this?

Well the text is about using the old style resources but I think the same
thing applies to xrc. What you'll want to do is get the window that needs
the validator using FindWindowById and then calling SetValidator on it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Well the text is about using the old style resources but I think
the same thing applies to xrc. What you'll want to do is get the
window that needs the validator using FindWindowById and then
calling SetValidator on it.

Right. I'll only add that you can use XRCCTRL("name") to access the
window, you need not use FindWindow(ById) directly.

VS

Robin Dunn wrote:
> Well the text is about using the old style resources but I think
> the same thing applies to xrc. What you'll want to do is get the
> window that needs the validator using FindWindowById and then
> calling SetValidator on it.

Right. I'll only add that you can use XRCCTRL("name") to access the
window, you need not use FindWindow(ById) directly.

Oops, yes I forgot about that. Much easier...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

> Robin Dunn wrote:
> > Well the text is about using the old style resources but
I think the
> > same thing applies to xrc. What you'll want to do is get
the window
> > that needs the validator using FindWindowById and then calling
> > SetValidator on it.
>
> Right. I'll only add that you can use XRCCTRL("name") to access the
> window, you need not use FindWindow(ById) directly.

Oops, yes I forgot about that. Much easier...

thanks for your hints, but how does the validator know how many
TextCtrl's are within the dialog and how they should be validated?

regards,

achim

thanks for your hints, but how does the validator know how many
TextCtrl's are within the dialog and how they should be validated?

Because you should assign a new validator instance to each control that
needs one, and presumably the type of validator you use and/or how you
initialize it will determine how it validates.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Because you should assign a new validator instance to each
control that needs one, and presumably the type of validator
you use and/or how you initialize it will determine how it validates.

ok, but how can i iterate through the controls of the xml generated
dialog and how can i determine the type of the control (if i don't know
how the dialog is setted up)?

regards
achim

>
> Because you should assign a new validator instance to each
> control that needs one, and presumably the type of validator
> you use and/or how you initialize it will determine how it validates.

ok, but how can i iterate through the controls of the xml generated
dialog and how can i determine the type of the control (if i don't know
how the dialog is setted up)?

Parse the XML yourself and for all the "object" nodes get the "name"
attribute and use that with XRCCTRL to get the actual widget.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!