Use OrderedDict to keep items order from json

This commit is contained in:
Davide Andreoli 2015-02-01 16:12:21 +01:00
parent c737915efd
commit 4d41e26f9b
1 changed files with 7 additions and 3 deletions

View File

@ -27,6 +27,7 @@ TODO
* fix (in erigo) the label with markup
* properties that need to be fixed:
- visibility (will be fixed in eo)
* scrollable interface, widgets must be changed to always inherit from Scroller
* how to manage translations??
* what when we create the same widget more than one time ?
* Radio.group_add is not a property !!
@ -39,8 +40,9 @@ TODO
"""
import os
import importlib
import json
import importlib
from collections import OrderedDict
try:
basestring # py2
@ -93,10 +95,12 @@ class ErigoGui(object):
if json_file is not None:
self._print('\n### Generating gui from file: %s' % json_file)
self._data = json.load(open(json_file))
self._data = json.load(open(json_file),
object_pairs_hook=OrderedDict)
elif json_string is not None:
self._print('\n### Generating gui from string')
self._data = json.loads(json_string)
self._data = json.loads(json_string,
object_pairs_hook=OrderedDict)
else:
raise RuntimeError('One of "file" or "json_string" is mandatory')