davemds pushed a commit to branch master. commit f8c332d6366149022306a84d027b1f2a29c66f97 Author: davemds <d...@gurumeditation.it> Date: Mon Sep 16 21:10:45 2013 +0200
Python-EFL: add support for the "recording" style of ProgressBar --- efl/elementary/progressbar.pxd | 4 +++- efl/elementary/progressbar.pyx | 34 ++++++++++++++++++++++++++++++--- examples/elementary/test_progressbar.py | 28 ++++++++++++++++++--------- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/efl/elementary/progressbar.pxd b/efl/elementary/progressbar.pxd index 8762a17..001a82e 100644 --- a/efl/elementary/progressbar.pxd +++ b/efl/elementary/progressbar.pxd @@ -1,4 +1,4 @@ -from efl.evas cimport Eina_Bool, Evas_Object, Evas_Coord +from efl.evas cimport Eina_Bool, Evas_Object, const_Evas_Object, Evas_Coord from libc.string cimport const_char cdef extern from "Elementary.h": @@ -8,6 +8,8 @@ cdef extern from "Elementary.h": void elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state) void elm_progressbar_value_set(Evas_Object *obj, double val) double elm_progressbar_value_get(Evas_Object *obj) + void elm_progressbar_part_value_set(Evas_Object *obj, const_char *part, double val) + double elm_progressbar_part_value_get(const_Evas_Object *obj, const_char *part) void elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size) Evas_Coord elm_progressbar_span_size_get(Evas_Object *obj) void elm_progressbar_unit_format_set(Evas_Object *obj, const_char *format) diff --git a/efl/elementary/progressbar.pyx b/efl/elementary/progressbar.pyx index 83b267d..6d37f9c 100644 --- a/efl/elementary/progressbar.pyx +++ b/efl/elementary/progressbar.pyx @@ -54,15 +54,21 @@ This widget has the following styles: - ``"default"`` - ``"wheel"`` (simple style, no text, no progression, only "pulse" - effect is available) + effect is available) + - ``"recording"`` (style with two independent progress indicators) Default text parts of the progressbar widget that you can use for are: - - "default" - Label of the progressbar + - ``"default"`` - Label of the progressbar Default content parts of the progressbar widget that you can use for are: - - "icon" - An icon of the progressbar + - ``"icon"`` - An icon of the progressbar + +Default part names for the "recording" style: + + - ``"elm.cur.progressbar1"`` - The "main" indicator bar + - ``"elm.cur.progressbar"`` - The "secondary" indicator bar """ @@ -140,6 +146,28 @@ cdef class Progressbar(LayoutClass): def value_get(self): return elm_progressbar_value_get(self.obj) + def part_value_get(self, part not None): + """ Get the progress status (in percentage) for the given part. + + This can be used with a progressbar of style: "recording". The recording + style have two different part that can represent two different progress + operation on the same progressbar at the same time. + The default theme provide two parts by default: + "elm.cur.progressbar" and "elm.cur.progressbar1" + + """ + if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part) + return elm_progressbar_part_value_get(self.obj, <const_char *>part) + + def part_value_set(self, part not None, value): + """ Set the progress status (in percentage) for the given part. + + :see: :py:func:`part_value_get` for more info. + + """ + if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part) + elm_progressbar_part_value_set(self.obj, <const_char *>part, value) + property span_size: """The (exact) length of the bar region of a given progress bar widget. diff --git a/examples/elementary/test_progressbar.py b/examples/elementary/test_progressbar.py index cf8e022..d5f4028 100644 --- a/examples/elementary/test_progressbar.py +++ b/examples/elementary/test_progressbar.py @@ -15,7 +15,7 @@ from efl.elementary.progressbar import Progressbar my_progressbar_run = False my_progressbar_timer = None -def pb_timer_cb(pb1, pb2, pb3, pb4, pb5, pb6, pb7): +def pb_timer_cb(pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8): progress = pb1.value_get() if progress < 1.0: progress += 0.0123 @@ -25,6 +25,8 @@ def pb_timer_cb(pb1, pb2, pb3, pb4, pb5, pb6, pb7): pb4.value_set(progress) pb3.value_set(progress) pb6.value_set(progress) + pb8.part_value_set("elm.cur.progressbar", progress * 1.50) + pb8.part_value_set("elm.cur.progressbar1", progress) if progress < 1.0: return ecore.ECORE_CALLBACK_RENEW global my_progressbar_run @@ -32,7 +34,7 @@ def pb_timer_cb(pb1, pb2, pb3, pb4, pb5, pb6, pb7): return ecore.ECORE_CALLBACK_CANCEL def begin_test(obj, *args, **kwargs): - (pb1, pb2, pb3, pb4, pb5, pb6, pb7) = args + (pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8) = args pb2.pulse(True) pb5.pulse(True) pb7.pulse(True) @@ -43,7 +45,7 @@ def begin_test(obj, *args, **kwargs): *args) my_progressbar_run = True -def end_test(obj, pb1, pb2, pb3, pb4, pb5, pb6, pb7): +def end_test(obj, pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8): pb2.pulse(False) pb5.pulse(False) pb7.pulse(False) @@ -68,6 +70,7 @@ def progressbar_clicked(obj): bx.show() pb1 = Progressbar(win) + pb1.span_size = 300 pb1.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND pb1.size_hint_align = evas.EVAS_HINT_FILL, 0.5 bx.pack_end(pb1) @@ -86,17 +89,24 @@ def progressbar_clicked(obj): ic1.size_hint_aspect = evas.EVAS_ASPECT_CONTROL_VERTICAL, 1, 1 pb3 = Progressbar(win) - pb3.text = "Label" + pb3.text = "Inverted" pb3.content = ic1 pb3.inverted = True pb3.unit_format = "%1.1f units" - pb3.span_size = 200 pb3.size_hint_align = evas.EVAS_HINT_FILL, 0.5 pb3.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND bx.pack_end(pb3) ic1.show() pb3.show() + pb8 = Progressbar(win) + pb8.style = "recording" + pb8.text = "Style: recording" + pb8.size_hint_align = evas.EVAS_HINT_FILL, 0.5 + pb8.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + bx.pack_end(pb8) + pb8.show() + hbx = Box(win) hbx.horizontal = True hbx.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND @@ -110,14 +120,14 @@ def progressbar_clicked(obj): pb4.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND hbx.pack_end(pb4) pb4.span_size = 60 - pb4.text = "percent" + pb4.text = "Vertical" pb4.show() pb5 = Progressbar(win) pb5.horizontal = False pb5.size_hint_align = evas.EVAS_HINT_FILL, 0.5 pb5.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND - pb5.span_size = 80 + pb5.span_size = 120 pb5.pulse_mode = True pb5.unit_format = None pb5.text = "Infinite bounce" @@ -130,7 +140,7 @@ def progressbar_clicked(obj): pb6 = Progressbar(win) pb6.horizontal = False - pb6.text = "Label" + pb6.text = "Inverted" pb6.content = ic2 pb6.inverted = True pb6.unit_format = "%1.2f%%" @@ -156,7 +166,7 @@ def progressbar_clicked(obj): bx.pack_end(bt_bx) bt_bx.show() - pbt = (pb1, pb2, pb3, pb4, pb5, pb6, pb7) + pbt = (pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8) bt = Button(win) bt.text = "Start" --