By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,586 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

setting extra data to a wx.textctrl

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.