PyValidator: Validation of one dialog field against another field in the same dialog?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PyValidator: Validation of one dialog field against another field in the same dialog?

Bob Klahn-2
How does one create a dialog that allows one field in that dialog to be
validated (presumably using PyValidator) against a different field in
that same dialog?  Possible?

If that is possible, would someone please point me to a simple example
that does that?

I'm using wxPython 3.0.2.0 msw (classic) with Python 2.7.13.

Bob

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PyValidator: Validation of one dialog field against another field in the same dialog?

GadgetSteve


On 18/11/2017 23:38, Bob Klahn wrote:

> How does one create a dialog that allows one field in that dialog to be
> validated (presumably using PyValidator) against a different field in
> that same dialog?  Possible?
>
> If that is possible, would someone please point me to a simple example
> that does that?
>
> I'm using wxPython 3.0.2.0 msw (classic) with Python 2.7.13.
>
> Bob
>

Bob,

I can't think of any specific examples out there but I have done similar
in the past and IIRC the trick was to, in the Validate method:

ctrl = self.GetWindow() # Get the control to validate
dlg = ctrl.GetParent() # Get the dialogue it is a part of
option = dlg.SomeOtherControl.GetValueOrSelection()

Then validate based on option, note that depending on the layout of your
dialogue you may have to do more than one GetParent and you will need to
know, (or check for the presence of), the name of the control that you
are deciding how to validate, etc.

Hope that is some help.


--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.
http://www.avg.com

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PyValidator: Validation of one dialog field against another field in the same dialog?

Bob Klahn-2
On 11/19/2017 12:42 AM, Steve Barnes wrote:

> On 18/11/2017 23:38, Bob Klahn wrote:
>> How does one create a dialog that allows one field in that dialog to be
>> validated (presumably using PyValidator) against a different field in
>> that same dialog?  Possible?
>>
>> If that is possible, would someone please point me to a simple example
>> that does that?
>>
>> I'm using wxPython 3.0.2.0 msw (classic) with Python 2.7.13.
>>
>> Bob
>>
> Bob,
>
> I can't think of any specific examples out there but I have done similar
> in the past and IIRC the trick was to, in the Validate method:
>
> ctrl = self.GetWindow() # Get the control to validate
> dlg = ctrl.GetParent() # Get the dialogue it is a part of
> option = dlg.SomeOtherControl.GetValueOrSelection()
>
> Then validate based on option, note that depending on the layout of your
> dialogue you may have to do more than one GetParent and you will need to
> know, (or check for the presence of), the name of the control that you
> are deciding how to validate, etc.
>
> Hope that is some help.
Aargh!  I've done this kind of thing many, many times, just not with a
validator.  Major brain failure!  Feeling my age.  :-(
Thanks, Steve.

Bob

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.