Python : Populating ComboControl from array/dict

Hi,
In a monitor script how would I take the contents of a nested 2x array and populate the first entry into a string list for display in a ComboControl and take the second entry in the array and populate it into a textControl. The idea being that as a user selects a particular entry in the ComboControl, the textcontrol updates with the corresponding array entry. Here’s some example code of what I am trying to achieve!

[code]import sys
from System.IO import *
from Deadline.Scripting import *

########################################################################

Globals

########################################################################
scriptDialog = None

########################################################################

Main Function

########################################################################
def main ( *args ):
global scriptDialog

dialogWidth = 450

Need Code[x] to be for each FIRST entry in the array as listed below under “##Source Code”

scriptDialog.AddComboControl( "Command", "ComboControl", "", (Code[x][1]), dialogWidth - 10, -1 )

Again, need Code[x] to be for each SECOND entry in the array as listed below…

scriptDialog.AddControl("CommandCode","TextControl",(Code[x][2]),dialogWidth - 10, -1)

########################################################################

Source

########################################################################
Code = (
( “A”, “A_command” ),
( “B”, “B_command” ),
( “C”, “C_command” ),
)[/code]

So far, the ComboControl wants to be fed a nice comma separated list for its entries, so I need to convert the array accordingly to suit this. Some help would be much appreciated!
Thanks,
Mike

One way I would go about doing this is to use a dictionary to create the key/value mappings. Then I would use that dictionary to build up an array of keys to pass to the combo control (assuming that this is possible). Then in the event that gets fired when the combo value changes, I would just grab the combo box value and use that as the key to get the corresponding text box value.

Cheers,

  • Ryan