Validators

Hello list.

I was trying to find an example about validators. The wxpython demo is a great resource, however I couldn't find any example transferring data to and from python variables.

Can such an example be found anywhere?

How can I pass a "reference" to the python variable to the validator?

Do you, people, generally use validators?

Thank you all!

Regards,
Stavros

Tsolakos Stavros escribio':

Hello list.

I was trying to find an example about validators. The wxpython demo is a great resource, however I couldn't find any example transferring data to and from python variables.

Can such an example be found anywhere?

How can I pass a "reference" to the python variable to the validator?

Do you, people, generally use validators?

I use validators a lot. Take this non-tested code as an example:

class MyValidator(wx.PyValidator):
def __init__(self, data, key):
self.data = data
self.key = key

def Clone(self):
return MyValidator(self.data, self.key)

def Validate(self):
return True

def TransferFromWindow(self):
w = self.GetWindow()
if self.key in self.data.keys():
w.SetValue(self.data[self.key])
return True

def TransferFromWindow(self):
w = self.GetWindow()
self.data[self.key] = w.GetValue()
return True

-- jonhattan

···

Thank you all!

Regards,
Stavros
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

jonhattan escribio':

Tsolakos Stavros escribio':

Hello list.

I was trying to find an example about validators. The wxpython demo is a great resource, however I couldn't find any example transferring data to and from python variables.

Can such an example be found anywhere?

How can I pass a "reference" to the python variable to the validator?

Do you, people, generally use validators?

I use validators a lot. Take this non-tested code as an example:

same code as an attachment, to not lost indentation.

validator_example.py (530 Bytes)

···

class MyValidator(wx.PyValidator):
def __init__(self, data, key):
self.data = data
self.key = key

def Clone(self):
return MyValidator(self.data, self.key)

def Validate(self):
return True

def TransferFromWindow(self):
w = self.GetWindow()
if self.key in self.data.keys():
w.SetValue(self.data[self.key])
return True

def TransferFromWindow(self):
w = self.GetWindow()
self.data[self.key] = w.GetValue()
return True

-- jonhattan

Thank you all!

Regards,
Stavros
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Jonhathan.

I was trying to find an example about validators. The wxpython demo is a great resource, however I couldn't find any example transferring data to and from python variables.

Can such an example be found anywhere?

How can I pass a "reference" to the python variable to the validator?

Do you, people, generally use validators?

I use validators a lot. Take this non-tested code as an example:

same code as an attachment, to not lost indentation.

:slight_smile:

Thank you very much for your kindness!

Regards,
Stavros

Tsolakos Stavros wrote:

Hello list.

I was trying to find an example about validators. The wxpython demo is a great resource, however I couldn't find any example transferring data to and from python variables.

Can such an example be found anywhere?

samples/wxPIA_book/Chapter-09/validator2.py

···

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