I have a problem with predefined values and their order in 'value map' field. Wnen I tried this How to create predefined values in a field in PyQGIS? it works, but I'm not able to keep order (even when I use OrderedDict instead of dict). The second problem is how to insert also empty value.
val_map = OrderedDict()
for value,label in sorted(val['values'].items()):
val_map[label.decode("utf-8")] = label.decode("utf-8")
print(val_map)
vlayer.setEditorWidgetV2( index, 'ValueMap' )
vlayer.setEditorWidgetV2Config(index, val_map)
result: OrderedDict([(u'silnice I.t\u0159', u'silnice I.t\u0159'), (u'silnice II.t\u0159', u'silnice II.t\u0159'), (u'silnice III.t\u0159', u'silnice III.t\u0159'), (u'MK I.t\u0159', u'MK I.t\u0159'), (u'MK II.t\u0159', u'MK II.t\u0159'), (u'MK III.t\u0159', u'MK III.t\u0159'), (u'MK IV.t\u0159', u'MK IV.t\u0159'), (u'UK', u'UK')])
But you can see, that there is alphabetical order in value map