aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_tooltip.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-03 10:42:50 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-03 10:42:50 +0200
commitcf1f98bbf611ad14662254988a48529cfedcf49c (patch)
tree870be59a45571058abf7d380dbf6ecc359ad5748 /examples/elementary/test_tooltip.py
parentElementary.progressbar: Style "recording" -> "double" (diff)
downloadpython-efl-cf1f98bbf611ad14662254988a48529cfedcf49c.tar.gz
Elementary: Improve the rest of the examples.
Summary of changes: - Make use of constructor keyword args - Most scripts are now working directory agnostic - Enabled evas textgrid example - Printed messages are slightly better formatted
Diffstat (limited to 'examples/elementary/test_tooltip.py')
-rw-r--r--examples/elementary/test_tooltip.py92
1 files changed, 36 insertions, 56 deletions
diff --git a/examples/elementary/test_tooltip.py b/examples/elementary/test_tooltip.py
index c7e07a5..65f4c3b 100644
--- a/examples/elementary/test_tooltip.py
+++ b/examples/elementary/test_tooltip.py
@@ -1,11 +1,12 @@
#!/usr/bin/env python
# encoding: utf-8
-from efl import evas
-from efl import ecore
+import os
+
+from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
+from efl.ecore import Timer
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.box import Box
from efl.elementary.button import Button
from efl.elementary.entry import Entry
@@ -13,22 +14,25 @@ from efl.elementary.list import List
from efl.elementary.toolbar import Toolbar
from efl.elementary.icon import Icon
+EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
+EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
+FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
+FILL_HORIZ = EVAS_HINT_FILL, 0.5
+
+script_path = os.path.dirname(os.path.abspath(__file__))
+img_path = os.path.join(script_path, "images")
def _tt_icon(obj, *args, **kargs):
- ic = Icon(obj)
- ic.file_set("images/logo_small.png")
- ic.resizable_set(0, 0)
- ic.resize(64, 64)
+ ic = Icon(obj, file=os.path.join(img_path, "logo_small.png"),
+ resizable=(False, False), size=(64, 64))
return ic
def _tt_item_icon(obj, item, *args, **kargs):
return _tt_icon(obj,item, *args, **kargs)
def _tt_icon2(obj, *args, **kargs):
- ic = Icon(obj)
- ic.file_set("images/icon_00.png")
- ic.resizable_set(0, 0)
- ic.resize(64, 64)
+ ic = Icon(obj, file=os.path.join(img_path, "icon_00.png"),
+ resizable=(False, False), size=(64, 64))
return ic
def _tt_timer_del(obj, data, *args):
@@ -39,26 +43,16 @@ def _tt_timer_del(obj, data, *args):
def tooltip_clicked(obj):
- win = Window("tooltips", elementary.ELM_WIN_BASIC)
- win.title_set("Tooltips")
- win.autodel_set(True)
+ win = StandardWindow("tooltips", "Tooltips", autodel=True, size=(400, 500))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- bg = Background(win)
- win.resize_object_add(bg)
- bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- bg.show()
-
- bx = Box(win)
+ bx = Box(win, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(bx)
- bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
bx.show()
- tb = Toolbar(win)
- tb.homogeneous_set(False)
- tb.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
- tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0)
+ tb = Toolbar(win, homogeneous=False, size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_HORIZ)
bx.pack_end(tb)
tb.show()
@@ -69,8 +63,7 @@ def tooltip_clicked(obj):
ti.tooltip_content_cb_set(_tt_item_icon, None)
ti.tooltip_style_set("transparent")
- bt = Button(win)
- bt.text_set("Simple text tooltip");
+ bt = Button(win, text="Simple text tooltip")
bt.tooltip_text_set("Simple text tooltip")
bx.pack_end(bt)
bt.show()
@@ -83,8 +76,7 @@ def tooltip_clicked(obj):
value += 1
data["value"] = value
- bt = Button(win)
- bt.text_set("Simple text tooltip, click to change");
+ bt = Button(win, text="Simple text tooltip, click to change")
bt.tooltip_text_set("Initial")
data = dict()
bt.callback_clicked_add(_tt_text_replace, data)
@@ -102,12 +94,10 @@ def tooltip_clicked(obj):
del data["timer"]
obj.text_set("Simple text tooltip, click to start changed timed")
return
- data["timer"] = ecore.timer_add(1.5, _tt_text_replace_timer_cb, obj,
- data)
+ data["timer"] = Timer(1.5, _tt_text_replace_timer_cb, obj, data)
obj.text_set("Simple text tooltip, click to stop changed timed")
- bt = Button(win)
- bt.text_set("Simple text tooltip, click to start changed timed");
+ bt = Button(win, text="Simple text tooltip, click to start changed timed")
bt.tooltip_text_set("Initial")
data = dict()
bt.callback_clicked_add(_tt_text_replace_timed, data)
@@ -115,8 +105,7 @@ def tooltip_clicked(obj):
bt.show()
bt.on_del_add(_tt_timer_del, data)
- bt = Button(win)
- bt.text_set("Icon tooltip");
+ bt = Button(win, text="Icon tooltip")
bt.tooltip_content_cb_set(_tt_icon, None)
bx.pack_end(bt)
bt.show()
@@ -141,8 +130,7 @@ def tooltip_clicked(obj):
data)
obj.text_set("Icon tooltip, click to stop changed timed")
- bt = Button(win)
- bt.text_set("Icon tooltip, click to start changed timed");
+ bt = Button(win, text="Icon tooltip, click to start changed timed")
bt.tooltip_content_cb_set(_tt_icon)
data = dict()
bt.callback_clicked_add(_tt_icon_replace_timed, data)
@@ -150,8 +138,7 @@ def tooltip_clicked(obj):
bt.show()
bt.on_del_add(_tt_timer_del, data)
- bt = Button(win)
- bt.text_set("Transparent Icon tooltip");
+ bt = Button(win, text="Transparent Icon tooltip")
bt.tooltip_content_cb_set(_tt_icon, None)
bt.tooltip_style_set("transparent")
bx.pack_end(bt)
@@ -177,8 +164,7 @@ def tooltip_clicked(obj):
data)
obj.text_set("Icon tooltip, click to stop changed timed")
- bt = Button(win)
- bt.text_set("Icon tooltip style, click to start changed timed");
+ bt = Button(win, text="Icon tooltip style, click to start changed timed")
bt.tooltip_content_cb_set(_tt_icon, None)
data = dict()
bt.callback_clicked_add(_tt_style_replace_timed, data)
@@ -196,38 +182,32 @@ def tooltip_clicked(obj):
obj.text_set("Locked tooltip visibility");
obj.tooltip_show()
- bt = Button(win)
- bt.text_set("Unlocked tooltip visibility");
- bt.tooltip_text_set("This tooltip is unlocked visible,<br> clock the button to lock!")
+ bt = Button(win, text="Unlocked tooltip visibility");
+ bt.tooltip_text_set(
+ "This tooltip is unlocked visible,<br> clock the button to lock!")
data = dict()
bt.callback_clicked_add(_tt_visible_lock_toggle, data)
bx.pack_end(bt)
bt.show()
- en = Entry(win)
- en.scrollable_set(True)
- en.single_line_set(True)
- en.entry_set("Hello, some scrolled entry here!")
- en.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
- en.size_hint_align_set(evas.EVAS_HINT_FILL, 0.5)
+ en = Entry(win, scrollable=True, single_line=True,
+ entry="Hello, some scrolled entry here!", size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_HORIZ)
en.tooltip_text_set("Type something here!")
bx.pack_end(en)
en.show()
- lst = List(win)
+ lst = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
+ size_hint_min=(100, 100))
li = lst.item_append("Hello")
li.tooltip_text_set("Something useful here?")
li = lst.item_append("Icon Tooltip")
li.tooltip_content_cb_set(_tt_item_icon, None)
- lst.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- lst.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
- lst.size_hint_min_set(100, 100)
bx.pack_end(lst)
lst.go()
lst.show()
win.show()
- win.resize(400, 500)
if __name__ == "__main__":