Beispiel #1
0
def genlist_clicked(obj, item=None):
    win = StandardWindow("Genlist", "Genlist test", autodel=True)

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    gl.callback_selected_add(_gl_selected,
                             "arg1",
                             "arg2",
                             kwarg1="kwarg1",
                             kwarg2="kwarg2")
    gl.callback_clicked_double_add(_gl_clicked_double,
                                   "arg1",
                                   "arg2",
                                   kwarg1="kwarg1",
                                   kwarg2="kwarg2")
    gl.callback_longpressed_add(_gl_longpressed,
                                "arg1",
                                "arg2",
                                kwarg1="kwarg1",
                                kwarg2="kwarg2")
    bx.pack_end(gl)
    gl.show()

    over = Rectangle(win.evas_get())
    over.color_set(0, 0, 0, 0)
    over.event_callback_add(evas.EVAS_CALLBACK_MOUSE_DOWN, _gl_over_click, gl)
    over.repeat_events_set(True)
    over.show()
    over.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(over)

    vbx = Box(win, horizontal=True)
    bx.pack_end(vbx)
    vbx.show()

    itc1 = GenlistItemClass(item_style="default",
                            text_get_func=gl_text_get,
                            content_get_func=gl_content_get,
                            state_get_func=gl_state_get)

    bt_50 = Button(win, text="Go to 50")
    vbx.pack_end(bt_50)
    bt_50.show()

    bt_1500 = Button(win, text="Go to 1500")
    vbx.pack_end(bt_1500)
    bt_1500.show()

    for i in range(0, 2000):
        gli = gl.item_append(itc1, i, func=gl_item_sel)
        if i == 50:
            bt_50._callback_add("clicked", lambda bt, it: it.bring_in(), gli)
        elif i == 1500:
            bt_1500._callback_add("clicked", lambda bt, it: it.bring_in(), gli)

    win.resize(480, 800)
    win.show()
def core_evas_canvas_callbacks_clicked(obj, item=None):
    win = StandardWindow("evascanvascbs",
                         "Evas canvas callbacks",
                         autodel=True,
                         size=(320, 320))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    text = Text(win.evas,
                text="Events printed on console",
                size=(300, 30),
                color=(0, 0, 0, 255))
    text.font_set("Sans", 12)
    text.pos = (10, 10)
    text.show()

    canvas = win.evas_get()
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN, events_cb1,
                              "EVAS_CALLBACK_CANVAS_FOCUS_IN")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT, events_cb1,
                              "EVAS_CALLBACK_CANVAS_FOCUS_OUT")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, events_cb2,
                              "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
                              events_cb2,
                              "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT")

    canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE, events_cb1,
                              "EVAS_CALLBACK_RENDER_FLUSH_PRE")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST, events_cb1,
                              "EVAS_CALLBACK_RENDER_FLUSH_POST")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_PRE, events_cb1,
                              "EVAS_CALLBACK_RENDER_PRE")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_POST, events_cb1,
                              "EVAS_CALLBACK_RENDER_POST")

    r2 = Rectangle(win.evas,
                   size=(120, 70),
                   color=(0, 100, 0, 100),
                   pos=(70, 70))
    r2.show()

    hbox = Box(win,
               size_hint_weight=EXPAND_BOTH,
               size_hint_align=FILL_BOTH,
               horizontal=True)
    win.resize_object_add(hbox)
    hbox.show()

    b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0))
    hbox.pack_end(b)
    b.callback_clicked_add(btn_del_cbs_cb)
    b.show()

    win.show()
def genlist_clicked(obj, item=None):
    win = StandardWindow("Genlist", "Genlist test", autodel=True)

    bx = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bx)
    bx.show()

    gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    gl.callback_selected_add(_gl_selected, "arg1", "arg2",
        kwarg1="kwarg1", kwarg2="kwarg2")
    gl.callback_clicked_double_add(_gl_clicked_double, "arg1", "arg2",
        kwarg1="kwarg1", kwarg2="kwarg2")
    gl.callback_longpressed_add(_gl_longpressed, "arg1", "arg2",
        kwarg1="kwarg1", kwarg2="kwarg2")
    bx.pack_end(gl)
    gl.show()

    over = Rectangle(win.evas_get())
    over.color_set(0, 0, 0, 0)
    over.event_callback_add(evas.EVAS_CALLBACK_MOUSE_DOWN, _gl_over_click, gl)
    over.repeat_events_set(True)
    over.show()
    over.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(over)

    vbx = Box(win, horizontal=True)
    bx.pack_end(vbx)
    vbx.show()

    itc1 = GenlistItemClass(item_style="default",
                            text_get_func=gl_text_get,
                            content_get_func=gl_content_get,
                            state_get_func=gl_state_get)

    bt_50 = Button(win, text="Go to 50")
    vbx.pack_end(bt_50)
    bt_50.show()

    bt_1500 = Button(win, text="Go to 1500")
    vbx.pack_end(bt_1500)
    bt_1500.show()

    for i in range(0, 2000):
        gli = gl.item_append(itc1, i, func=gl_item_sel)
        if i == 50:
            bt_50._callback_add("clicked", lambda bt, it: it.bring_in(), gli)
        elif i == 1500:
            bt_1500._callback_add("clicked", lambda bt, it: it.bring_in(), gli)

    win.resize(480, 800)
    win.show()
def core_evas_canvas_callbacks_clicked(obj, item=None):
    win = StandardWindow("evascanvascbs", "Evas canvas callbacks", autodel=True,
        size=(320,320))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    text = Text(win.evas, text="Events printed on console", size=(300, 30),
        color=(0,0,0,255))
    text.font_set("Sans", 12)
    text.pos = (10, 10)
    text.show()

    canvas = win.evas_get()
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_IN,
        events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_IN")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_FOCUS_OUT,
        events_cb1, "EVAS_CALLBACK_CANVAS_FOCUS_OUT")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
        events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN")
    canvas.event_callback_add(EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
        events_cb2, "EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT")

    canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_PRE,
        events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_PRE")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_FLUSH_POST,
        events_cb1, "EVAS_CALLBACK_RENDER_FLUSH_POST")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_PRE,
        events_cb1, "EVAS_CALLBACK_RENDER_PRE")
    canvas.event_callback_add(EVAS_CALLBACK_RENDER_POST,
        events_cb1, "EVAS_CALLBACK_RENDER_POST")

    r2 = Rectangle(win.evas, size=(120,70), color=(0,100,0,100), pos=(70,70))
    r2.show()

    hbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
        horizontal=True)
    win.resize_object_add(hbox)
    hbox.show()

    b = Button(win, text="del cbs", size_hint_align=(0.5, 1.0))
    hbox.pack_end(b)
    b.callback_clicked_add(btn_del_cbs_cb)
    b.show()

    win.show()
def menu_clicked(obj):
    win = StandardWindow("menu", "Menu test", autodel=True, size=(350, 200))
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    rect = Rectangle(win.evas_get(), color=(0, 0, 0, 0))
    win.resize_object_add(rect)
    rect.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
    rect.show()

    menu = Menu(win)
    item = menu.item_add(None, "first item", "clock")
    item = menu.item_add(None, "second item", "mail-send")
    menu_populate_1(menu, item)

    menu.item_add(item, "sub menu", "refresh")

    rect.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, menu_show, menu)

    win.show()