468,287 Members | 1,968 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

setting extra data to a wx.textctrl

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!
May 11 '07 #1
2 1548
On May 10, 10:51 pm, Pom <i.read....@group.invalidwrote:
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

May 11 '07 #2
Pom
ky******@gmail.com wrote:
On May 10, 10:51 pm, Pom <i.read....@group.invalidwrote:
>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!
May 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Logan | last post: by
12 posts views Thread by Simon Hibbs | last post: by
reply views Thread by Erik | last post: by
3 posts views Thread by bcwhite | last post: by
3 posts views Thread by Alejandro | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.