setting extra data to a wx.textctrl

P

Pom

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!
 
K

kyosohma

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
 
P

Pom

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top