391 lines
9.9 KiB
Python
391 lines
9.9 KiB
Python
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
from efl import evas
|
|
from efl import elementary
|
|
from efl.elementary.window import Window
|
|
from efl.elementary.background import Background
|
|
from efl.elementary.box import Box
|
|
from efl.elementary.button import Button
|
|
from efl.elementary.frame import Frame
|
|
from efl.elementary.label import Label
|
|
from efl.elementary.list import List
|
|
from efl.elementary.icon import Icon
|
|
from efl.elementary.table import Table
|
|
|
|
|
|
def my_list_show_it(obj, it):
|
|
it.show()
|
|
|
|
def list_clicked(obj, item=None):
|
|
win = Window("list", elementary.ELM_WIN_BASIC)
|
|
win.title_set("List")
|
|
win.autodel_set(True)
|
|
|
|
bg = Background(win)
|
|
win.resize_object_add(bg)
|
|
bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bg.show()
|
|
|
|
li = List(win)
|
|
win.resize_object_add(li)
|
|
li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(1, 1)
|
|
it1 = li.item_append("Hello", ic)
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
li.item_append("Hello", ic)
|
|
ic = Icon(win)
|
|
ic.standard_set("edit")
|
|
ic.resizable_set(0, 0)
|
|
ic2 = Icon(win)
|
|
ic2.standard_set("clock")
|
|
ic2.resizable_set(0, 0)
|
|
li.item_append(".", ic, ic2)
|
|
|
|
ic = Icon(win)
|
|
ic.standard_set("delete")
|
|
ic.resizable_set(0, 0)
|
|
ic2 = Icon(win)
|
|
ic2.standard_set("clock")
|
|
ic2.resizable_set(0, 0)
|
|
it2 = li.item_append("How", ic, ic2)
|
|
|
|
bx = Box(win)
|
|
bx.horizontal_set(True)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.5)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.0)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
li.item_append("are")
|
|
|
|
li.item_append("you")
|
|
it3 = li.item_append("doing")
|
|
li.item_append("out")
|
|
li.item_append("there")
|
|
li.item_append("today")
|
|
li.item_append("?")
|
|
it4 = li.item_append("Here")
|
|
li.item_append("are")
|
|
li.item_append("some")
|
|
li.item_append("more")
|
|
li.item_append("items")
|
|
li.item_append("Is this label long enough?")
|
|
it5 = li.item_append("Maybe this one is even longer so we can test long long items.")
|
|
|
|
li.go()
|
|
|
|
li.show()
|
|
|
|
tb2 = Table(win)
|
|
tb2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
win.resize_object_add(tb2)
|
|
|
|
bt = Button(win)
|
|
bt.text_set("Hello")
|
|
bt.callback_clicked_add(my_list_show_it, it1)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bt.size_hint_align_set(0.9, 0.5)
|
|
tb2.pack(bt, 0, 0, 1, 1);
|
|
bt.show()
|
|
|
|
bt = Button(win)
|
|
bt.text_set("How")
|
|
bt.callback_clicked_add(my_list_show_it, it2)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bt.size_hint_align_set(0.9, 0.5)
|
|
tb2.pack(bt, 0, 1, 1, 1);
|
|
bt.show()
|
|
|
|
bt = Button(win)
|
|
bt.text_set("doing")
|
|
bt.callback_clicked_add(my_list_show_it, it3)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bt.size_hint_align_set(0.9, 0.5)
|
|
tb2.pack(bt, 0, 2, 1, 1);
|
|
bt.show()
|
|
|
|
bt = Button(win)
|
|
bt.text_set("Here")
|
|
bt.callback_clicked_add(my_list_show_it, it4)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bt.size_hint_align_set(0.9, 0.5)
|
|
tb2.pack(bt, 0, 3, 1, 1);
|
|
bt.show()
|
|
|
|
bt = Button(win)
|
|
bt.text_set("Maybe this...")
|
|
bt.callback_clicked_add(my_list_show_it, it5)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bt.size_hint_align_set(0.9, 0.5)
|
|
tb2.pack(bt, 0, 4, 1, 1);
|
|
bt.show()
|
|
|
|
tb2.show()
|
|
|
|
win.resize(320, 320)
|
|
win.show()
|
|
|
|
|
|
def my_list2_clear(bt, li):
|
|
li.clear()
|
|
|
|
def my_list2_sel(obj, it):
|
|
it = obj.selected_item_get()
|
|
if it is not None:
|
|
it.selected_set(False)
|
|
|
|
def list2_clicked(obj, item=None):
|
|
win = Window("list-2", elementary.ELM_WIN_BASIC)
|
|
win.title_set("List 2")
|
|
win.autodel_set(True)
|
|
|
|
bg = Background(win)
|
|
bg.file_set('images/plant_01.jpg')
|
|
win.resize_object_add(bg)
|
|
bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bg.show()
|
|
|
|
bx = Box(win)
|
|
bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
win.resize_object_add(bx)
|
|
bx.show()
|
|
|
|
li = List(win)
|
|
li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
|
|
li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
li.mode_set(elementary.ELM_LIST_LIMIT)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
it = li.item_append("Hello", ic, callback=my_list2_sel)
|
|
it.selected_set(True)
|
|
ic = Icon(win)
|
|
ic.resizable_set(0, 0)
|
|
ic.file_set('images/logo_small.png')
|
|
li.item_append("world", ic)
|
|
ic = Icon(win)
|
|
ic.standard_set("edit")
|
|
ic.resizable_set(0, 0)
|
|
li.item_append(".", ic)
|
|
|
|
ic = Icon(win)
|
|
ic.standard_set("delete")
|
|
ic.resizable_set(0, 0)
|
|
ic2 = Icon(win)
|
|
ic2.standard_set("clock")
|
|
ic2.resizable_set(0, 0)
|
|
it2 = li.item_append("How", ic, ic2)
|
|
|
|
bx2 = Box(win)
|
|
bx2.horizontal_set(True)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.5)
|
|
bx2.pack_end(ic)
|
|
ic.show()
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.0)
|
|
bx2.pack_end(ic)
|
|
ic.show()
|
|
|
|
li.item_append("are", bx2)
|
|
|
|
li.item_append("you")
|
|
li.item_append("doing")
|
|
li.item_append("out")
|
|
li.item_append("there")
|
|
li.item_append("today")
|
|
li.item_append("?")
|
|
li.item_append("Here")
|
|
li.item_append("are")
|
|
li.item_append("some")
|
|
li.item_append("more")
|
|
li.item_append("items")
|
|
li.item_append("Longer label.")
|
|
|
|
li.go()
|
|
|
|
bx.pack_end(li)
|
|
li.show()
|
|
|
|
bx2 = Box(win)
|
|
bx2.horizontal_set(True)
|
|
bx2.homogeneous_set(True)
|
|
bx2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
|
|
bx2.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
|
|
|
|
bt = Button(win)
|
|
bt.text_set("Clear")
|
|
bt.callback_clicked_add(my_list2_clear, li)
|
|
bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
|
|
bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
|
|
bx2.pack_end(bt)
|
|
bt.show()
|
|
|
|
bx.pack_end(bx2)
|
|
bx2.show()
|
|
|
|
win.resize(320, 320)
|
|
win.show()
|
|
|
|
|
|
def list3_clicked(obj, item=None):
|
|
win = Window("list-3", elementary.ELM_WIN_BASIC)
|
|
win.title_set("List 3")
|
|
win.autodel_set(True)
|
|
|
|
bg = Background(win)
|
|
win.resize_object_add(bg)
|
|
bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
bg.show()
|
|
|
|
li = List(win)
|
|
win.resize_object_add(li)
|
|
li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
li.mode_set(elementary.ELM_LIST_COMPRESS)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
li.item_append("Hello", ic)
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
li.item_append("world", ic)
|
|
ic = Icon(win)
|
|
ic.standard_set("edit")
|
|
ic.resizable_set(0, 0)
|
|
li.item_append(".", ic)
|
|
|
|
ic = Icon(win)
|
|
ic.standard_set("delete")
|
|
ic.resizable_set(0, 0)
|
|
ic2 = Icon(win)
|
|
ic2.standard_set("clock")
|
|
ic2.resizable_set(0, 0)
|
|
it2 = li.item_append("How", ic, ic2)
|
|
|
|
bx = Box(win)
|
|
bx.horizontal_set(True)
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.5)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.5, 0.0)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
|
|
ic = Icon(win)
|
|
ic.file_set('images/logo_small.png')
|
|
ic.resizable_set(0, 0)
|
|
ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
|
|
bx.pack_end(ic)
|
|
ic.show()
|
|
|
|
li.item_append("are", bx)
|
|
li.item_append("you")
|
|
li.item_append("doing")
|
|
li.item_append("out")
|
|
li.item_append("there")
|
|
li.item_append("today")
|
|
li.item_append("?")
|
|
li.item_append("Here")
|
|
li.item_append("are")
|
|
li.item_append("some")
|
|
li.item_append("more")
|
|
li.item_append("items")
|
|
li.item_append("Is this label long enough?")
|
|
it5 = li.item_append("Maybe this one is even longer so we can test long long items.")
|
|
|
|
li.go()
|
|
|
|
li.show()
|
|
|
|
win.resize(320, 300)
|
|
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()
|
|
|
|
box0 = Box(win)
|
|
box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
|
|
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()
|
|
|
|
items = [("List", list_clicked),
|
|
("List 2", list2_clicked),
|
|
("List 3", list3_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)
|
|
box0.pack_end(li)
|
|
li.show()
|
|
|
|
for item in items:
|
|
li.item_append(item[0], callback=item[1])
|
|
|
|
li.go()
|
|
|
|
win.resize(320,520)
|
|
win.show()
|
|
elementary.run()
|
|
elementary.shutdown()
|