I tried to use validators in wxPython but probably I'm doing this in wrong
way. Please look at this and tell me what is wrong:
1. I created dialog box with one edit box
2. in dialog constructor I asigned validator to edit box control
__init__(self):
self.Angle = 0
self.AngleEdit = wxTextCtrl(size = wxSize(72, 21), value =
'', pos = wxPoint(240, 208), ...)
self.AngleEdit.SetValidator(MyValidator(self.Angle))
3. MyValidator class contains all needed methods: Clone, TransferToWindow,
TransferFromWindow, Validate.
Everything works fine but how can I then fetch data which is stored in
validator?
If validated object is not simple type but a class instance it will work
because only reference is used but in case of string, reals, ints etc.
validator creates its own copy of data. I have some solutions for that but I
belive that there should be a better way to do this.
My solutions:
1. Validator will get as input object and attribute name: MyValidator(self,
'Angle') - then it has only reference to object
2. Overwrite OnOK method and for each control: get its validator and read
data from it
Seems to be crazy, isn't it?
Mariusz