aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_external.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-01 01:52:48 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-01 01:52:48 +0200
commit944234bccdd02e53d14490373fa15930667bb50b (patch)
tree4acbfc7f477d19450664add6f75639ac5daaa182 /examples/elementary/test_external.py
parentElementary.datetime_elm: Fix an API bug. (diff)
downloadpython-efl-944234bccdd02e53d14490373fa15930667bb50b.tar.gz
Elementary: Examplifying examples.
Diffstat (limited to 'examples/elementary/test_external.py')
-rw-r--r--examples/elementary/test_external.py113
1 files changed, 39 insertions, 74 deletions
diff --git a/examples/elementary/test_external.py b/examples/elementary/test_external.py
index e84bfb2..dc7788d 100644
--- a/examples/elementary/test_external.py
+++ b/examples/elementary/test_external.py
@@ -1,12 +1,11 @@
#!/usr/bin/env python
# encoding: utf-8
-from efl import evas
-from efl import ecore
+from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
+from efl.ecore import Timer
from efl import edje
from efl import elementary
-from efl.elementary.window import Window
-from efl.elementary.background import Background
+from efl.elementary.window import StandardWindow
from efl.elementary.progressbar import Progressbar
from efl.elementary.button import Button
from efl.elementary.layout import Layout
@@ -15,24 +14,22 @@ from efl.elementary.frame import Frame
from efl.elementary.label import Label
from efl.elementary.list import List
+EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
+FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
def edje_external_button_clicked(obj, item=None):
- win = Window("edje-external-button", elementary.ELM_WIN_BASIC)
- win.title_set("Edje External Button")
- win.autodel_set(True)
+ win = StandardWindow("edje-external-button", "Edje External Button",
+ autodel=True, size=(320, 400))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- ly = Layout(win)
- ly.file_set("test_external.edj", "external/button")
- ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ ly = Layout(win, file=("test_external.edj", "external/button"),
+ size_hint_weight=EXPAND_BOTH)
win.resize_object_add(ly)
ly.show()
- win.resize(320, 400)
win.show()
-
def animate(ly):
val = ly.edje_get().part_external_object_get("ext_pbar1").value
val += 0.0123
@@ -41,7 +38,7 @@ def animate(ly):
ly.edje_get().part_external_object_get(part_name).value = val
if val < 1:
- ecore.timer_add(0.1, animate, ly)
+ Timer(0.1, animate, ly)
else:
for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
ly.edje_get().part_external_object_get(part_name).pulse(False)
@@ -51,128 +48,99 @@ def animate(ly):
return False
def cb_btn3_clicked(bt, ly):
- ly.edje_get().part_external_object_get("ext_pbar1").value = 0.0
+ ly.edje.part_external_object_get("ext_pbar1").value = 0.0
for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
ly.edje_get().part_external_object_get(part_name).pulse(True)
for part_name in ["ext_button1", "ext_button2", "ext_button3"]:
ly.edje_get().part_external_object_get(part_name).disabled = True
- ecore.timer_add(0.1, animate, ly)
+ Timer(0.1, animate, ly)
def edje_external_pbar_clicked(obj, item=None):
- win = Window("edje-external-pbar", elementary.ELM_WIN_BASIC)
- win.title_set("Edje External Progress Bar")
- win.autodel_set(True)
+ win = StandardWindow("edje-external-pbar", "Edje External Progress Bar",
+ autodel=True, size=(320, 400))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- ly = Layout(win)
- ly.file_set("test_external.edj", "external/pbar")
- ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ ly = Layout(win, file=("test_external.edj", "external/pbar"),
+ size_hint_weight=EXPAND_BOTH)
win.resize_object_add(ly)
ly.show()
- bt = ly.edje_get().part_external_object_get("ext_button3")
+ bt = ly.edje.part_external_object_get("ext_button3")
bt.text = "...or from Python"
bt.callback_clicked_add(cb_btn3_clicked, ly)
- win.resize(320, 400)
win.show()
-
def edje_external_scroller_clicked(obj, item=None):
- win = Window("edje-external-scroller", elementary.ELM_WIN_BASIC)
- win.title_set("Edje External Scroller")
- win.autodel_set(True)
+ win = StandardWindow("edje-external-scroller", "Edje External Scroller",
+ autodel=True, size=(320, 400))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- ly = Layout(win)
- ly.file_set("test_external.edj", "external/scroller")
- ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ ly = Layout(win, file=("test_external.edj", "external/scroller"),
+ size_hint_weight=EXPAND_BOTH)
win.resize_object_add(ly)
ly.show()
- win.resize(320, 400)
win.show()
-
def edje_external_slider_clicked(obj, item=None):
- win = Window("edje-external-slider", elementary.ELM_WIN_BASIC)
- win.title_set("Edje External Slider")
- win.autodel_set(True)
+ win = StandardWindow("edje-external-slider", "Edje External Slider",
+ autodel=True, size=(320, 400))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- ly = Layout(win)
- ly.file_set("test_external.edj", "external/slider")
- ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ ly = Layout(win, file=("test_external.edj", "external/slider"),
+ size_hint_weight=EXPAND_BOTH)
win.resize_object_add(ly)
ly.show()
- win.resize(320, 400)
win.show()
-
def edje_external_video_clicked(obj, item=None):
- win = Window("edje-external-video", elementary.ELM_WIN_BASIC)
- win.title_set("Edje External Video")
- win.autodel_set(True)
+ win = StandardWindow("edje-external-video", "Edje External Video",
+ autodel=True, size=(320, 400))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- ly = Layout(win)
- ly.file_set("test_external.edj", "external/video")
- ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ ly = Layout(win, file=("test_external.edj", "external/video"),
+ size_hint_weight=EXPAND_BOTH)
win.resize_object_add(ly)
ly.show()
- win.resize(320, 400)
win.show()
-
if __name__ == "__main__":
- def destroy(obj):
- elementary.exit()
-
elementary.init()
- win = Window("test", elementary.ELM_WIN_BASIC)
- win.title_set("python-elementary test application")
- win.callback_delete_request_add(destroy)
-
- bg = Background(win)
- win.resize_object_add(bg)
- bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- bg.show()
+ win = StandardWindow("test", "python-elementary test application",
+ size=(320,520))
+ win.callback_delete_request_add(lambda o: elementary.exit())
- box0 = Box(win)
- box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ box0 = Box(win, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(box0)
box0.show()
- fr = Frame(win)
- fr.text_set("Information")
- box0.pack_end(fr)
- fr.show()
-
lb = Label(win)
lb.text_set("Please select a test from the list below<br>"
"by clicking the test button to show the<br>"
"test window.")
- fr.content_set(lb)
lb.show()
+ fr = Frame(win, text="Information", content=lb)
+ box0.pack_end(fr)
+ fr.show()
+
items = [("Ext Button", edje_external_button_clicked),
("Ext ProgressBar", edje_external_pbar_clicked),
("Ext Scroller", edje_external_scroller_clicked),
("Ext Slider", edje_external_slider_clicked),
("Ext Video", edje_external_video_clicked)]
-
- li = List(win)
- li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+
+ li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
box0.pack_end(li)
li.show()
@@ -181,9 +149,6 @@ if __name__ == "__main__":
li.go()
- win.resize(320,520)
win.show()
elementary.run()
elementary.shutdown()
- ecore.shutdown()
- evas.shutdown()