wx.ListCtrol,listmix.textEditMixin - implement a validator

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 calcdata
      
    def 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 True

    def 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")

I am lost ...

ThanX,

Tobi

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 calcdata

     def 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 True

     def 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'

···

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 calcdata

     def 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 True

     def 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

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

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

···

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 calcdata

      def 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 True

      def 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'

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...

I see if I can quickly switch to Andrea's UltimateListCtrl and add a
TextCtrl to a cell whose content I should be able to connect w/ a custom
validator I hope

I will open a new thread and see if there is any example on that.

Thank you so far Werner

···

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 calcdata

      def 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 True

      def 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

You could implement it and submit a patch.

···

On 10/24/11 12:34 PM, Tobias Weber wrote:

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 calcdata

       def 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 True

       def 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...

--
Robin Dunn
Software Craftsman

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:
Unfortunately I supposed it was there, so now I need a workaround for
about 30 ListCtrls .... - my fault not checking properly in the 1st
place ....

Btw: I found that almost all (o.k.- all I found) validator examples out
there or in the book(s) always deal w/ TextCtrls and vlidators ...

···

Am 24.10.11 21:39, schrieb Robin Dunn:

On 10/24/11 12:34 PM, Tobias Weber wrote:

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 calcdata

       def 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 True

       def 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...

You could implement it and submit a patch.

It should only take a few lines of code and some testing. That sounds like a quick fix to me. If you don't want to modify the module in the wx.lib.mixins package you can just put your modified copy of that class in your application's source tree until your patch is included in a new release.

···

On 10/24/11 12:44 PM, Tobias Weber wrote:

Am 24.10.11 21:39, schrieb Robin Dunn:

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...

You could implement it and submit a patch.

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:

--
Robin Dunn
Software Craftsman

Am on it :slight_smile:

ThanX

···

Am 24.10.11 21:51, schrieb Robin Dunn:

On 10/24/11 12:44 PM, Tobias Weber wrote:

Am 24.10.11 21:39, schrieb Robin Dunn:

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...

You could implement it and submit a patch.

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:

It should only take a few lines of code and some testing. That sounds
like a quick fix to me. If you don't want to modify the module in the
wx.lib.mixins package you can just put your modified copy of that
class in your application's source tree until your patch is included
in a new release.

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

Or you could simply derive a new class from TextEditMixin that adds the functionality that you need in an overridden make_editor method.

···

On 10/24/11 12:51 PM, Robin Dunn wrote:

On 10/24/11 12:44 PM, Tobias Weber wrote:

Am 24.10.11 21:39, schrieb Robin Dunn:

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...

You could implement it and submit a patch.

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:

It should only take a few lines of code and some testing. That sounds
like a quick fix to me. If you don't want to modify the module in the
wx.lib.mixins package you can just put your modified copy of that class
in your application's source tree until your patch is included in a new
release.

--
Robin Dunn
Software Craftsman

I'm getting there ...

Is there somewhere an example of a general implementation of a validator
on a ListCtrl?

I cannot find any ....

ThanX

···

Am 24.10.11 21:54, schrieb Robin Dunn:

On 10/24/11 12:51 PM, Robin Dunn wrote:

On 10/24/11 12:44 PM, Tobias Weber wrote:

Am 24.10.11 21:39, schrieb Robin Dunn:

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...

You could implement it and submit a patch.

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:

It should only take a few lines of code and some testing. That sounds
like a quick fix to me. If you don't want to modify the module in the
wx.lib.mixins package you can just put your modified copy of that class
in your application's source tree until your patch is included in a new
release.

Or you could simply derive a new class from TextEditMixin that adds
the functionality that you need in an overridden make_editor method.

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

I have to put that aside for now- I now have a small patch that works
for me but now I see that I cannot call GetColumnText ....
I need sthg that works for now and will dedicate time later- it feels
like this Mixin needs some thorough doublechecking I cannot provide
right now...

Still, I will get back to it after I handed in what is due in a couple
of hours ....

···

Am 24.10.11 23:05, schrieb Tobias Weber:

I'm getting there ...

Is there somewhere an example of a general implementation of a validator
on a ListCtrl?

I cannot find any ....

ThanX

Am 24.10.11 21:54, schrieb Robin Dunn:

On 10/24/11 12:51 PM, Robin Dunn wrote:

On 10/24/11 12:44 PM, Tobias Weber wrote:

Am 24.10.11 21:39, schrieb Robin Dunn:

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...

You could implement it and submit a patch.

Will do- right now I need a quick fix since I need to show something
2morrow :slight_smile:

It should only take a few lines of code and some testing. That sounds
like a quick fix to me. If you don't want to modify the module in the
wx.lib.mixins package you can just put your modified copy of that class
in your application's source tree until your patch is included in a new
release.

Or you could simply derive a new class from TextEditMixin that adds
the functionality that you need in an overridden make_editor method.

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

Maybe I'm not understanding something but don't you want the validator to be used with the wx.TextCtrl that the TextEditMixin is creating for editing items, and not for the ListCtrl itself? IMO those would be two very different things.

···

On 10/24/11 2:05 PM, Tobias Weber wrote:

I'm getting there ...

Is there somewhere an example of a general implementation of a validator
on a ListCtrl?

I cannot find any ....

--
Robin Dunn
Software Craftsman

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line to a dict. So i need the validator to transfer data not when an editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I can simply read what was entered/ changed/ untouched w/ a validator ... am I not ending up w/ a list after The editor was closed? So simply speaking: what is The Way to do it (right)?

Thanks

···

Von meinem iTelefon gesendet

Am 25.10.2011 um 03:14 schrieb Robin Dunn <robin@alldunn.com>:

On 10/24/11 2:05 PM, Tobias Weber wrote:

I'm getting there ...

Is there somewhere an example of a general implementation of a validator
on a ListCtrl?

I cannot find any ....

Maybe I'm not understanding something but don't you want the validator to be used with the wx.TextCtrl that the TextEditMixin is creating for editing items, and not for the ListCtrl itself? IMO those would be two very different things.

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Tobias,

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line to a dict. So i need the validator to transfer data not when an editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I can simply read what was entered/ changed/ untouched w/ a validator ... am I not ending up w/ a list after The editor was closed? So simply speaking: what is The Way to do it (right)?

Is there a right/wrong way? I am not sure, it depends more on your use case.

I personally consider list controls containers which list items and I don't like/use them to edit items as I feel that it is more difficult to control what is happening and what and when one needs to save to the database after something is changed.

What triggers the database update in your case?
- Moving to another editor?
- Clicking a button?
- ?

I guess you could trigger the validate/db update on loss of focus of a cell - in other words use the "kill focus event" handler to call validation and db update for this one item.

Not sure that a "validator" would be that great for this approach, I use/like them for filling/validating/reading lots of controls on e.g. a dialog or frame or whatever when a user takes an action, i.e. click a button or select an item from a list etc.

If you let user change many items and he/she clicks a button to call list.validate and if that passes then call list.TransferFromWindow before you commit to the db. The validator you passed to the list control would have to know how to cycle through the list in its "Validate" and "TransferFromWindow" method.

Werner

···

On 10/25/2011 08:03 AM, Tobias Weber wrote:

Hi Tobias,

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line
to a dict. So i need the validator to transfer data not when an
editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I
can simply read what was entered/ changed/ untouched w/ a validator
... am I not ending up w/ a list after The editor was closed? So
simply speaking: what is The Way to do it (right)?

Is there a right/wrong way? I am not sure, it depends more on your
use case.

I personally consider list controls containers which list items and I
don't like/use them to edit items as I feel that it is more difficult
to control what is happening and what and when one needs to save to
the database after something is changed.

What triggers the database update in your case?
- Moving to another editor?
- Clicking a button?
- ?

I guess you could trigger the validate/db update on loss of focus of a
cell - in other words use the "kill focus event" handler to call
validation and db update for this one item.

Not sure that a "validator" would be that great for this approach, I
use/like them for filling/validating/reading lots of controls on e.g.
a dialog or frame or whatever when a user takes an action, i.e. click
a button or select an item from a list etc.

If you let user change many items and he/she clicks a button to call
list.validate and if that passes then call list.TransferFromWindow
before you commit to the db. The validator you passed to the list
control would have to know how to cycle through the list in its
"Validate" and "TransferFromWindow" method.

I am ok w/ a simple button for now to trigger a custom "read all
cells-event". The validator itself is an issue I have not really gotten
a grasp on yet-
I honestly do not understand why it is mentioned to be applicable to a
ListCtrl, etc ...Ctrls other than TextCtrls in a Dialog if it is that
hard to implement
and (therefore?) there are no examples of such a use.
I am trying to implement a custom funtion that loops over the cell
entries and reads its contents now.

So how would you do it? Keep track of the number and positions of the
cells that are filled from the db and then read in every single value in
a loop again on i.e. a button is pressed?
I am open to something that does the job- simply speaking- after having
bumped my head for almost 10 hours on that subject (again- I have
SWITCHED to wx.python so bare w/ me :slight_smile: )

And: Whats the use of an editable cell if there is no standard funtion
to mass-read back cell values?

Cheers,
TObi

···

Am 25.10.11 12:33, schrieb werner:

On 10/25/2011 08:03 AM, Tobias Weber wrote:

Werner

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

Hi Tobias,

Hi Tobias,

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line
to a dict. So i need the validator to transfer data not when an
editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I
can simply read what was entered/ changed/ untouched w/ a validator
... am I not ending up w/ a list after The editor was closed? So
simply speaking: what is The Way to do it (right)?

Is there a right/wrong way? I am not sure, it depends more on your
use case.

I personally consider list controls containers which list items and I
don't like/use them to edit items as I feel that it is more difficult
to control what is happening and what and when one needs to save to
the database after something is changed.

What triggers the database update in your case?
- Moving to another editor?
- Clicking a button?
- ?

I guess you could trigger the validate/db update on loss of focus of a
cell - in other words use the "kill focus event" handler to call
validation and db update for this one item.

Not sure that a "validator" would be that great for this approach, I
use/like them for filling/validating/reading lots of controls on e.g.
a dialog or frame or whatever when a user takes an action, i.e. click
a button or select an item from a list etc.

If you let user change many items and he/she clicks a button to call
list.validate and if that passes then call list.TransferFromWindow
before you commit to the db. The validator you passed to the list
control would have to know how to cycle through the list in its
"Validate" and "TransferFromWindow" method.

I am ok w/ a simple button for now to trigger a custom "read all
cells-event". The validator itself is an issue I have not really gotten
a grasp on yet-
I honestly do not understand why it is mentioned to be applicable to a
ListCtrl, etc ...Ctrls other than TextCtrls in a Dialog if it is that
hard to implement
and (therefore?) there are no examples of such a use.
I am trying to implement a custom funtion that loops over the cell
entries and reads its contents now.

So how would you do it? Keep track of the number and positions of the
cells that are filled from the db and then read in every single value in
a loop again on i.e. a button is pressed?

- that is one option, as long as you don't have tons of entries in you list.
- when I used listctrl to list items I used the "SetItemData" to set the db primary key per item. You could do this and when an item is changed save this and/or its index to only loop through the items which have changed when the button is pressed.

I am open to something that does the job- simply speaking- after having
bumped my head for almost 10 hours on that subject (again- I have
SWITCHED to wx.python so bare w/ me :slight_smile: )

BTW, take all my advice with a grain of salt as I am not a professional programmer.

Maybe not now, but at some point you might want to look at SQLalchemy and ObjectListView.

A couple of years ago I switched to SQLAlchemy and at about the same time found ObjectListView (http://objectlistview.sourceforge.net/python/cellEditing.html#cell-editing-label), so when I need a list I "just" pass a SQLAlchemy query object to an OLV list to show the items, but I don't allow edit in the list, so I don't know if the change to the model object the OLV does in the above can just be written to the db by calling SQLAlchemy's commit or if more work is done.

Werner

···

On 10/25/2011 12:46 PM, Tobias Weber wrote:

Am 25.10.11 12:33, schrieb werner:

On 10/25/2011 08:03 AM, Tobias Weber wrote:

Thank you- it looks concise, simple, straight-forward and claims that
cells are editable- i will give it a shot right away, especially since
its concept is much more what i am used to from other stuff...

I'll keep you updated

···

Am 25.10.11 13:05, schrieb werner:

Hi Tobias,

On 10/25/2011 12:46 PM, Tobias Weber wrote:

Am 25.10.11 12:33, schrieb werner:

Hi Tobias,

On 10/25/2011 08:03 AM, Tobias Weber wrote:

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line
to a dict. So i need the validator to transfer data not when an
editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I
can simply read what was entered/ changed/ untouched w/ a validator
... am I not ending up w/ a list after The editor was closed? So
simply speaking: what is The Way to do it (right)?

Is there a right/wrong way? I am not sure, it depends more on your
use case.

I personally consider list controls containers which list items and I
don't like/use them to edit items as I feel that it is more difficult
to control what is happening and what and when one needs to save to
the database after something is changed.

What triggers the database update in your case?
- Moving to another editor?
- Clicking a button?
- ?

I guess you could trigger the validate/db update on loss of focus of a
cell - in other words use the "kill focus event" handler to call
validation and db update for this one item.

Not sure that a "validator" would be that great for this approach, I
use/like them for filling/validating/reading lots of controls on e.g.
a dialog or frame or whatever when a user takes an action, i.e. click
a button or select an item from a list etc.

If you let user change many items and he/she clicks a button to call
list.validate and if that passes then call list.TransferFromWindow
before you commit to the db. The validator you passed to the list
control would have to know how to cycle through the list in its
"Validate" and "TransferFromWindow" method.

I am ok w/ a simple button for now to trigger a custom "read all
cells-event". The validator itself is an issue I have not really gotten
a grasp on yet-
I honestly do not understand why it is mentioned to be applicable to a
ListCtrl, etc ...Ctrls other than TextCtrls in a Dialog if it is that
hard to implement
and (therefore?) there are no examples of such a use.
I am trying to implement a custom funtion that loops over the cell
entries and reads its contents now.

So how would you do it? Keep track of the number and positions of the
cells that are filled from the db and then read in every single value in
a loop again on i.e. a button is pressed?

- that is one option, as long as you don't have tons of entries in you
list.
- when I used listctrl to list items I used the "SetItemData" to set
the db primary key per item. You could do this and when an item is
changed save this and/or its index to only loop through the items
which have changed when the button is pressed.

I am open to something that does the job- simply speaking- after having
bumped my head for almost 10 hours on that subject (again- I have
SWITCHED to wx.python so bare w/ me :slight_smile: )

BTW, take all my advice with a grain of salt as I am not a
professional programmer.

Maybe not now, but at some point you might want to look at SQLalchemy
and ObjectListView.

A couple of years ago I switched to SQLAlchemy and at about the same
time found ObjectListView
(http://objectlistview.sourceforge.net/python/cellEditing.html#cell-editing-label),
so when I need a list I "just" pass a SQLAlchemy query object to an
OLV list to show the items, but I don't allow edit in the list, so I
don't know if the change to the model object the OLV does in the above
can just be written to the db by calling SQLAlchemy's commit or if
more work is done.

Werner

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

Ooops:

aeh- where can I get ObjectListView for python/ wx.Python?

···

Am 25.10.11 13:05, schrieb werner:

Hi Tobias,

On 10/25/2011 12:46 PM, Tobias Weber wrote:

Am 25.10.11 12:33, schrieb werner:

Hi Tobias,

On 10/25/2011 08:03 AM, Tobias Weber wrote:

O.k. I am populating the list from a db with only the 1st.
cell empty for the user to enter a value. The plan was
To then use the validator to Transfer this and 2 more values per line
to a dict. So i need the validator to transfer data not when an
editor is initiated but to get the cell values from and to ...
I used to populate the cells w/ simple strings believing that later I
can simply read what was entered/ changed/ untouched w/ a validator
... am I not ending up w/ a list after The editor was closed? So
simply speaking: what is The Way to do it (right)?

Is there a right/wrong way? I am not sure, it depends more on your
use case.

I personally consider list controls containers which list items and I
don't like/use them to edit items as I feel that it is more difficult
to control what is happening and what and when one needs to save to
the database after something is changed.

What triggers the database update in your case?
- Moving to another editor?
- Clicking a button?
- ?

I guess you could trigger the validate/db update on loss of focus of a
cell - in other words use the "kill focus event" handler to call
validation and db update for this one item.

Not sure that a "validator" would be that great for this approach, I
use/like them for filling/validating/reading lots of controls on e.g.
a dialog or frame or whatever when a user takes an action, i.e. click
a button or select an item from a list etc.

If you let user change many items and he/she clicks a button to call
list.validate and if that passes then call list.TransferFromWindow
before you commit to the db. The validator you passed to the list
control would have to know how to cycle through the list in its
"Validate" and "TransferFromWindow" method.

I am ok w/ a simple button for now to trigger a custom "read all
cells-event". The validator itself is an issue I have not really gotten
a grasp on yet-
I honestly do not understand why it is mentioned to be applicable to a
ListCtrl, etc ...Ctrls other than TextCtrls in a Dialog if it is that
hard to implement
and (therefore?) there are no examples of such a use.
I am trying to implement a custom funtion that loops over the cell
entries and reads its contents now.

So how would you do it? Keep track of the number and positions of the
cells that are filled from the db and then read in every single value in
a loop again on i.e. a button is pressed?

- that is one option, as long as you don't have tons of entries in you
list.
- when I used listctrl to list items I used the "SetItemData" to set
the db primary key per item. You could do this and when an item is
changed save this and/or its index to only loop through the items
which have changed when the button is pressed.

I am open to something that does the job- simply speaking- after having
bumped my head for almost 10 hours on that subject (again- I have
SWITCHED to wx.python so bare w/ me :slight_smile: )

BTW, take all my advice with a grain of salt as I am not a
professional programmer.

Maybe not now, but at some point you might want to look at SQLalchemy
and ObjectListView.

A couple of years ago I switched to SQLAlchemy and at about the same
time found ObjectListView
(http://objectlistview.sourceforge.net/python/cellEditing.html#cell-editing-label),
so when I need a list I "just" pass a SQLAlchemy query object to an
OLV list to show the items, but I don't allow edit in the list, so I
don't know if the change to the model object the OLV does in the above
can just be written to the db by calling SQLAlchemy's commit or if
more work is done.

Werner

--
--------------------------------------------------
Tobias Weber
CEO

The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56

www.roglink.com

Gesch�ftsf�hrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

Werner

···

On 10/25/2011 01:43 PM, Tobias Weber wrote:

Ooops:

aeh- where can I get ObjectListView for python/ wx.Python?