[wxPython] Question about using validators

Hi wxPython freaks !

I'm just new to wxPython and want to write a database app based on it. By
just reading the doc or checking the demo source code I was not able to
figure out how to assign a variable to a validator, that is then used to
fill the tex field or whatever.

Any help is appreciated

Alexander

I used a similar idea for my database app, basically i have a list that
contains the fields that have been changed.

the validator is a on_char that adds the field, if the user is allowed to
modify the field and it does not exist.

My method is being outgrown though. The validator will put the values into
each field, and transfer it out right?

My other idea is simply, a ismodified on the fields, and gets the values of
the modified.

Paul

I will let others respond to the question about validators, but for
the sake of variety I will describe my approach, which does not use
validators. I have been working on a set of "variables" which are
both "observable" and "storable". By storable, I mean that each
element knows how to save itself in an XML encoded datafile. And by
observable, I mean that each element maintains a list of observers
that are notified whenever a change in value occurs. Then on top of
this, each element has a set of wxPython "visual proxies" such that
one simply codes:

tc1 = container.subcontainer.element.TextCtrl(parent, id)

to create a wxTextCtrl that is automatically an Observer of the
element and automatically changes its element value when it loses
focus. If you want a combobox instead, simply use:

cb1 = container.subcontainer.element.ComboBox(parent, id)

where ...element.Choices = ('option 1', 'option 2', 'option 3')

If there is further interest in this approach, I could try to put
together a succint summary of how this is done.

···

--- "Alexander v. Zitzewitz" <a.zitzewitz@generic-home.de> wrote:

I'm just new to wxPython and want to write a database app based
on it. By just reading the doc or checking the demo source code
I was not able to figure out how to assign a variable to a
validator, that is then used to fill the tex field or whatever.

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

I'm just new to wxPython and want to write a database app based on it. By
just reading the doc or checking the demo source code I was not able to
figure out how to assign a variable to a validator, that is then used to
fill the tex field or whatever.

Take a look at wxValidator.py in the demo. The TextObjectValidator could be
modified to do what you want simply by implementing TransferToWindow and
TransferFromWindow to copy data to/from the textctrl to wherever you want.

The problem with doing it just like the C++ classes is that strings (and
other types) are immutable in Python so you can't just pass a string object
to the validator because when it updated it the reference in the validator
would now be to a new string object, and the original in your data class (or
whatever) would be unchanged. So in wxPython you have to get a little
creative, perhaps you could give your validator a pair of get/set methods to
manipulate the original string object with...

···

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