Erigo: Implemented callbacks of -Modify- type
plus a fix for py3 and the test json updated
This commit is contained in:
parent
2d2bbb1977
commit
14a070012d
|
@ -32,6 +32,11 @@ TODO
|
||||||
import importlib
|
import importlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
try:
|
||||||
|
basestring # py2
|
||||||
|
except NameError:
|
||||||
|
basestring = str # py3
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
## NOTE/TODO: importlib is only implemented from python 2.7
|
## NOTE/TODO: importlib is only implemented from python 2.7
|
||||||
## From py-efl 1.14 we will need to rise py min version
|
## From py-efl 1.14 we will need to rise py min version
|
||||||
|
@ -109,7 +114,7 @@ def _widget_generate(self, data, name):
|
||||||
if 'Properties' in w_data:
|
if 'Properties' in w_data:
|
||||||
for eo_name, p_vals in w_data['Properties'].items():
|
for eo_name, p_vals in w_data['Properties'].items():
|
||||||
p_name = eo_name.split('.')[-1]
|
p_name = eo_name.split('.')[-1]
|
||||||
if p_name == 'visibility':
|
if p_name == 'visibility': # TODO implement this property in Evas.Object
|
||||||
if p_vals[0] is True:
|
if p_vals[0] is True:
|
||||||
w.show()
|
w.show()
|
||||||
elif p_name == 'constructor':
|
elif p_name == 'constructor':
|
||||||
|
@ -147,6 +152,24 @@ def _widget_generate(self, data, name):
|
||||||
child = _widget_generate(self, data, c_name)
|
child = _widget_generate(self, data, c_name)
|
||||||
w.pack(child, x, y, rspan, cspan)
|
w.pack(child, x, y, rspan, cspan)
|
||||||
|
|
||||||
|
|
||||||
|
# callbacks
|
||||||
|
if 'Callbacks' in w_data:
|
||||||
|
for cb_name, cb_data in w_data['Callbacks'].items():
|
||||||
|
if cb_data[0] == 'Modify':
|
||||||
|
target_name, target_prop, values = cb_data[1:4]
|
||||||
|
target_prop = target_prop.split('.')[-1]
|
||||||
|
self._print('callback %s (Modify) %s.%s => %s' % \
|
||||||
|
(cb_name, target_name, target_prop, values))
|
||||||
|
w._callback_add(str(cb_name), _property_modify_cb,
|
||||||
|
self, target_name, target_prop, values)
|
||||||
|
|
||||||
|
elif cb_data[0] == 'Create':
|
||||||
|
print("TODO")
|
||||||
|
|
||||||
|
elif cb_data[0] == 'Invoke':
|
||||||
|
print("TODO")
|
||||||
|
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,11 +190,19 @@ def _params_list_parse(mod, params):
|
||||||
return [ _param_parse(mod, p) for p in params ]
|
return [ _param_parse(mod, p) for p in params ]
|
||||||
|
|
||||||
def _param_parse(mod, p_value):
|
def _param_parse(mod, p_value):
|
||||||
if isinstance(p_value, (unicode, str)):
|
if isinstance(p_value, basestring):
|
||||||
if p_value.startswith('ELM_'):
|
if p_value.startswith('ELM_'):
|
||||||
enum_val = getattr(mod, p_value, None)
|
enum_val = getattr(mod, p_value, None)
|
||||||
if enum_val is not None:
|
if enum_val is not None:
|
||||||
return enum_val
|
return enum_val
|
||||||
return p_value
|
return p_value
|
||||||
|
|
||||||
|
def _property_modify_cb(obj, self, widget_name, prop_name, values):
|
||||||
|
w = self._widgets[widget_name]
|
||||||
|
if prop_name == 'visibility': # TODO implement this property in Evas.Object
|
||||||
|
w.show() if values[0] is True else w.hide()
|
||||||
|
else:
|
||||||
|
if prop_name == 'file': # ARGHHHHHHHHHHH TODO FIXME
|
||||||
|
values = (values[0])
|
||||||
|
setattr(w, prop_name, values[0] if len(values) == 1 else values)
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
{
|
{
|
||||||
"elm_button2":[0, 0, 1, 1],
|
"elm_button2":[0, 0, 1, 1],
|
||||||
"elm_button3":[1, 1, 1, 1],
|
"elm_button3":[1, 1, 1, 1],
|
||||||
"elm_image1":[1, 0, 1, 1]
|
"elm_button4":[0, 1, 1, 1]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"elm_button2":
|
"elm_button2":
|
||||||
|
@ -167,9 +167,9 @@
|
||||||
"Properties":
|
"Properties":
|
||||||
{
|
{
|
||||||
"Evas.Object.visibility":[true],
|
"Evas.Object.visibility":[true],
|
||||||
"Elm_Widget.part_text":[null, "elm_button2"],
|
|
||||||
"Evas.Object.size_hint_weight":[1, 1],
|
"Evas.Object.size_hint_weight":[1, 1],
|
||||||
"Evas.Object.color":[0, 255, 0, 255]
|
"Evas.Object.color":[0, 255, 0, 255],
|
||||||
|
"Elm_Widget.part_text":[null, "hide btn1"]
|
||||||
},
|
},
|
||||||
"Callbacks":
|
"Callbacks":
|
||||||
{
|
{
|
||||||
|
@ -186,32 +186,15 @@
|
||||||
"Properties":
|
"Properties":
|
||||||
{
|
{
|
||||||
"Evas.Object.visibility":[true],
|
"Evas.Object.visibility":[true],
|
||||||
"Elm_Widget.part_text":[null, "elm_button3"],
|
|
||||||
"Evas.Object.size_hint_weight":[1, 1],
|
"Evas.Object.size_hint_weight":[1, 1],
|
||||||
"Evas.Object.color":[255, 255, 0, 255]
|
"Evas.Object.color":[255, 255, 0, 255],
|
||||||
|
"Elm_Widget.part_text":[null, "show btn1"]
|
||||||
},
|
},
|
||||||
"Callbacks":
|
"Callbacks":
|
||||||
{
|
{
|
||||||
"clicked":["Modify", "elm_button1", "Evas.Object.visibility", [true]]
|
"clicked":["Modify", "elm_button1", "Evas.Object.visibility", [true]]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"elm_image1":
|
|
||||||
{
|
|
||||||
"Desc":
|
|
||||||
{
|
|
||||||
"parent":"elm_table1",
|
|
||||||
"class":"Elm_Image"
|
|
||||||
},
|
|
||||||
"Properties":
|
|
||||||
{
|
|
||||||
"Elm_Widget.part_text":[null, "elm_image1"],
|
|
||||||
"Evas.Object.size_hint_weight":[1, 1],
|
|
||||||
"Evas.Object.visibility":[true],
|
|
||||||
"Efl.File.file":["logo", null],
|
|
||||||
"Evas.Object.size":[40, 40],
|
|
||||||
"Evas.Object.size_hint_align":[-1, -1]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"elm_label1":
|
"elm_label1":
|
||||||
{
|
{
|
||||||
"Desc":
|
"Desc":
|
||||||
|
@ -226,6 +209,24 @@
|
||||||
"Elm_Widget.part_text":[null, "Label"],
|
"Elm_Widget.part_text":[null, "Label"],
|
||||||
"Evas.Object.size_hint_weight":[1, 0]
|
"Evas.Object.size_hint_weight":[1, 0]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"elm_button4":
|
||||||
|
{
|
||||||
|
"Desc":
|
||||||
|
{
|
||||||
|
"parent":"elm_table1",
|
||||||
|
"class":"Elm_Button"
|
||||||
|
},
|
||||||
|
"Properties":
|
||||||
|
{
|
||||||
|
"Evas.Object.size_hint_weight":[1, 1],
|
||||||
|
"Evas.Object.visibility":[true],
|
||||||
|
"Elm_Widget.part_text":[null, "modify btn1 text"]
|
||||||
|
},
|
||||||
|
"Callbacks":
|
||||||
|
{
|
||||||
|
"clicked":["Modify", "elm_button1", "Elm_Widget.part_text", [null, "Halo !"]]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue