def outlines_populate(self, outlines, parent=None): for outline in outlines: if isinstance(outline, list): GenlistItem(oll_glic, outline, parent, ELM_GENLIST_ITEM_TREE).append_to(self.ol_gl) else: GenlistItem(ol_glic, outline, parent, ELM_GENLIST_ITEM_NONE, self._outline_clicked_cb, outline).append_to(self.ol_gl)
def genlist15_clicked(obj, item=None): win = StandardWindow("genlist-decorate-all-mode", "Genlist Decorate All Mode", autodel=True, size=(520, 520)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) gl.show() itc15 = ItemClass15(item_style="default", decorate_all_item_style="edit") itc15.state_get = gl_state_get for i in range(100): ck = Check(gl) data = [i, False] it = GenlistItem( item_class=itc15, item_data=data, parent_item=None, flags=ELM_GENLIST_ITEM_NONE, func=gl15_sel, func_data=data, ).append_to(gl) data.append(it) bx.pack_end(gl) bx.show() bx2 = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt = Button(win, text="Decorate All mode", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(gl15_deco_all_mode, gl) bx2.pack_end(bt) bt.show() bt = Button(win, text="Normal mode", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(gl15_normal_mode, gl) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() win.show()
def __init__(self): StandardWindow.__init__(self, "ex11", "Genlist List", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourList = Genlist(self) ourList.size_hint_weight = EXPAND_BOTH ourList.callback_activated_add(self.listItemSelected) ListItems.sort() for it in ListItems: li = GenlistItem(item_data={"itemName": it}, item_class=GLIC()) li.append_to(ourList) ourList.show() self.resize_object_add(ourList)
def __init__(self): StandardWindow.__init__(self, "ex11", "Genlist List", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourList = Genlist(self) ourList.size_hint_weight = EXPAND_BOTH ourList.callback_activated_add(self.listItemSelected) ListItems.sort() for it in ListItems: li = GenlistItem(item_data={"itemName":it}, item_class=GLIC()) li.append_to(ourList) ourList.show() self.resize_object_add(ourList)
def genlist10_clicked(obj, item=None): win = StandardWindow("genlist-decorate-item-mode", "Genlist Decorate Item Mode", autodel=True, size=(520, 520)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bx2 = Box(win) bx2.show() fr = Frame(win, text="Decorate Item Mode Type", content=bx2) bx.pack_end(fr) fr.show() rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=0, text="Slide : Sweep genlist items to the right.") rd.show() bx2.pack_end(rd) rdg = rd rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=1, text="Rotate : Click each item.") rd.group_add(rdg) rd.show() bx2.pack_end(rd) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) gl.callback_drag_start_right_add(my_gl_mode_right, rdg) gl.callback_drag_start_left_add(my_gl_mode_left, rdg) gl.callback_drag_start_up_add(my_gl_mode_cancel, rdg) gl.callback_drag_start_down_add(my_gl_mode_cancel, rdg) gl.show() itc10 = ItemClass10(item_style="default", decorate_item_style="mode") itc10.state_get = gl_state_get for i in range(1000, 1050): GenlistItem(item_class=itc10, item_data=i, parent_item=None, flags=ELM_GENLIST_ITEM_NONE, func=gl_sel10, func_data=(i, rdg)).append_to(gl) bx.pack_end(gl) win.size = 520, 520 win.show()
def genlist5_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist iteration test", autodel=True, size=(320, 320)) gl = Genlist(win, homogeneous=True, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(gl) gl.show() itc_i = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) item_count = 10000 t1 = time.time() for i in range(item_count): GenlistItem(itc_i, i).append_to(gl) t2 = time.time() assert (len(gl) == gl.items_count) t3 = time.time() it = gl.first_item while it: d = it.data it = it.next t4 = time.time() assert (d == item_count - 1) t5 = time.time() for it in gl: e = it.data t6 = time.time() assert (e == item_count - 1) assert (it in gl) print("Time to add {0} items:".format(item_count)) print(t2 - t1) print("Time to iterate item data over {0} items using " "it.next:".format(item_count)) print(t4 - t3) print("Time to iterate item data over {0} items using " "a python iterator:".format(item_count)) print(t6 - t5) win.show()
def packFileFolder(self, ourPath, d, isDir): if isDir: li = GenlistItem(item_data={"type": "dir", "path": ourPath, "d": d}, item_class=dirglic, func=self.listItemSelected) else: li = GenlistItem(item_data={"type": "file", "path": ourPath, "d": d}, item_class=fileglic, func=self.listItemSelected) li.append_to(self.fileList)
def genlist4_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist sorted insert test", autodel=True, size=(320, 320)) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(gl) gl.show() itc_i = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) for i in range(100, -1, -1): GenlistItem(itc_i, i).sorted_insert(gl, gl_comp_func) win.show()
def floating_clicked(obj): win = StandardWindow("floating", "Floating", autodel=True, size=(480, 800)) gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, pos=(800, 0), size=(480, 800)) gl.show() for i in range(20): GenlistItem(ItemClass(), i, None, ELM_GENLIST_ITEM_NONE, gl_sel_cb, i).append_to(gl) win.show() ani = Animator(anim, gl) win.callback_delete_request_add(del_cb, ani) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit())
def pack_all(self, path, name, is_dir): '''Append to genlist''' if is_dir: gen_lst_it = GenlistItem(item_data={ 'type': 'dir', 'path': path, 'd': name }, item_class=DIRGLIC, func=self.list_it_selected) else: gen_lst_it = GenlistItem(item_data={ 'type': 'file', 'path': path, 'd': name }, item_class=FILEGLIC, func=self.list_it_selected) gen_lst_it.append_to(self.file_lst)