The posts from earlier underneath.
It leads me to believe that TestMixinList does not support the validator
keyword or does not pass it correctly to the ListCtrl class.
Anybody w/ a quick alternative of a ListCtrl that allows for user input
in a cell that can be validated?
Cheers
···
Am 24.10.11 20:40, schrieb werner:
On 10/24/2011 08:00 PM, Tobias Weber wrote:
Am 24.10.11 19:01, schrieb werner:
Hi Tobi,
On 10/24/2011 05:40 PM, Tobias Weber wrote:
I want to implement a validator in order to transfer data from a
TextEditMixinCtrl and simply do not know how- is it possible, or do I
have to transfer
adn validate data entered in a TextEditMixinList differently?My validator looks like this:
class DataCalculateValidator(wx.PyValidator):
def __init__(self, calcdata, key):
wx.PyValidator.__init__(self)
self.calcdata = calcdata
self.key = key
print calcdatadef Clone (self):
return DataCalculateValidator(self.calcdata, self.key)def Validate(self):
print 'here we go'# def TransferToWindow(self):
# print "TransferTO"
# #print data
# listCtrl = self.GetWindow()
# listtCtrl.SetValue(self.calcdata.get(self.key, ""))
# return Truedef TransferFromWindow(self):
listCtrl = self.GetWindow()
print "TransferFROM"
self.calcdata[self.key] = listCtrl.GetValue()
print calcdata
return True#----Here is my MixinClass:
class TestMxinList(wx.ListCtrl,listmix.TextEditMixin):
def __init__(self, parent,):
wx.ListCtrl.__init__(
self, parent, -1,
style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_VRULES,
#validator=wx.DefaultValidator,
)
listmix.TextEditMixin.__init__(self)#-----and then I create a new instance of the class on a notebook
panel:
self.list1 = TestMxinList(panel)
#-----here I would like to tell it that the value entered is
handled by
my validator
index = self.list1.InsertStringItem(sys.maxint,''),validator =
DataCalculateValidator(calcdata,"AMOUNT")You are trying to assign the validator to an item, you need to assign
it to the list.self.list1 = TestMxinList(panel, validator=DataCalculationValidator...
and then adapt your TransferTo/FromWindow to load items and to
read/save items.Werner
Thank you, but it doesn't work:
self.list1 =
TestMxinList(panel,validator=DataCalculateValidator(calcdata,'sample')TypeError: __init__() got an unexpected keyword argument 'validator'
Checking the doc for wx.ListCtrl definitely supports "validator"
keyword, so that means that TestMxinList either doesn't handle it or
doesn't pass it through correctly.Frankly, whenever I do this stuff I get really messed up and it takes
me ages to get it right.You need to show at least your TestMxinList.__init__ signature and the
code which inits the wx.ListCtrl or if you have a smallish runnable
sample I am sure someone will be able to help.Werner
After some research I must believe that you are right:
TestMxinList does not support the validator keyword, which puts me into
some serious trouble and i do not see why it wasn't implemented...