473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1685
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Logan | last post by:
I asked a similar question already in the wxPython mailing list, but did not get an answer up to now: 1.) When using a TextCtrl with styles (color etc.) in wxPython, is it then possible to get a...
6
by: Hako | last post by:
Hello All, I have a function to set readonly or editable of a textctrl. I'd like to make the textctrl initial set readonly and use other event funciton to set editable of the textctrl but it...
12
by: Simon Hibbs | last post by:
I have a simple form with some input values and some calculated values in TextCtrl widgets. What I would like to do is have the display update automaticaly when the user changes one of the input...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
10
by: abcd | last post by:
I have a TextCtrl which is set to be multi-line. I have a function say, updateText(msg), which takes some string and appends it to the text control... txtControl.AppendText(msg) ...
0
by: Erik | last post by:
Is it possible with wxPython to place images in a textctrl (or a styledtextctrl)? If you don't get what I mean, just think about emoticons in the MSN messenger chat window. So is it possible to...
3
by: bcwhite | last post by:
I'm running Python2.5 with wxPython v2.8.3.0 under WinXP and I cannot get the SetDefaultStyle method to work. I'm trying: self.output.SetDefaultStyle(wx.TextAttr(wx.RED))...
3
by: Alejandro | last post by:
Hi: I want to redirect stdout to a textctrl I have. From what I read in the wxpython documentation, I can use the wxLogTextCtrl class to do this. I am doing the following: class...
1
by: aeroumr | last post by:
In the following code, I have created a panel with a button and a textctrl object on it. I have also created a menubar that will create a new text file (i.e. textctrl object). My problem is that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.