setting extra data to a wx.textctrl

Pom i.read.the at group.invalid
Fri May 11 17:23:11 EDT 2007


kyosohma at gmail.com wrote:
> On May 10, 10:51 pm, Pom <i.read.... at group.invalid> wrote:
>> Hello group!
>>
>> I have an application which uses a lot of mysql data fields, all the
>> same data type (floats).
>>
>> I created a panel which executes a "SELECT * FROM tablename" and makes
>> as much fields as needed, using de cursor.description as wx.statictext
>> and the cursors field contents copied into wx.textctrls.
>>
>> At creation time, I loop over all the fields in the record and create a
>> tuple which contains ((textctrl1, fieldname1), (textctrl2, fieldname2),
>> ...)  so I can keep track of which textctrl holds which piece of fielddata.
>>
>> The problem I'm having is:
>>
>> to know the fieldname in an text_event, I use event.GetEventObject(),
>> then perform an iteration over the tuple and when I find a match I use
>> the field name to update the mysqltable.
>> When having a few fields, this is ok.  But I have over 100 fields in 1
>> record and it really slows things down.
>>
>> Now my question is: should I use a python dictionary (with an object as
>> first lookup field) ?
>>
>> On windows, I've seen a "Tag" property in a textbox which was meant to
>> be used for this kind of stuff.  Maybe it's better to override the
>> wx.textctrl so I can add an extra string value?
>>
>> Anyone having the best solution for this ?
>>
>> thx!
> 
> Both of your ideas seem sound to me. You could also look into using
> statically assigned IDs that increment by one. Then you could just
> increment or decrement by one and look up the field by ID. Of course,
> that might get ugly and there are some IDs that are supposedly
> reserved. But it's an idea.
> 
> Also, I've heard that Dabo (http://dabodev.com/) is good for database
> work. You might look at that. To get the quickest and most on target
> answers to wxPython questions, I recommend the wxPython users-group
> mailing list: http://www.wxpython.org/maillist.php
> 
> Mike
> 


thx!



More information about the Python-list mailing list