Python-EFL: edje_external now works with py3
SVN revision: 83980
This commit is contained in:
parent
b58be93f12
commit
2b75edb785
11
INSTALL
11
INSTALL
|
@ -50,10 +50,11 @@
|
|||
|
||||
|
||||
|
||||
5. DEMOS and TESTS
|
||||
5. TESTS and EXAMPLES
|
||||
|
||||
You can run individual tests or use the 00_run_all_tests.py in each folder or
|
||||
even in the tests/ base dir to run all the tests at once.
|
||||
The tests/ folder contain all the unit tests available, you can run individual
|
||||
tests or use the 00_run_all_tests.py in each folder or even in the tests/ base
|
||||
dir to run all the tests at once.
|
||||
|
||||
The tests in elementary and emotion are not unittest and are meant to be
|
||||
run by the user as they usually require some sort of interaction.
|
||||
The examples/ folder instead contain scripts that must be run by the user
|
||||
as they need some sort of interaction.
|
||||
|
|
1
TODO
1
TODO
|
@ -32,7 +32,6 @@ TODO FOR PYTHON 3:
|
|||
|
||||
* ecore.Exe (use new buffer interface)
|
||||
* ecore.FdHandler (use new buffer interface)
|
||||
* edje external
|
||||
|
||||
|
||||
STUFF LEAVED OUT:
|
||||
|
|
|
@ -305,18 +305,37 @@ cdef class Edje(Object):
|
|||
edje_object_part_unswallow(self.obj, obj.obj)
|
||||
|
||||
def part_swallow_get(self, part):
|
||||
return object_from_instance(edje_object_part_swallow_get(self.obj,
|
||||
_cfruni(part)))
|
||||
return object_from_instance(edje_object_part_swallow_get(
|
||||
self.obj, _cfruni(part)))
|
||||
|
||||
def part_external_object_get(self, part):
|
||||
return object_from_instance(edje_object_part_external_object_get(self.obj,
|
||||
_cfruni(part)))
|
||||
return object_from_instance(edje_object_part_external_object_get(
|
||||
self.obj, _cfruni(part)))
|
||||
|
||||
def part_external_param_set(self, char *part, char *param, value):
|
||||
def part_external_param_set(self, part, param, value):
|
||||
cdef Edje_External_Param p
|
||||
cdef Edje_External_Param_Type t
|
||||
cdef const_char_ptr c_part
|
||||
cdef const_char_ptr c_param
|
||||
|
||||
p.name = param
|
||||
if isinstance(part, unicode):
|
||||
str1 = part.encode('UTF-8')
|
||||
c_part = str1
|
||||
elif isinstance(part, str):
|
||||
c_part = part
|
||||
else:
|
||||
raise TypeError("part must be str or unicode, found %s" %
|
||||
type(part).__name__)
|
||||
|
||||
if isinstance(param, unicode):
|
||||
str2 = param.encode('UTF-8')
|
||||
c_param = str2
|
||||
elif isinstance(param, str):
|
||||
c_param = param
|
||||
else:
|
||||
raise TypeError("param must be str or unicode, found %s" %
|
||||
type(param).__name__)
|
||||
|
||||
p.name = c_param
|
||||
if isinstance(value, bool): # bool is int, so keep it before!
|
||||
p.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL
|
||||
p.i = value
|
||||
|
@ -329,41 +348,54 @@ cdef class Edje(Object):
|
|||
elif isinstance(value, (str, unicode)):
|
||||
# may be STRING or CHOICE
|
||||
p.type = edje_object_part_external_param_type_get(
|
||||
self.obj, part, param)
|
||||
|
||||
self.obj, c_part, c_param)
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode("utf-8")
|
||||
value = value.encode("UTF-8")
|
||||
p.s = value
|
||||
else:
|
||||
raise TypeError("unsupported type %s" % type(value).__name__)
|
||||
return bool(edje_object_part_external_param_set(self.obj, part, &p))
|
||||
|
||||
def part_external_param_get(self, char *part, char *param):
|
||||
return bool(edje_object_part_external_param_set(self.obj, c_part, &p))
|
||||
|
||||
def part_external_param_get(self, part, param):
|
||||
cdef Edje_External_Param p
|
||||
cdef Edje_External_Param_Type t
|
||||
cdef const_char_ptr c_part
|
||||
cdef const_char_ptr c_param
|
||||
|
||||
t = edje_object_part_external_param_type_get(self.obj, part, param)
|
||||
if t == EDJE_EXTERNAL_PARAM_TYPE_MAX:
|
||||
if isinstance(part, unicode):
|
||||
str1 = part.encode('UTF-8')
|
||||
c_part = str1
|
||||
elif isinstance(part, str):
|
||||
c_part = part
|
||||
else:
|
||||
raise TypeError("part must be str or unicode, found %s" %
|
||||
type(part).__name__)
|
||||
|
||||
if isinstance(param, unicode):
|
||||
str2 = param.encode('UTF-8')
|
||||
c_param = str2
|
||||
elif isinstance(param, str):
|
||||
c_param = param
|
||||
else:
|
||||
raise TypeError("param must be str or unicode, found %s" %
|
||||
type(param).__name__)
|
||||
|
||||
p.name = c_param
|
||||
p.type = edje_object_part_external_param_type_get(self.obj, c_part, c_param)
|
||||
if p.type >= EDJE_EXTERNAL_PARAM_TYPE_MAX:
|
||||
return None
|
||||
|
||||
p.name = param
|
||||
p.type = t
|
||||
if not edje_object_part_external_param_get(self.obj, part, &p):
|
||||
if not edje_object_part_external_param_get(self.obj, c_part, &p):
|
||||
return None
|
||||
if t == EDJE_EXTERNAL_PARAM_TYPE_BOOL:
|
||||
if p.type == EDJE_EXTERNAL_PARAM_TYPE_BOOL:
|
||||
return bool(p.i)
|
||||
elif t == EDJE_EXTERNAL_PARAM_TYPE_INT:
|
||||
elif p.type == EDJE_EXTERNAL_PARAM_TYPE_INT:
|
||||
return p.i
|
||||
elif t == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
|
||||
elif p.type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
|
||||
return p.d
|
||||
elif t == EDJE_EXTERNAL_PARAM_TYPE_STRING:
|
||||
if p.s == NULL:
|
||||
return ""
|
||||
return p.s
|
||||
elif t == EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
|
||||
if p.s == NULL:
|
||||
return ""
|
||||
return p.s
|
||||
elif p.type == EDJE_EXTERNAL_PARAM_TYPE_STRING or \
|
||||
p.type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
|
||||
return _ctouni(p.s)
|
||||
|
||||
def part_box_append(self, part, Object obj):
|
||||
return bool(edje_object_part_box_append(self.obj, _cfruni(part), obj.obj))
|
||||
|
|
|
@ -26,9 +26,17 @@ class TestEdjeExternal(unittest.TestCase):
|
|||
elm_label = self.theme.part_external_object_get("ext_elm_label")
|
||||
self.assertIsInstance(elm_label, elementary.Label)
|
||||
|
||||
# check values setted in edc (from external)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_label", "label"), "This is an elm label")
|
||||
|
||||
# check values setted in edc (from object)
|
||||
self.assertEqual(elm_label.text, "This is an elm label")
|
||||
|
||||
# do params set
|
||||
self.theme.part_external_param_set("ext_elm_label", "label", "new text")
|
||||
|
||||
# recheck setted values
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_label", "label"), "new text")
|
||||
self.assertEqual(elm_label.text, "new text")
|
||||
|
||||
|
||||
|
@ -36,10 +44,21 @@ class TestEdjeExternal(unittest.TestCase):
|
|||
elm_slider = self.theme.part_external_object_get("ext_elm_slider")
|
||||
self.assertIsInstance(elm_slider, elementary.Slider)
|
||||
|
||||
# check values setted in edc
|
||||
# check values setted in edc (from external)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "label"), "external slider")
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "min"), -2)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "max"), 999)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "value"), 0.6)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "inverted"), True)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "horizontal"), True)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "span"), 45)
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "unit format"), "test %f")
|
||||
self.assertEqual(self.theme.part_external_param_get("ext_elm_slider", "indicator format"), "%f ind")
|
||||
|
||||
# check values setted in edc (from object)
|
||||
self.assertEqual(elm_slider.text, "external slider")
|
||||
self.assertEqual(elm_slider.min_max, (-1, 999))
|
||||
self.assertEqual(elm_slider.value_get(), 0.6)
|
||||
self.assertEqual(elm_slider.value, 0.6)
|
||||
self.assertEqual(elm_slider.inverted, True)
|
||||
self.assertEqual(elm_slider.horizontal, True)
|
||||
self.assertEqual(elm_slider.span_size, 45)
|
||||
|
|
|
@ -38,11 +38,11 @@ class SmartObjectTest(unittest.TestCase):
|
|||
self.assertEqual(self.obj.members, (self.obj.r1, self.obj.r2))
|
||||
|
||||
def testResize(self):
|
||||
print self.obj.geometry
|
||||
print self.obj.r1.geometry
|
||||
print(self.obj.geometry)
|
||||
print(self.obj.r1.geometry)
|
||||
self.obj.resize(100, 100)
|
||||
print self.obj.geometry
|
||||
print self.obj.r1.geometry
|
||||
print(self.obj.geometry)
|
||||
print(self.obj.r1.geometry)
|
||||
self.assertEqual(self.obj.r1.geometry, (0, 0, 50, 50))
|
||||
self.assertEqual(self.obj.r2.geometry, (50, 50, 50, 50))
|
||||
|
||||
|
|
Loading…
Reference in New Issue