Elementary: Add Slider example, fixed minor issues in others

This commit is contained in:
Kai Huuhko 2013-11-04 07:07:17 +02:00
parent cb1ae5d01a
commit a261a2bb69
4 changed files with 281 additions and 17 deletions

View File

@ -44,15 +44,15 @@ items = [
("Evas Map 3D", "test_3d", "evas3d_clicked"),
]),
("Booleans", [
("Checks", "test_check", "check_clicked"),
# ("Toggles", toggles_clicked),TODO make a toggle with check
("Check", "test_check", "check_clicked"),
#TODO: ("Toggle", "test_check", "toggle_clicked"),
]),
("Boundaries", [
("Bubble", "test_bubble", "bubble_clicked"),
("Separator", "test_separator", "separator_clicked"),
]),
("Buttons", [
("Buttons", "test_button", "buttons_clicked"),
("Button", "test_button", "buttons_clicked"),
]),
("Containers", [
("Box Horiz", "test_box", "box_horiz_clicked"),
@ -73,6 +73,16 @@ items = [
("Dividers", [
("Panel", "test_panel", "panel_clicked"),
("Panes", "test_panes", "panes_clicked"),
]),
("Drag & Drop", [
("Genlist DnD Default Anim", "test_dnd", "dnd_genlist_default_anim_clicked"),
]),
("Edje External", [
("Ext Button", "test_external", "edje_external_button_clicked"),
("Ext ProgressBar", "test_external", "edje_external_pbar_clicked"),
("Ext Scroller", "test_external", "edje_external_scroller_clicked"),
("Ext Slider", "test_external", "edje_external_slider_clicked"),
("Ext Video", "test_external", "edje_external_video_clicked"),
]),
("Effects", [
("Flip", "test_flip", "flip_clicked"),
@ -92,13 +102,6 @@ items = [
("Entry Scrolled", "test_entry", "entry_scrolled_clicked"),
("Entry Anchor", "test_entry", "entry_anchor_clicked"),
("MultiButtonEntry", "test_multibuttonentry", "multibuttonentry_clicked"),
]),
("Edje External", [
("Ext Button", "test_external", "edje_external_button_clicked"),
("Ext ProgressBar", "test_external", "edje_external_pbar_clicked"),
("Ext Scroller", "test_external", "edje_external_scroller_clicked"),
("Ext Slider", "test_external", "edje_external_slider_clicked"),
("Ext Video", "test_external", "edje_external_video_clicked"),
]),
("Geographic", [
("Map", "test_map", "map_clicked"),
@ -152,6 +155,7 @@ items = [
("Range Values", [
("Spinner", "test_spinner", "spinner_clicked"),
("Progressbar", "test_progressbar", "progressbar_clicked"),
("Slider", "test_slider", "slider_clicked"),
]),
("Scroller", [
("Scroller", "test_scroller", "scroller_clicked"),

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python
# encoding: utf-8
import os
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, FilledImage
from efl import elementary
from efl.elementary.window import StandardWindow
@ -14,6 +16,9 @@ from efl.elementary.scroller import Scroller
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
script_path = os.path.dirname(os.path.abspath(__file__))
img_path = os.path.join(script_path, "images")
def cb_items(li, item):
print(("ctxpopup item selected: %s" % (item.text)))
@ -29,7 +34,7 @@ def cb_btn(btn):
if "img" in cp.data:
return
img = FilledImage(btn.evas)
img.file_set("images/sky_04.jpg")
img.file_set(os.path.join(img_path, "sky_04.jpg"))
img.move(40, 40)
img.resize(320, 320)
img.show()

View File

@ -1,11 +1,16 @@
#!/usr/bin/env python
# encoding: utf-8
import os
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \
EVAS_ASPECT_CONTROL_VERTICAL, EVAS_CALLBACK_MOUSE_MOVE, \
EVAS_CALLBACK_MOUSE_UP, EVAS_CALLBACK_MOUSE_DOWN, \
EVAS_EVENT_FLAG_ON_HOLD
from efl import elementary
from efl.elementary.label import Label
from efl.elementary.frame import Frame
from efl.elementary.list import List
from efl.elementary.box import Box
from efl.elementary.window import StandardWindow
from efl.elementary.icon import Icon
@ -15,6 +20,9 @@ from efl.elementary.genlist import Genlist, GenlistItemClass, \
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
script_path = os.path.dirname(os.path.abspath(__file__))
img_path = os.path.join(script_path, "images")
img = (
"panel_01.jpg",
"plant_01.jpg",
@ -51,7 +59,7 @@ class DndItemClass(GenlistItemClass):
def content_get(self, obj, part, data, *args):
if part == "elm.swallow.icon":
icon = Icon(obj, file=data,
icon = Icon(obj, file=os.path.join(img_path, data),
size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
icon.show()
return icon
@ -69,7 +77,7 @@ def win_del(obj, data):
# FIXME Needed?: if (itc1) elm_genlist_item_class_free(itc1)
#itc1 = NULL
elementary.exit()
#elementary.exit()
def gl_item_getcb(gl, x, y):
# This function returns pointer to item under (x,y) coords
@ -511,10 +519,9 @@ def gl_dnd_default_anim_data_getcb(gl, it):
# else
# return False
def dnd_genlist_default_anim_clicked(*args):
def dnd_genlist_default_anim_clicked(obj, item=None):
win = StandardWindow("dnd-genlist-default-anim",
"DnD-Genlist-Default-Anim", autodel=True, size=(680, 800))
win.autodel = True
bxx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(bxx)
@ -542,7 +549,7 @@ def dnd_genlist_default_anim_clicked(*args):
#itc1 = DndItemClass()
for i in range (20):
gl.item_append(itc1, "images/{0}".format(img[i % 9]), flags=ELM_GENLIST_ITEM_NONE)
gl.item_append(itc1, img[i % 9], flags=ELM_GENLIST_ITEM_NONE)
win.show()
@ -683,8 +690,37 @@ def dnd_genlist_default_anim_clicked(*args):
if __name__ == "__main__":
elementary.init()
win = StandardWindow("test", "python-elementary test application",
size=(320,520))
win.callback_delete_request_add(lambda o: elementary.exit())
dnd_genlist_default_anim_clicked(None)
box0 = Box(win, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(box0)
box0.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.")
lb.show()
fr = Frame(win, text="Information", content=lb)
box0.pack_end(fr)
fr.show()
items = [
("DnD Genlist Default Anim", dnd_genlist_default_anim_clicked),
]
li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
box0.pack_end(li)
li.show()
for item in items:
li.item_append(item[0], callback=item[1])
li.go()
win.show()
elementary.run()
elementary.shutdown()

View File

@ -0,0 +1,219 @@
#!/usr/bin/env python
# encoding: utf-8
import os
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \
EVAS_ASPECT_CONTROL_VERTICAL, EVAS_ASPECT_CONTROL_HORIZONTAL
from efl import elementary
from efl.elementary.window import StandardWindow
from efl.elementary.box import Box
from efl.elementary.button import Button
from efl.elementary.frame import Frame
from efl.elementary.list import List
from efl.elementary.icon import Icon
from efl.elementary.slider import Slider
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
EXPAND_VERT = 0.0, EVAS_HINT_EXPAND
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
FILL_HORIZ = EVAS_HINT_FILL, 0.5
FILL_VERT = 0.5, EVAS_HINT_FILL
ALIGN_CENTER = 0.5, 0.5
ZERO_WEIGHT = 0.0, 0.0
script_path = os.path.dirname(os.path.abspath(__file__))
img_path = os.path.join(script_path, "images")
def delay_change_cb(obj, data=None):
print("delay,changed! slider value : %d" % round(obj.value))
def change_cb(obj, data=None):
data.value = obj.value
def change_print_cb(obj, data=None):
print("change to %3.3f" % obj.value)
def bt_0(obj, data=None):
data.value = 0.0
def bt_1(obj, data=None):
data.value = 1.0
def bt_p1(obj, data=None):
data.value += 0.1
def bt_m1(obj, data=None):
data.value -= 0.1
def step_size_calculate(min_size, max_size):
steps = max_size - min_size
if steps:
step = (1.0 / steps)
return step
def slider_clicked(obj):
win = StandardWindow("slider", "Slider", autodel=True)
if obj is None:
win.callback_delete_request_add(lambda x: elementary.exit())
win.show()
fr = Frame(win, size_hint_weight=EXPAND_BOTH, style="pad_large")
win.resize_object_add(fr)
fr.show()
bx = Box(win)
fr.content = bx
bx.show()
# disabled horizontal slider
ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
ic.show()
sl = Slider(bx, text="Disabled", unit_format="%1.1f units", span_size=120,
min_max=(50, 150), value=80, disabled=True, size_hint_align=FILL_HORIZ,
size_hint_weight=EXPAND_HORIZ)
sl.part_content_set("icon", ic)
bx.pack_end(sl)
sl.show()
#TODO: step = step_size_calculate(0, 9)
sl = Slider(bx, unit_format="%1.0f units", indicator_format="%1.0f",
span_size=120, min_max=(0, 9), text="Manual step (TODO)", #TODO: step=step,
size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ)
bx.pack_end(sl)
sl.show()
# normal horizontal slider
ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
sl1 = sl = Slider(bx, text="Horizontal", unit_format="%1.1f units",
indicator_format="%1.1f", span_size=120, size_hint_align=FILL_HORIZ,
size_hint_weight=EXPAND_HORIZ)
sl.part_content_set("icon", ic)
bx.pack_end(sl)
ic.show()
sl.show()
# horizontally inverted slider
ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
ic.show()
sl = Slider(bx, text="Horizontal inverted", unit_format="%3.0f units",
span_size=80, indicator_format="%3.0f", min_max=(50, 150), value=80,
inverted=True, size_hint_align=ALIGN_CENTER,
size_hint_weight=(0.0, 0.0))
sl.part_content_set("end", ic)
sl.callback_delay_changed_add(delay_change_cb)
bx.pack_end(sl)
sl.show()
# disabled horizontally inverted slider
ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
ic.show()
sl = Slider(bx, text="Disabled inverted", span_size=80,
indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True,
disabled=True, size_hint_align=ALIGN_CENTER,
size_hint_weight=(0.0, 0.0))
sl.part_content_set("end", ic)
bx.pack_end(sl)
sl.show()
# scale doubled slider
sl = Slider(bx, indicator_show=False, text="Scale doubled",
unit_format="%3.0f units", span_size=40, size_hint_align=FILL_HORIZ,
size_hint_weight=EXPAND_HORIZ, indicator_format="%3.0f",
min_max=(50, 150), value=80, inverted=True, scale=2.0)
bx.pack_end(sl)
sl.show()
# horizontal box
bx2 = Box(bx, size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_VERT, horizontal=True)
bx.pack_end(bx2)
bx2.show()
# vertical inverted slider
ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1))
ic.show()
sl = Slider(bx2, text="Vertical inverted", inverted=True,
unit_format="%1.1f units", span_size=60,
size_hint_align=FILL_VERT,
size_hint_weight=EXPAND_VERT,
indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False)
sl.part_content_set("icon", ic)
bx2.pack_end(sl)
sl.show()
sl1.callback_changed_add(change_cb, sl)
# disabled vertical slider
ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"),
size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1))
sl = Slider(bx2, text="Disabled vertical", inverted=True,
unit_format="%1.1f units", span_size=100,
size_hint_align=FILL_VERT,
size_hint_weight=EXPAND_VERT,
indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False)
#
# XXX: If vertical mode is set after disabled, it's no longer disabled.
# Elm bug?
#
sl.disabled = True
sl.part_content_set("icon", ic)
bx2.pack_end(sl)
sl.show()
# normal vertical slider
sl = Slider(bx2, text="Vertical", unit_format="%1.1f units", span_size=60,
size_hint_align=FILL_VERT,
size_hint_weight=EXPAND_VERT, indicator_show=False,
value=0.2, scale=1.0, horizontal=False)
sl.callback_changed_add(change_print_cb, sl)
bx2.pack_end(sl)
sl.show()
# box for bottom buttons
bx2 = Box(win,size_hint_weight=EXPAND_HORIZ, horizontal=True)
bx.pack_end(bx2)
bx2.show()
bt = Button(win, text="0")
bt.callback_clicked_add(bt_0, sl)
bt.show()
bx2.pack_end(bt)
bt = Button(win, text="1")
bt.callback_clicked_add(bt_1, sl)
bt.show()
bx2.pack_end(bt)
bt = Button(win, text="+0.1")
bt.callback_clicked_add(bt_p1, sl)
bt.show()
bx2.pack_end(bt)
bt = Button(win, text="-0.1")
bt.callback_clicked_add(bt_m1, sl)
bt.show()
bx2.pack_end(bt)
if __name__ == "__main__":
elementary.init()
slider_clicked(None)
elementary.run()
elementary.shutdown()