davemds pushed a commit to branch master. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=64c1d33c9f69ec43e342337cb06920b83781cb86
commit 64c1d33c9f69ec43e342337cb06920b83781cb86 Author: Dave Andreoli <d...@gurumeditation.it> Date: Sat Jan 3 14:51:08 2015 +0100 Added new convenience class: DialogWindow With a new test for both StandardWindow and DialogWindow --- efl/elementary/window.pxd | 1 + efl/elementary/window.pyx | 30 ++++++++++++++++++++ examples/elementary/test.py | 5 ++-- examples/elementary/test_win_dialog.py | 50 ++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/efl/elementary/window.pxd b/efl/elementary/window.pxd index 11dc863..0ae4406 100644 --- a/efl/elementary/window.pxd +++ b/efl/elementary/window.pxd @@ -13,6 +13,7 @@ cdef extern from "Ecore_X.h": cdef extern from "Elementary.h": Evas_Object *elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) Evas_Object *elm_win_util_standard_add(const char *name, const char *title) + Evas_Object *elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title) void elm_win_resize_object_add(Evas_Object *obj, Evas_Object* subobj) void elm_win_resize_object_del(Evas_Object *obj, Evas_Object* subobj) void elm_win_title_set(Evas_Object *obj, const char *title) diff --git a/efl/elementary/window.pyx b/efl/elementary/window.pyx index 71ae407..7603e14 100644 --- a/efl/elementary/window.pyx +++ b/efl/elementary/window.pyx @@ -1889,3 +1889,33 @@ cdef class StandardWindow(Window): <const char *>name if name is not None else NULL, <const char *>title if title is not None else NULL)) self._set_properties_from_keyword_args(kwargs) + + +cdef class DialogWindow(Window): + + """A :py:class:`Window` with standard dialog setup. + + This creates a window like :py:class:`Window` but also puts in a standard + :py:class:`Background <efl.elementary.background.Background>`, as well as + setting the window title to ``title``. The window type created is of type + ELM_WIN_DIALOG_BASIC. This tipe of window will be handled in special + mode by window managers with regards of it's parent window. + + :param parent: The parent window (mandatory) + :type parent: :py:class:`efl.evas.Object` + :param name: A name for the new window. + :type name: string + :param title: A title for the new window. + :type title: string + + .. versionadded :: 1.13 + + """ + + def __init__(self, evasObject parent not None, name, title, *args, **kwargs): + if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) + if isinstance(title, unicode): title = PyUnicode_AsUTF8String(title) + self._set_obj(elm_win_util_dialog_add(parent.obj, + <const char *>name if name is not None else NULL, + <const char *>title if title is not None else NULL)) + self._set_properties_from_keyword_args(kwargs) diff --git a/examples/elementary/test.py b/examples/elementary/test.py index 6107239..777f4e1 100755 --- a/examples/elementary/test.py +++ b/examples/elementary/test.py @@ -244,10 +244,11 @@ items = [ ("Web", "test_web", "web_clicked"), ]), ("Window / Background", [ - ("Bg Plain", "test_bg", "bg_plain_clicked"), - ("Bg Image", "test_bg", "bg_image_clicked"), + ("Window Standard/Dialog", "test_win_dialog", "window_dialog_clicked"), ("InnerWindow", "test_inwin", "inner_window_clicked"), ("Window States", "test_win", "window_states_clicked"), + ("Bg Plain", "test_bg", "bg_plain_clicked"), + ("Bg Image", "test_bg", "bg_image_clicked"), ]) ] diff --git a/examples/elementary/test_win_dialog.py b/examples/elementary/test_win_dialog.py new file mode 100644 index 0000000..45a4224 --- /dev/null +++ b/examples/elementary/test_win_dialog.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# encoding: utf-8 + +from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL +from efl import elementary +from efl.elementary.window import StandardWindow, DialogWindow +from efl.elementary.box import Box +from efl.elementary.button import Button +from efl.elementary.label import Label + +EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + + +def clicked_cb(btn, parent): + dia = DialogWindow(parent, "window-dia", "DialogWindow", + size=(200,150), autodel=True) + + lb = Label(dia, text="This is a DialogWindow", + size_hint_weight=EXPAND_BOTH) + dia.resize_object_add(lb) + lb.show() + + dia.show() + +def window_dialog_clicked(obj): + win = StandardWindow("window-states", "This is a StandardWindow", + autodel=True, size=(400, 400)) + if obj is None: + win.callback_delete_request_add(lambda o: elementary.exit()) + + box = Box(win, size_hint_weight=EXPAND_BOTH) + win.resize_object_add(box) + box.show() + + bt = Button(win, text="Create a new dialog") + bt.callback_clicked_add(clicked_cb, win) + box.pack_end(bt) + bt.show() + + win.show() + + +if __name__ == "__main__": + elementary.init() + + window_dialog_clicked(None) + + elementary.run() + elementary.shutdown() + --