aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_label.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
commitb58be93f121c2ca240b888d1dd41896d4779927f (patch)
tree371d4e331b3e685e106b211ce3e28b31e9886ada /examples/elementary/test_label.py
parentPython-EFL: Cleanup and enable compilation of emotion, cleaned also the test. (diff)
downloadpython-efl-b58be93f121c2ca240b888d1dd41896d4779927f.tar.gz
move elementary and emotion tests in a new examples dir. Now tests/ contain only unittest while examples/ all the other tests that need user interaction
SVN revision: 83964
Diffstat (limited to 'examples/elementary/test_label.py')
-rw-r--r--examples/elementary/test_label.py169
1 files changed, 169 insertions, 0 deletions
diff --git a/examples/elementary/test_label.py b/examples/elementary/test_label.py
new file mode 100644
index 0000000..adbba0a
--- /dev/null
+++ b/examples/elementary/test_label.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from efl import elementary
+from efl import evas
+
+
+def cb_slide_radio(radio, lb):
+ lb.style = radio.text
+
+def cb_slider_duration(slider, lb):
+ lb.slide = False
+ lb.slide_duration = slider.value
+ lb.slide = True
+
+def label_clicked(obj):
+ win = elementary.Window("label", elementary.ELM_WIN_BASIC)
+ win.title = "Label test"
+ win.autodel = True
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ bg = elementary.Background(win)
+ win.resize_object_add(bg)
+ bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bg.show()
+
+ vbox = elementary.Box(win)
+ vbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ vbox.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ win.resize_object_add(vbox)
+ vbox.show()
+
+ lb = elementary.Label(win)
+ lb.text = "<b>This is a small label</b>"
+ lb.size_hint_align = (0.0, 0.5)
+ vbox.pack_end(lb)
+ lb.show()
+
+ lb = elementary.Label(win)
+ lb.text = "This is a larger label with newlines<br/>" \
+ "to make it bigger, bit it won't expand or wrap<br/>" \
+ "just be a block of text that can't change its<br/>" \
+ "formatting as it's fixed based on text<br/>"
+ lb.size_hint_align = (0.0, 0.5)
+ vbox.pack_end(lb)
+ lb.show()
+
+ lb = elementary.Label(win)
+ lb.line_wrap_set(elementary.ELM_WRAP_CHAR)
+ lb.text = "<b>This is more text designed to line-wrap here as " \
+ "This object is resized horizontally. As it is " \
+ "resized vertically though, nothing should change. " \
+ "The amount of space allocated vertically should " \
+ "change as horizontal size changes.</b>"
+ lb.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ lb.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ vbox.pack_end(lb)
+ lb.show()
+
+ lb = elementary.Label(win)
+ lb.text = "This small label set to wrap"
+ lb.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ lb.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ vbox.pack_end(lb)
+ lb.show()
+
+ sp = elementary.Separator(win)
+ sp.horizontal = True
+ vbox.pack_end(sp)
+ sp.show()
+
+ gd = elementary.Grid(win)
+ gd.size = (100, 100)
+ gd.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ gd.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ vbox.pack_end(gd)
+ gd.show()
+
+ lb = elementary.Label(win)
+ lb.text = "Test Label Ellipsis:"
+ lb.size_hint_align = (0.0, 0.5)
+ gd.pack(lb, 5, 5, 90, 15)
+ lb.show()
+
+ rect = evas.Rectangle(win.evas)
+ rect.color = (255, 125, 125, 255)
+ gd.pack(rect, 5, 15, 90, 15)
+ rect.show()
+
+ lb = elementary.Label(win)
+ lb.text = "This is a label set to ellipsis. " \
+ "If set ellipsis to true and the text doesn't fit " \
+ "in the label an ellipsis(\"...\") will be shown " \
+ "at the end of the widget."
+ lb.ellipsis = True
+ lb.size_hint_align = (0.0, 0.5)
+ gd.pack(lb, 5, 15, 90, 15)
+ lb.show()
+
+ lb = elementary.Label(win)
+ lb.text = "Test Label Slide:"
+ lb.size_hint_align = (0.0, 0.5)
+ gd.pack(lb, 5, 40, 90, 15)
+ lb.show()
+
+ rect = evas.Rectangle(win.evas)
+ rect.color = (255, 125, 125, 255)
+ gd.pack(rect, 5, 50, 90, 15)
+ rect.show()
+
+ lb = elementary.Label(win)
+ lb.text = "This is a label set to slide. " \
+ "If set slide to true the text of the label " \
+ "will slide/scroll through the length of label." \
+ "This only works with the themes \"slide_short\", " \
+ "\"slide_long\" and \"slide_bounce\"."
+ lb.slide = True
+ lb.style = ("slide_short")
+ lb.size_hint_align = (0.0, 0.5)
+ gd.pack(lb, 5, 50, 90, 15)
+ lb.show()
+
+ rd = elementary.Radio(win)
+ rd.state_value = 1
+ rd.text = "slide_short"
+ gd.pack(rd, 5, 65, 30, 15)
+ rd.callback_changed_add(cb_slide_radio, lb)
+ rd.show()
+ rdg = rd
+
+ rd = elementary.Radio(win)
+ rd.group_add(rdg)
+ rd.state_value = 2
+ rd.text = "slide_long"
+ gd.pack(rd, 35, 65, 30, 15)
+ rd.callback_changed_add(cb_slide_radio, lb)
+ rd.show()
+
+ rd = elementary.Radio(win)
+ rd.group_add(rdg)
+ rd.state_value = 3
+ rd.text = "slide_bounce"
+ gd.pack(rd, 65, 65, 30, 15)
+ rd.callback_changed_add(cb_slide_radio, lb)
+ rd.show()
+
+ sl = elementary.Slider(win)
+ sl.text = "Slide Duration"
+ sl.unit_format = "%1.1f units"
+ sl.min_max = (1, 20)
+ sl.value = 10
+ sl.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
+ sl.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ sl.callback_changed_add(cb_slider_duration, lb)
+ gd.pack(sl, 5, 80, 90, 15)
+ sl.show()
+
+ win.resize(280, 400)
+ win.show()
+
+
+if __name__ == "__main__":
+ elementary.init()
+
+ label_clicked(None)
+
+ elementary.run()
+ elementary.shutdown()