- #1
cpscdave
- 403
- 120
Maybe I am going about this the wrong way.
I'm trying to build a form to display & update information in a object.
The objects are stored in an array since I'll have 1-N of them.
What I've done now is created an array of dictonaries which hold the information about the form fields, it contains information such as: Label, control Type, and then a pointer to the get & set functions of the object field.
This works great if I define the array AFTER I know which index the object is in.
Is there a way I can do this before? Otherwise I'll have to have a similar array elsewhere to handle the actual updating of the object.Code is as follows:
basically I want to be able to remove theControllers[index] from the function pointer. Is this possible?
I'm trying to build a form to display & update information in a object.
The objects are stored in an array since I'll have 1-N of them.
What I've done now is created an array of dictonaries which hold the information about the form fields, it contains information such as: Label, control Type, and then a pointer to the get & set functions of the object field.
This works great if I define the array AFTER I know which index the object is in.
Is there a way I can do this before? Otherwise I'll have to have a similar array elsewhere to handle the actual updating of the object.Code is as follows:
Python:
objects = [{'name': 'theName', 'type' : 'textBox', 'lbl': 'Controller Name:','getFunction' : theControllers[index].getName, 'setFunction' : theControllers[index].setName},
{'name': 'theModbusID', 'type' : 'textBox', 'lbl': 'Modbus ID:', 'getFunction' : theControllers[index].getModbus, 'setFunction' : theControllers[index].setModbus},
{'name': 'theLocation', 'type' : 'textBox', 'lbl': 'Location:', 'getFunction' : theControllers[index].getLocation, 'setFunction' : theControllers[index].setLocation},
{'name': 'theChannel', 'type' : 'textBox', 'lbl': 'Com Channel', 'getFunction' : theControllers[index].getComChannel, 'setFunction' : theControllers[index].setComChannel},
{'name': 'theFirstCircuit','type' : 'textBox', 'lbl': 'First Circuit:', 'getFunction' : theControllers[index].getFirstCiruit, 'setFunction' : theControllers[index].setFirstCircuit},
{'name': 'theControlType', 'type' : 'dropDown', 'lbl': 'Controller Type:','getFunction' : theControllers[index].getFirstCiruit, 'setFunction' : theControllers[index].setFirstCircuit}]
for i in range(0, len(objects)):
#set up the controlls
basically I want to be able to remove theControllers[index] from the function pointer. Is this possible?