Added new convenience class: DialogWindow
With a new test for both StandardWindow and DialogWindow
This commit is contained in:
parent
1746a0acdd
commit
64c1d33c9f
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"),
|
||||
])
|
||||
]
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
Loading…
Reference in New Issue