python-efl/eolian-example.py

50 lines
995 B
Python
Executable File

#!/usr/bin/python
import logging
efllog = logging.getLogger("efl")
efllog.addHandler(logging.StreamHandler())
import sys
if len(sys.argv) < 2:
sys.exit("Usage: %s <file1> [file2] ... [fileN]".format(sys.argv[0]))
w, h = 600, 600
from efl import elementary as elm
elm.init()
win = elm.Win("pydemo", 1)
win.title = "Python demo"
win.autodel = False
win.size = (w, h)
win.event_callback_add("delete,request", lambda x, y: elm.exit())
bg = elm.Bg(win)
bg.size_hint_weight = (1.0, 1.0)
win.resize_object_add(bg)
bg.show()
img = elm.Image(win)
img.size_hint_weight = (1.0, 1.0)
img.smooth = True
img.aspect_fixed = True
img.file = sys.argv[1], ""
img.position = (0, 0)
img.size = (w, h)
file_idx = 1
def _mouse_down_cb(*args):
global file_idx
file_idx += 1
if file_idx > len(sys.argv):
file_idx = 1
global img
img.file = sys.argv[file_idx], ""
return True
img.event_callback_add("mouse,down", _mouse_down_cb)
img.show()
win.show()
elm.run()
elm.shutdown()