[twill] Setting ListControls by Value
Titus Brown
titus at caltech.edu
Mon Nov 28 10:20:35 PST 2005
-> I needed to be able to set a list control by value.
-> So I added three lines to the set_form_control_value method in utils.py
-> as shown:
->
-> ----------------------------------------------------------
->
-> def set_form_control_value(control, val):
-> """
-> Helper function to deal with setting form values on lists etc.
-> """
-> if isinstance(control, ClientForm.ListControl):
-> > if val[0:2] == '__':
-> > control.set(1, val[2:], by_label=True )
-> > else:
-> control.set(1, val)
-> else:
-> control.value = val
->
-> ----------------------------------------------------------
->
-> Basically you need to prefix the value with __ (two underscores).
->
-> It works for me. The syntax may be somewhat and could be improved ;)
Hi, Suresh,
could you give me an example case where you need to do this?
lazily yours,
--titus
More information about the twill
mailing list