Implemented -Create- callback type
This commit is contained in:
parent
8fecc5f55b
commit
64c58021ea
|
@ -20,13 +20,18 @@
|
|||
TODO
|
||||
====
|
||||
|
||||
* fix 'file' property
|
||||
* mainmenu ??
|
||||
* implement Resources ... but when? always in the file prop?
|
||||
* test more widget items (only menu tested atm)
|
||||
* implement callbacks
|
||||
* documentation for this module
|
||||
|
||||
* properties that need to be fixed:
|
||||
- visibility
|
||||
- file
|
||||
- position
|
||||
|
||||
* What when we create the same widget more than one time ?
|
||||
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
@ -81,7 +86,7 @@ class ErigoGui(object):
|
|||
print(msg)
|
||||
|
||||
|
||||
def _widget_generate(self, name):
|
||||
def _widget_generate(self, name, parent_name=None):
|
||||
self._print('\n### Generating widget: %s' % name)
|
||||
|
||||
# get the widget class object from the correct module
|
||||
|
@ -96,11 +101,10 @@ def _widget_generate(self, name):
|
|||
# Custom CONSTRUCTOR
|
||||
params = w_data['Properties'][eo_klass_name+'.constructor']
|
||||
params = _params_list_parse(mod, params)
|
||||
w = klass(*params)
|
||||
w = klass(*params, parent=self._widgets.get(parent_name))
|
||||
else:
|
||||
# Standard CONSTRUCTOR
|
||||
parent_name = w_data['Desc']['parent']
|
||||
parent = self._widgets[parent_name]
|
||||
parent = self._widgets[parent_name or w_data['Desc']['parent']]
|
||||
w = klass(parent)
|
||||
self._widgets[name] = w
|
||||
|
||||
|
@ -151,7 +155,7 @@ def _widget_generate(self, name):
|
|||
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, rspan, cspan)
|
||||
w.pack(child, x, y, cspan, rspan)
|
||||
|
||||
|
||||
# callbacks
|
||||
|
@ -174,7 +178,10 @@ def _widget_generate(self, name):
|
|||
w._callback_add(str(event_name), getattr(self, cb_name))
|
||||
|
||||
elif cb_data[0] == 'Create':
|
||||
print("TODO")
|
||||
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)
|
||||
|
||||
return w
|
||||
|
||||
|
@ -212,3 +219,5 @@ def _property_modify_cb(obj, self, widget_name, prop_name, values):
|
|||
values = (values[0])
|
||||
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)
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
},
|
||||
"Eo_Callbacks":
|
||||
{
|
||||
"btn5_clicked_cb_alias":"btn5_clicked_cb"
|
||||
"btn5_clicked_cb_alias":"btn5_clicked_cb",
|
||||
"btn8_clicked_cb_alias":"btn8_clicked_cb",
|
||||
"win2_btn_clicked_cb_alias":"win2_btn_clicked_cb"
|
||||
}
|
||||
},
|
||||
"Widgets":
|
||||
|
@ -159,7 +161,10 @@
|
|||
"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_button5":[1, 1, 1, 1],
|
||||
"elm_button6":[0, 2, 1, 1],
|
||||
"elm_button8":[1, 2, 1, 1],
|
||||
"elm_button9":[0, 3, 2, 1]
|
||||
}
|
||||
},
|
||||
"elm_button2":
|
||||
|
@ -251,6 +256,204 @@
|
|||
{
|
||||
"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
|
||||
},
|
||||
"Properties":
|
||||
{
|
||||
"Elm_Win.title":["elm_win2"],
|
||||
"Evas.Object.size_hint_weight":[1, 1],
|
||||
"Evas.Object.visibility":[true],
|
||||
"Evas.Object.size":[150, 100],
|
||||
"Elm_Win.constructor":[null, "ELM_WIN_BASIC"],
|
||||
"Elm_Win.autodel":[true]
|
||||
},
|
||||
"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_label2", "elm_button7"]
|
||||
},
|
||||
"elm_label2":
|
||||
{
|
||||
"Desc":
|
||||
{
|
||||
"parent":"elm_box2",
|
||||
"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"
|
||||
},
|
||||
"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.constructor":["dia-win", "ELM_WIN_DIALOG_BASIC"],
|
||||
"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 <br> I should move with my parent"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,12 @@ class MyGui(ErigoGui):
|
|||
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 erigo_clicked(obj):
|
||||
start_time = time.time()
|
||||
|
|
Loading…
Reference in New Issue