Compare commits

...

19 Commits

Author SHA1 Message Date
Davide Andreoli e8749538ce Do not fail when no start_points are given 2015-02-03 19:58:49 +01:00
Davide Andreoli f05be9a21c Added support for Ctxpopup, Dayselector and Diskselector 2015-02-02 21:02:33 +01:00
Davide Andreoli 0a0991cdc8 Add support and test for Frame and Separator 2015-02-02 20:33:45 +01:00
Davide Andreoli f4445f05e7 Implement erigo json V3
NOTE: this is only compatible with erigo develop branch
2015-02-02 20:18:08 +01:00
Davide Andreoli 57481ac5fb Added a method called on each public widget creation
We can now populate the genlist when needed
2015-02-01 16:58:48 +01:00
Davide Andreoli 4d41e26f9b Use OrderedDict to keep items order from json 2015-02-01 16:12:21 +01:00
Davide Andreoli c737915efd Added support for Flip, Genlist, Gengrid and Toolbar 2015-02-01 16:08:20 +01:00
Davide Andreoli 3c76ede01e support enums from evas 2015-02-01 13:13:08 +01:00
Davide Andreoli 2e7ae199ad Added support for more erigo widgets 2015-01-31 16:29:33 +01:00
Davide Andreoli 6015567953 The file property seems ok now, will see... 2015-01-24 20:31:59 +01:00
Davide Andreoli 31320ca2e8 Workaround the visibility name in a simpler way 2015-01-24 20:12:50 +01:00
Davide Andreoli 6422f5a149 EvasObject: added the Eo position property
and deprecate the legacy name: pos
2015-01-24 20:04:31 +01:00
Davide Andreoli e091fc6064 Smaller tux image for the test 2015-01-24 18:52:36 +01:00
Davide Andreoli ce1101e317 Implemented resource management 2015-01-24 18:48:29 +01:00
Davide Andreoli 64c58021ea Implemented -Create- callback type 2015-01-24 13:03:44 +01:00
Davide Andreoli 8fecc5f55b Keep the json data around
Will be needed for the next commit
2015-01-24 13:00:31 +01:00
Davide Andreoli ae2dec22da Implemented Invoke type callbacks 2015-01-24 10:51:14 +01:00
Davide Andreoli 14a070012d Erigo: Implemented callbacks of -Modify- type
plus a fix for py3 and the test json updated
2015-01-22 23:22:32 +01:00
Davide Andreoli 2d2bbb1977 Initial work on erigo support in pyefl.
This will be developed in a separate branch and it will be ready for the 1.14 release.

The generator implemented here is on-the-fly, it does not generate the python code,
but actually generate the real interface from the json file on runtime.

The work is really at a good point yet, just need to fix/implement some
little more.

Test included
2015-01-22 20:43:51 +01:00
8 changed files with 1413 additions and 1 deletions

View File

@ -396,6 +396,22 @@ cdef class Object(evasObject):
if type(self) is Object:
raise TypeError("Must not instantiate Object, but subclasses")
property part_text:
"""Sets the text of a specific part of this object.
:type: (part_name, text_to_set)
.. versionadded:: 1.14
"""
def __set__(self, value):
part, text = value
if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
elm_object_part_text_set(self.obj,
<const char *>part if part is not None else NULL,
<const char *>text if text is not None else NULL)
def part_text_set(self, part, text):
"""Sets the text of a given part of this object.

View File

@ -17,6 +17,7 @@
from cpython cimport Py_INCREF, Py_DECREF
from efl.utils.conversions cimport eina_list_objects_to_python_list
from efl.utils.deprecated cimport DEPRECATED
cdef int _object_free_wrapper_resources(Object obj) except 0:
@ -406,11 +407,13 @@ cdef class Object(Eo):
"""
evas_object_resize(self.obj, w, h)
property pos:
property position:
"""Object's position on the X and Y coordinates.
:type: (int **x**, int **y**)
.. versionadded:: 1.14
"""
def __get__(self): # replicated to avoid performance hit
cdef int x, y
@ -422,10 +425,38 @@ cdef class Object(Eo):
x, y = spec
evas_object_move(self.obj, x, y)
def position_get(self):
cdef int x, y
evas_object_geometry_get(self.obj, &x, &y, NULL, NULL)
return (x, y)
def position_set(self, int x, int y):
evas_object_move(self.obj, x, y)
property pos:
"""Object's position on the X and Y coordinates.
:type: (int **x**, int **y**)
.. deprecated:: 1.14
Use the position property instead
"""
def __get__(self): # replicated to avoid performance hit
cdef int x, y
evas_object_geometry_get(self.obj, &x, &y, NULL, NULL)
return (x, y)
def __set__(self, spec):
cdef int x, y
x, y = spec
evas_object_move(self.obj, x, y)
@DEPRECATED("1.14", "Use position_get() instead.")
def pos_get(self):
cdef int x, y
evas_object_geometry_get(self.obj, &x, &y, NULL, NULL)
return (x, y)
@DEPRECATED("1.14", "Use position_set() instead.")
def pos_set(self, int x, int y):
evas_object_move(self.obj, x, y)

303
efl/utils/erigo.py Normal file
View File

@ -0,0 +1,303 @@
# Copyright (C) 2007-2015 various contributors (see AUTHORS)
#
# This file is part of Python-EFL.
#
# Python-EFL is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# Python-EFL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
"""
TODO
====
* mainmenu ??
* test more widget items
* add all the supported widget to KLASSES
* documentation for this module
* 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 accept an obj, not a string !!!
* Widget that seems not usable in erigo itsef:
- Icon: how to set a standard icon?
- ActionSlider: how to configure it?
"""
import os
import json
import importlib
from collections import OrderedDict
try:
basestring # py2
except NameError:
basestring = str # py3
###################################################################
## NOTE/TODO: importlib is only implemented from python 2.7
## From py-efl 1.14 we will need to rise py min version
###################################################################
JSON_Version = 3
KLASSES = {
'Elm_Actionslider': ('efl.elementary.actionslider', 'Actionslider'),
'Elm_Bg': ('efl.elementary.background', 'Background'),
'Elm_Box': ('efl.elementary.box', 'Box'),
'Elm_Button': ('efl.elementary.button', 'Button'),
'Elm_Clock': ('efl.elementary.clock', 'Clock'),
'Elm_Check': ('efl.elementary.check', 'Check'),
'Elm_Ctxpopup': ('efl.elementary.ctxpopup', 'Ctxpopup'),
'Elm_Dayselector': ('efl.elementary.dayselector', 'Dayselector'),
'Elm_Diskselector': ('efl.elementary.diskselector', 'Diskselector'),
'Elm_Entry': ('efl.elementary.entry', 'Entry'),
'Elm_Flip': ('efl.elementary.flip', 'Flip'),
'Elm_Frame': ('efl.elementary.frame', 'Frame'),
'Elm_Genlist': ('efl.elementary.genlist', 'Genlist'),
'Elm_Gengrid': ('efl.elementary.gengrid', 'Gengrid'),
'Elm_Icon': ('efl.elementary.icon', 'Icon'),
'Elm_Image': ('efl.elementary.image', 'Image'),
'Elm_Label': ('efl.elementary.label', 'Label'),
'Elm_Layout': ('efl.elementary.layout', 'Layout'),
'Elm_Menu': ('efl.elementary.menu', 'Menu'),
'Elm_Radio': ('efl.elementary.radio', 'Radio'),
'Elm_Separator': ('efl.elementary.separator', 'Separator'),
'Elm_Table': ('efl.elementary.table', 'Table'),
'Elm_Toolbar': ('efl.elementary.toolbar', 'Toolbar'),
'Elm_Win': ('efl.elementary.window', 'Window'),
}
class ErigoGui(object):
""" TODO: Class doc """
def __init__ (self, json_file=None, json_string=None, resources_path=None,
verbose=False):
self._verbose = verbose
self._widgets = {} # key: widget_name data: widget_instance
self._data = None # parsed json data
if resources_path:
self._res_path = resources_path
elif json_file:
self._res_path = os.path.dirname(json_file)
else:
self._res_path = os.getcwd() # :/
if json_file is not None:
self._print('\n### Generating gui from file: %s' % 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,
object_pairs_hook=OrderedDict)
else:
raise RuntimeError('One of "file" or "json_string" is mandatory')
if int(self._data['JSON_Version']) != JSON_Version:
raise RuntimeError('Wrong json version. Found: %s, wanted: %s' % \
(self._data['JSON_Version'], JSON_Version))
for w_name in self._data['Settings'].get('start_points', []):
_widget_generate(self, w_name)
def widget_generated(self, name, widget):
""" User can redefine this method to be informed when a public widget
is created. """
self._print('Widget generated: %s' % widget.__class__)
def _print(self, msg):
if self._verbose:
print(msg)
def _resource_find(self, value):
name, group = value
if name in self._data['Resources']['Images']:
fname = os.path.join(self._res_path,
self._data['Resources']['Images'][name])
return (fname, group)
return value
def _widget_generate(self, name, parent_name=None):
self._print('\n### Generating widget: %s' % name)
# get the widget class object from the correct module
w_data = self._data['Widgets'][name]
eo_klass_name = w_data['Desc']['class']
module_name, klass_name = KLASSES[eo_klass_name]
mod = importlib.import_module(module_name)
klass = getattr(mod, klass_name)
# class constructor
if 'Constructors' in w_data:
# Custom (TODO support multiple constructors)
params = w_data['Constructors'][eo_klass_name + '.constructor']
params = _params_list_parse(mod, params)
w = klass(*params, parent=self._widgets.get(parent_name))
else:
# Standard
parent = self._widgets[parent_name or w_data['Desc']['parent']]
w = klass(parent)
self._widgets[name] = w
# apply widget properties
if 'Properties' in w_data:
for eo_name, p_vals in w_data['Properties'].items():
p_name = eo_name.split('.')[-1]
if p_name == 'visibility': # TODO remove this hack when Eo will be fixed
p_name = 'visible'
if p_name != 'constructor':
self._print('property %s => %s' % (p_name, p_vals))
p_vals = _params_list_parse(mod, p_vals)
if p_name == 'file':
p_vals = _resource_find(self, p_vals)
if len(p_vals) == 1:
setattr(w, p_name, p_vals[0])
else:
setattr(w, p_name, p_vals)
# call widget methods
if 'Methods' in w_data:
for eo_name, params in w_data['Methods'].items():
meth_name = eo_name.split('.')[-1]
params = _params_list_parse(mod, params)
self._print('method %s %s' % (meth_name, params))
if meth_name == 'group_add': # ARGH !!!!!!
params = [ self._widgets[params[0]] ] # resolv widget by name
getattr(w, meth_name)(*params)
# generate widget items
if 'Items' in w_data:
for item_name, item_data in w_data['Items'].items():
_item_generate(self, w, None, item_name, item_data)
# callbacks
if 'Callbacks' in w_data:
for event_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('event %s (Modify) %s.%s => %s' % \
(event_name, target_name, target_prop, values))
w._callback_add(str(event_name), _property_modify_cb,
self, target_name, target_prop, values)
elif cb_data[0] == 'Invoke':
cb_alias = cb_data[1]
cb_name = self._data['Resources']['Eo_Callbacks'][cb_alias]
self._print('event %s (Invoke) %s => %s' % \
(event_name, cb_alias, cb_name))
w._callback_add(str(event_name), getattr(self, cb_name))
elif cb_data[0] == 'Create':
w_name, w_parent_name = cb_data[1:3]
self._print('event %s (Create) %s' % (event_name, w_name))
w._callback_add(str(event_name), _widget_create_cb,
self, w_name, w_parent_name)
# make the widget public if requested, and call the widget_generated method
if w_data['Desc'].get('public', False) is True:
self._print('Installing name: %s' % name)
setattr(self, name, w)
self.widget_generated(name, w)
# generate (and pack) children widgets
if eo_klass_name == 'Elm_Win':
for c_name in w_data.get('Contains', []):
child = _widget_generate(self, c_name)
w.resize_object_add(child)
elif eo_klass_name == 'Elm_Box':
for c_name in w_data.get('Contains', []):
child = _widget_generate(self, c_name)
w.pack_end(child)
elif eo_klass_name == 'Elm_Table':
for c_name, (x, y, cspan, rspan) in w_data.get('Contains', {}).items():
child = _widget_generate(self, c_name)
w.pack(child, x, y, cspan, rspan)
else:
for c_name, (swallow,) in w_data.get('Contains', {}).items():
child = _widget_generate(self, c_name)
w.part_content_set(swallow, child)
return w
def _item_generate(self, parent_widget, parent_item, item_name, item_data):
self._print("Generating ITEM: %s" % item_name)
if parent_widget.__class__.__name__ == 'Toolbar':
it = parent_widget.item_append(item_data['icon'], item_data['label'])
elif parent_widget.__class__.__name__ == 'Menu':
it = parent_widget.item_add(parent_item, item_data['label'],
item_data['icon'])
elif parent_widget.__class__.__name__ == 'Diskselector':
it = parent_widget.item_append(item_data['label'], item_data['icon'])
elif parent_widget.__class__.__name__ == 'Ctxpopup':
it = parent_widget.item_append(item_data['label'], item_data['icon'])
if 'Items' in item_data:
for item_name, item_data in item_data['Items'].items():
_item_generate(self, parent_widget, it, item_name, item_data)
def _params_list_parse(mod, params):
return [ _param_parse(mod, p) for p in params ]
def _param_parse(mod, p_value):
if isinstance(p_value, basestring):
enum_val = None
if p_value.startswith('ELM_'):
enum_val = getattr(mod, p_value, None)
elif p_value.startswith('EVAS_'):
from efl import evas
enum_val = getattr(evas, p_value, None)
if enum_val is not None:
return enum_val
return p_value
def _property_modify_cb(obj, self, widget_name, prop_name, values):
w = self._widgets[widget_name]
if prop_name == 'visibility': # TODO remove this hack when Eo will be fixed
prop_name = 'visible'
elif prop_name == 'file':
values = _resource_find(self, values)
setattr(w, prop_name, values[0] if len(values) == 1 else values)
def _widget_create_cb(obj, self, widget_name, parent_name):
_widget_generate(self, widget_name, parent_name)

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,988 @@
{
"JSON_Version":"3",
"Settings":
{
"project":"pyefl_erigo_test",
"start_points":["elm_win1"]
},
"Resources":
{
"Images":
{
"tux":"images/tux.png",
"pyefl_logo":"images/logo.png"
},
"Eo_Callbacks":
{
"btn5_clicked_cb_alias":"btn5_clicked_cb",
"btn8_clicked_cb_alias":"btn8_clicked_cb",
"win2_btn_clicked_cb_alias":"win2_btn_clicked_cb",
"win2_radio_changed_alias":"win2_radio_changed_cb"
}
},
"Widgets":
{
"elm_win1":
{
"Desc":
{
"parent":null,
"class":"Elm_Win",
"public":true
},
"Constructors":
{
"Elm_Win.constructor":[null, "ELM_WIN_BASIC"]
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Win.autodel":[true],
"Elm_Win.title":["Win1 Title"],
"Evas.Object.size":[381, 480]
},
"Contains":["elm_bg1", "elm_box1"]
},
"elm_win1_main_menu":
{
"Desc":
{
"parent":"elm_win1",
"class":"Elm_Menu",
"public":true
},
"Items":
{
"elm_win1_main_menu_it0":
{
"type":"regular",
"icon":"stop",
"label":"Button",
"callback":null,
"Items":
{
"elm_win1_main_menu_it2":
{
"type":"regular",
"icon":"fileopen",
"label":"Show",
"callback":null
},
"elm_win1_main_menu_it3":
{
"type":"regular",
"icon":"list-add",
"label":"Hide",
"callback":null
}
}
},
"elm_win1_main_menu_it1":
{
"type":"regular",
"icon":"list-add",
"label":"Table",
"callback":null,
"Items":
{
"elm_win1_main_menu_it4":
{
"type":"regular",
"icon":"search",
"label":"Show",
"callback":null
},
"elm_win1_main_menu_it5":
{
"type":"regular",
"icon":"fileopen",
"label":"Hide",
"callback":null
}
}
}
}
},
"elm_bg1":
{
"Desc":
{
"parent":"elm_win1",
"class":"Elm_Bg"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "elm_bg1"],
"Evas.Object.size_hint_weight":[1, 1]
}
},
"elm_box1":
{
"Desc":
{
"parent":"elm_win1",
"class":"Elm_Box"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "elm_box1"],
"Evas.Object.size_hint_weight":[1, 1]
},
"Contains":["elm_label1", "elm_button1", "elm_table1"]
},
"elm_button1":
{
"Desc":
{
"parent":"elm_box1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "elm_button1"],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.size_hint_align":[-1, -1]
}
},
"elm_table1":
{
"Desc":
{
"parent":"elm_box1",
"class":"Elm_Table"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "elm_table1"],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.size_hint_align":[-1, -1]
},
"Contains":
{
"elm_button2":[0, 0, 1, 1],
"elm_button3":[1, 0, 1, 1],
"elm_button4":[0, 1, 1, 1],
"elm_button5":[1, 1, 1, 1],
"elm_button6":[0, 2, 1, 1],
"elm_button8":[1, 2, 1, 1],
"elm_button9":[0, 4, 2, 1],
"elm_image1":[0, 6, 1, 2],
"elm_button10":[1, 6, 1, 1],
"elm_button11":[1, 7, 1, 1],
"elm_button12":[0, 5, 2, 1]
}
},
"elm_button2":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.color":[0, 255, 0, 255],
"Elm_Widget.part_text":[null, "hide btn1"]
},
"Callbacks":
{
"clicked":["Modify", "elm_button1", "Evas.Object.visibility", [false]]
}
},
"elm_button3":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.color":[255, 255, 0, 255],
"Elm_Widget.part_text":[null, "show btn1"]
},
"Callbacks":
{
"clicked":["Modify", "elm_button1", "Evas.Object.visibility", [true]]
}
},
"elm_label1":
{
"Desc":
{
"parent":"elm_box1",
"class":"Elm_Label",
"public":true
},
"Properties":
{
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Label"],
"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 !"]]
}
},
"elm_button5":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[73, 30],
"Elm_Widget.part_text":[null, "user cb"]
},
"Callbacks":
{
"clicked":["Invoke", "btn5_clicked_cb_alias", null]
}
},
"elm_button6":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Create another win"]
},
"Callbacks":
{
"clicked":["Create", "elm_win2", null]
}
},
"elm_win2":
{
"Desc":
{
"parent":null,
"class":"Elm_Win",
"public":true
},
"Constructors":
{
"Elm_Win.constructor":[null, "ELM_WIN_BASIC"]
},
"Properties":
{
"Elm_Win.title":["elm_win2"],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Win.autodel":[true],
"Evas.Object.size":[250, 100],
"Evas.Object.size_hint_min":[250, 316]
},
"Contains":["elm_bg2", "elm_box2"]
},
"elm_win2_main_menu":
{
"Desc":
{
"parent":"elm_win2",
"class":"Elm_Menu"
}
},
"elm_bg2":
{
"Desc":
{
"parent":"elm_win2",
"class":"Elm_Bg"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, -1]
}
},
"elm_box2":
{
"Desc":
{
"parent":"elm_win2",
"class":"Elm_Box"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, -1]
},
"Contains":["elm_frame1", "elm_button7", "elm_separator1", "elm_check1", "elm_check2", "elm_separator2", "elm_radio1", "elm_radio2", "elm_radio3", "elm_separator3", "elm_actionslider1", "elm_clock1", "elm_dayselector1", "elm_diskselector1", "elm_entry1"]
},
"elm_label2":
{
"Desc":
{
"parent":"elm_frame1",
"class":"Elm_Label"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[60, 30],
"Elm_Widget.part_text":[null, "This is another main window"]
}
},
"elm_button7":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Invoke user cb"]
},
"Callbacks":
{
"clicked":["Invoke", "win2_btn_clicked_cb_alias", null]
}
},
"elm_button8":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Delete the other win"]
},
"Callbacks":
{
"clicked":["Invoke", "btn8_clicked_cb_alias", null]
}
},
"elm_button9":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0.50],
"Elm_Widget.part_text":[null, "Create a dialog win"]
},
"Callbacks":
{
"clicked":["Create", "elm_win3", "elm_win1"]
}
},
"elm_win3":
{
"Desc":
{
"parent":null,
"class":"Elm_Win"
},
"Constructors":
{
"Elm_Win.constructor":["dia-win", "ELM_WIN_DIALOG_BASIC"]
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[150, 100],
"Elm_Win.title":["A dialog win"],
"Elm_Win.autodel":[true]
},
"Contains":["elm_bg3", "elm_label3"]
},
"elm_win3_main_menu":
{
"Desc":
{
"parent":"elm_win3",
"class":"Elm_Menu"
}
},
"elm_bg3":
{
"Desc":
{
"parent":"elm_win3",
"class":"Elm_Bg"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true]
}
},
"elm_label3":
{
"Desc":
{
"parent":"elm_win3",
"class":"Elm_Label"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[60, 30],
"Elm_Widget.part_text":[null, "I'm a dialog window &lt;br&gt; I should move with my parent"]
}
},
"elm_image1":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Image"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Efl.File.file":["tux", null],
"Evas.Object.size_hint_align":[-1, -1],
"Evas.Object.size":[100, 100],
"Evas.Object.size_hint_min":[100, 100]
}
},
"elm_button10":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[73, 30],
"Elm_Widget.part_text":[null, "&lt;- tux"]
},
"Callbacks":
{
"clicked":["Modify", "elm_image1", "Efl.File.file", ["tux", null]]
}
},
"elm_button11":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[73, 30],
"Elm_Widget.part_text":[null, "&lt;- pyefl"],
"Evas.Object.size_hint_aspect":["EVAS_ASPECT_CONTROL_BOTH", 1, 1]
},
"Callbacks":
{
"clicked":["Modify", "elm_image1", "Efl.File.file", ["pyefl_logo", null]]
}
},
"elm_check1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Check"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Check One"]
},
"Callbacks":
{
"changed":["Modify", "elm_check2", "Elm_Check.state", [true]]
}
},
"elm_check2":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Check"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Check Two"]
}
},
"elm_radio1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Radio"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Radio One"],
"Elm_Radio.state_value":[1]
},
"Callbacks":
{
"changed":["Invoke", "win2_radio_changed_alias", null]
}
},
"elm_radio2":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Radio"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Radio Two"],
"Elm_Radio.state_value":[2]
},
"Methods":
{
"Elm_Radio.group_add":["elm_radio1"]
},
"Callbacks":
{
"changed":["Invoke", "win2_radio_changed_alias", null]
}
},
"elm_radio3":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Radio"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "Radio Three"],
"Elm_Radio.state_value":[3]
},
"Methods":
{
"Elm_Radio.group_add":["elm_radio1"]
},
"Callbacks":
{
"changed":["Invoke", "win2_radio_changed_alias", null]
}
},
"elm_actionslider1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Actionslider"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Widget.part_text":[null, "slide"],
"Evas.Object.size_hint_align":[-1, 0.50]
}
},
"elm_clock1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Clock"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[40, 40]
}
},
"elm_entry1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Entry"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0.50],
"Elm_Entry.single_line":[true],
"Elm_Entry.scrollable":[true],
"Elm_Widget.part_text":["guide", "Editable entry"]
}
},
"elm_button12":
{
"Desc":
{
"parent":"elm_table1",
"class":"Elm_Button"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0.50],
"Elm_Widget.part_text":[null, "Test more widgets..."]
},
"Callbacks":
{
"clicked":["Create", "elm_win4", null]
}
},
"elm_win4":
{
"Desc":
{
"parent":null,
"class":"Elm_Win"
},
"Constructors":
{
"Elm_Win.constructor":[null, "ELM_WIN_BASIC"]
},
"Properties":
{
"Elm_Win.title":["elm_win4"],
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Win.autodel":[true],
"Evas.Object.size":[245, 336]
},
"Contains":["elm_bg4", "elm_box3"]
},
"elm_win4_main_menu":
{
"Desc":
{
"parent":"elm_win4",
"class":"Elm_Menu"
}
},
"elm_box3":
{
"Desc":
{
"parent":"elm_win4",
"class":"Elm_Box"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, -1],
"Evas.Object.position":[97, 42]
},
"Contains":["elm_toolbar1", "elm_flip1"]
},
"elm_toolbar1":
{
"Desc":
{
"parent":"elm_box3",
"class":"Elm_Toolbar"
},
"Properties":
{
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0],
"Elm_Toolbar.shrink_mode":["ELM_TOOLBAR_SHRINK_MENU"],
"Evas.Object.size_hint_weight":[1, 0]
},
"Callbacks":
{
"selected":["Modify", "elm_flip1", "Elm_Flip.go", ["ELM_FLIP_CUBE_LEFT"]]
},
"Items":
{
"elm_toolbar1_it0":
{
"type":"regular",
"icon":"home",
"label":"Genlist",
"callback":null
},
"elm_toolbar1_it1":
{
"type":"regular",
"icon":"clock",
"label":"Gengrid",
"callback":null
}
}
},
"elm_bg4":
{
"Desc":
{
"parent":"elm_win4",
"class":"Elm_Bg"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.position":[129, -8]
}
},
"elm_flip1":
{
"Desc":
{
"parent":"elm_box3",
"class":"Elm_Flip"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, -1]
},
"Contains":
{
"elm_genlist1":["front"],
"elm_gengrid1":["back"]
}
},
"elm_genlist1":
{
"Desc":
{
"parent":"elm_flip1",
"class":"Elm_Genlist",
"public":true
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true]
}
},
"elm_gengrid1":
{
"Desc":
{
"parent":"elm_flip1",
"class":"Elm_Gengrid",
"public":true
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true]
}
},
"elm_separator1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Separator"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Separator.horizontal":[true]
}
},
"elm_separator2":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Separator"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Separator.horizontal":[true]
}
},
"elm_separator3":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Separator"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Elm_Separator.horizontal":[true]
}
},
"elm_frame1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Frame"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0.50],
"Elm_Widget.part_text":[null, "A collapsable frame"],
"Elm_Frame.autocollapse":[true]
},
"Contains":
{
"elm_label2":[null]
}
},
"elm_dayselector1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Dayselector"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, 0.50]
}
},
"elm_diskselector1":
{
"Desc":
{
"parent":"elm_box2",
"class":"Elm_Diskselector"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size":[60, 50],
"Evas.Object.size_hint_align":[-1, 0.50]
},
"Items":
{
"elm_diskselector1_it0":
{
"type":"regular",
"icon":null,
"label":"Item 1",
"callback":null
},
"elm_diskselector1_it2":
{
"type":"regular",
"icon":null,
"label":"Item 2",
"callback":null
},
"elm_diskselector1_it1":
{
"type":"regular",
"icon":null,
"label":"Item 3",
"callback":null
}
}
},
"elm_ctxpopup1":
{
"Desc":
{
"parent":"elm_win2",
"class":"Elm_Ctxpopup"
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Evas.Object.visibility":[true],
"Evas.Object.size_hint_align":[-1, -1]
},
"Items":
{
"elm_ctxpopup1_it0":
{
"type":"regular",
"icon":null,
"label":"Item 1",
"callback":null
},
"elm_ctxpopup1_it1":
{
"type":"regular",
"icon":null,
"label":"Item 2",
"callback":null
},
"elm_ctxpopup1_it2":
{
"type":"regular",
"icon":null,
"label":"Item 3",
"callback":null
}
}
}
}
}

View File

@ -0,0 +1,73 @@
#!/usr/bin/env python
# encoding: utf-8
import os
import time
from efl import elementary
from efl.utils.erigo import ErigoGui
from efl.elementary.icon import Icon
from efl.elementary.genlist import GenlistItemClass
prj_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "erigo_prj")
json_file = os.path.join(prj_path, "test_gui.egui")
class MyGenlistItemClass(GenlistItemClass):
def text_get(self, obj, part, data):
return 'Item #%d' % data
def content_get(self, obj, part, data):
if part == 'elm.swallow.icon':
return Icon(obj, standard='home')
class MyGui(ErigoGui):
def __init__(self, *args, **kargs):
ErigoGui.__init__(self, *args, **kargs)
self.gl_itc = MyGenlistItemClass(item_style='default')
def widget_generated(self, name, widget):
if name == 'elm_genlist1':
for i in range(100):
self.elm_genlist1.item_append(self.gl_itc, i)
def btn5_clicked_cb(self, btn):
print('USER CB INVOKED', btn)
self.elm_label1.text = 'User cb invoked!'
def btn8_clicked_cb(self, btn):
self.elm_win2.delete()
def win2_btn_clicked_cb(self, btn):
print('USER CB INVOKED', btn)
def win2_radio_changed_cb(self, radio):
print('Radio changed, value: %s' % radio.state_value)
def erigo_clicked(obj):
start_time = time.time()
# Test from file
egui = MyGui(json_file, verbose=True)
# Test from json string
# json = open(json_file).read()
# egui = MyGui(json_string=json, resources_path=prj_path, verbose=True)
egui.elm_label1.text = 'GUI Generated in %.5f seconds' % \
(time.time() - start_time)
if obj is None:
egui.elm_win1.callback_delete_request_add(lambda o: elementary.exit())
if __name__ == '__main__':
elementary.init()
erigo_clicked(None)
elementary.run()
elementary.shutdown()

View File

@ -278,6 +278,7 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
]
ext_modules.extend(utils_ext)
py_modules.append("efl.utils.setup")
py_modules.append("efl.utils.erigo")
packages.append("efl.utils")
# === Evas ===