aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_label.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-02 02:10:56 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-02 02:10:56 +0200
commita2364dba2c6cb275b3d3e592d128bfbc4a650dc0 (patch)
tree0e1fcddc0414c39075fa453116beed3efed708a1 /examples/elementary/test_label.py
parentElementary.object_item: Change ObjectItem.data to hold a dict (like Eo). (diff)
downloadpython-efl-a2364dba2c6cb275b3d3e592d128bfbc4a650dc0.tar.gz
Elementary: Examples, part N.
"We're doing it, we're doing it! Stop being so testy." - Vincent Price as The Sinister Man, addressing Satan.
Diffstat (limited to 'examples/elementary/test_label.py')
-rw-r--r--examples/elementary/test_label.py101
1 files changed, 32 insertions, 69 deletions
diff --git a/examples/elementary/test_label.py b/examples/elementary/test_label.py
index d03f583..ffa1a18 100644
--- a/examples/elementary/test_label.py
+++ b/examples/elementary/test_label.py
@@ -1,17 +1,20 @@
#!/usr/bin/env python
# encoding: utf-8
-from efl import evas
+from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, Rectangle
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.grid import Grid
-from efl.elementary.label import Label
+from efl.elementary.label import Label, ELM_WRAP_CHAR, ELM_LABEL_SLIDE_MODE_AUTO
from efl.elementary.radio import Radio
from efl.elementary.separator import Separator
from efl.elementary.slider import Slider
+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
def cb_slide_radio(radio, lb):
lb.style = radio.text
@@ -22,149 +25,109 @@ def cb_slider_duration(slider, lb):
lb.slide = True
def label_clicked(obj):
- win = Window("label", elementary.ELM_WIN_BASIC)
- win.title = "Label test"
- win.autodel = True
+ win = StandardWindow("label", "Label test", autodel=True, size=(280, 400))
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 = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- bg.show()
-
- vbox = 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)
+ vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
win.resize_object_add(vbox)
vbox.show()
- lb = Label(win)
- lb.text = "<b>This is a small label</b>"
- lb.size_hint_align = (0.0, 0.5)
+ lb = Label(win, "<b>This is a small label</b>", size_hint_align=(0.0, 0.5))
vbox.pack_end(lb)
lb.show()
- lb = Label(win)
+ lb = Label(win, size_hint_align=(0.0, 0.5))
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 = Label(win)
- lb.line_wrap_set(elementary.ELM_WRAP_CHAR)
+ lb = Label(win, line_wrap=ELM_WRAP_CHAR, size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_BOTH)
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 = 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)
+ lb = Label(win, text="This small label set to wrap",
+ size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
vbox.pack_end(lb)
lb.show()
- sp = Separator(win)
- sp.horizontal = True
+ sp = Separator(win, horizontal=True)
vbox.pack_end(sp)
sp.show()
- gd = 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)
+ gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_BOTH)
vbox.pack_end(gd)
gd.show()
-
- lb = Label(win)
- lb.text = "Test Label Ellipsis:"
- lb.size_hint_align = (0.0, 0.5)
+
+ lb = Label(win, text="Test Label Ellipsis:", 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)
+ rect = Rectangle(win.evas, color=(255, 125, 125, 255))
gd.pack(rect, 5, 15, 90, 15)
rect.show()
- lb = Label(win)
+ lb = Label(win, ellipsis=True, size_hint_align=(0.0, 0.5))
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 = Label(win)
- lb.text = "Test Label Slide:"
- lb.size_hint_align = (0.0, 0.5)
+ lb = Label(win, "Test Label Slide:", 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)
+ rect = Rectangle(win.evas, color=(255, 125, 125, 255))
gd.pack(rect, 5, 50, 90, 15)
rect.show()
- lb = Label(win)
+ lb = Label(win, slide_mode=ELM_LABEL_SLIDE_MODE_AUTO, style="slide_short",
+ size_hint_align=(0.0, 0.5))
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_mode = elementary.ELM_LABEL_SLIDE_MODE_AUTO
- lb.style = ("slide_short")
- lb.size_hint_align = (0.0, 0.5)
gd.pack(lb, 5, 50, 90, 15)
lb.show()
- rd = Radio(win)
- rd.state_value = 1
- rd.text = "slide_short"
+ rd = Radio(win, state_value=1, text="slide_short")
gd.pack(rd, 5, 65, 30, 15)
rd.callback_changed_add(cb_slide_radio, lb)
rd.show()
rdg = rd
- rd = Radio(win)
+ rd = Radio(win, state_value=2, text="slide_long")
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 = Radio(win)
+ rd = Radio(win, state_value=3, text="slide_bounce")
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 = 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 = Slider(win, text="Slide Duration", unit_format="%1.1f units",
+ min_max=(1, 20), value=10, size_hint_align=FILL_HORIZ,
+ size_hint_weight=EXPAND_HORIZ)
sl.callback_changed_add(cb_slider_duration, lb)
gd.pack(sl, 5, 80, 90, 15)
sl.show()
- win.resize(280, 400)
win.show()