def access_clicked(obj, item=None): win = StandardWindow("access", "Access") win.autodel = True win.on_free_add(cleanup_cb) config.access = True bx = Box(win, size_hint_weight=EXPAND_BOTH, homogeneous=True, horizontal=True) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(gl) gl.show() gl.callback_realized_add(_realized) itc1 = GLItC1(item_style="default") itc2 = GLItC2(item_style="full") for i in range(1, 9): if i % 4: gl.item_append(itc1, i, None, ELM_GENLIST_ITEM_NONE) else: gl.item_append(itc2, i, None, ELM_GENLIST_ITEM_NONE) itc1.free() itc2.free() win.resize(500, 400) win.show()
def access_clicked(obj, item=None): win = StandardWindow("access", "Access") win.autodel = True win.on_free_add(cleanup_cb) config.access = True bx = Box(win, size_hint_weight=EXPAND_BOTH, homogeneous=True, horizontal=True) win.resize_object_add(bx) bx.show() gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(gl) gl.show() gl.callback_realized_add(_realized) itc1 = GLItC1(item_style="default") itc2 = GLItC2(item_style="full") for i in range(1,9): if i % 4: gl.item_append(itc1, i, None, ELM_GENLIST_ITEM_NONE) else: gl.item_append(itc2, i, None, ELM_GENLIST_ITEM_NONE) itc1.free() itc2.free() win.resize(500, 400) win.show()
def dnd_genlist_user_anim_clicked(obj, item=None): win = StandardWindow("dnd-genlist-user-anim", "DnD-Genlist-User-Anim", autodel=True, size=(680,800)) bxx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bxx) bxx.show() for j in range(2): gl = Genlist(win, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) # START Drag and Drop handling win.callback_delete_request_add(win_del, gl) gl.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, gl_item_getcb, dropcb=gl_dropcb) gl.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, gl_item_getcb, gl_data_getcb) # We add mouse-down, up callbacks to start/stop drag animation gl.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, gl_obj_mouse_down, gl) # END Drag and Drop handling # FIXME: This causes genlist to resize the horiz axis very slowly :( # Reenable this and resize the window horizontally, then try to resize it back #elm_genlist_mode_set(gl, ELM_LIST_LIMIT) bxx.pack_end(gl) gl.show() for i in range(20): gl.item_append(itc1, img[i % 9], flags=ELM_GENLIST_ITEM_NONE) win.show()
def genlist3_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist Group 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) itc_g = GenlistItemClass(item_style="group_index", text_get_func=glg_text_get, content_get_func=glg_content_get) for i in range(300): if i % 10 == 0: git = gl.item_append(itc_g, i/10, flags=ELM_GENLIST_ITEM_GROUP) git.select_mode_set(ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) gl.item_append(itc_i, i, git) win.show()
def genlist3_clicked(obj, item=None): win = StandardWindow("Genlist", "Genlist Group 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) itc_g = GenlistItemClass(item_style="group_index", text_get_func=glg_text_get, content_get_func=glg_content_get) for i in range(300): if i % 10 == 0: git = gl.item_append(itc_g, i / 10, flags=ELM_GENLIST_ITEM_GROUP) git.select_mode_set(ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) gl.item_append(itc_i, i, git) win.show()
def dnd_genlist_gengrid_clicked(obj, item=None): win = StandardWindow("dnd-genlist-gengrid", "DnD-Genlist-Gengrid", autodel=True, size=(680, 800)) bxx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bxx) bxx.show() gl = Genlist(win, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.callback_delete_request_add(win_del, gl) # START Drag and Drop handling gl.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, gl_item_getcb, dropcb=gl_dropcb) gl.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, gl_item_getcb, gl_dnd_default_anim_data_getcb) # END Drag and Drop handling # FIXME: This causes genlist to resize the horiz axis very slowly :( # Reenable this and resize the window horizontally, then try to resize it back #elm_genlist_mode_set(gl, ELM_LIST_LIMIT) bxx.pack_end(gl) gl.show() for i in range(20): gl.item_append(itc1, img[i % 9], flags=ELM_GENLIST_ITEM_NONE) grid = Gengrid(win, item_size=(conf.scale * 150, conf.scale * 150), horizontal=False, reorder_mode=False, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.callback_delete_request_add(win_del, grid) grid.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, grid_item_getcb, dropcb=grid_dropcb) grid.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, grid_item_getcb, grid_data_getcb) for i in range(20): grid.item_append(gic, img[i % 9]) bxx.pack_end(grid) grid.show() win.show()
def index_clicked(obj): win = StandardWindow("index", "Index test", autodel=True, size=(320, 480)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() # index idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) idx.callback_delay_changed_add(cb_idx_delay_changed) idx.callback_changed_add(cb_idx_changed) idx.callback_selected_add(cb_idx_selected) win.resize_object_add(idx) idx.show() # genlist itc = GenlistItemClass(item_style="default", text_get_func=gl_text_get) # content_get_func=gl_content_get, # state_get_func=gl_state_get) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(gl) gl.show() for i in 'ABCDEFGHILMNOPQRSTUVZ': for j in 'acegikmo': gl_item = gl.item_append(itc, i + j) if j == 'a': idx_item = idx.item_append(i, cb_idx_item, gl_item) idx_item.data["gl_item"] = gl_item idx.level_go(0) sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() ck = Check(win, text="autohide_disabled") ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="indicator_disabled") ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="horizontal") ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state)) hbox.pack_end(ck) ck.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 dnd_genlist_gengrid_clicked(obj, item=None): win = StandardWindow("dnd-genlist-gengrid", "DnD-Genlist-Gengrid", autodel=True, size=(680,800)) bxx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bxx) bxx.show() gl = Genlist(win, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.callback_delete_request_add(win_del, gl) # START Drag and Drop handling gl.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, gl_item_getcb, dropcb=gl_dropcb) gl.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, gl_item_getcb, gl_dnd_default_anim_data_getcb) # END Drag and Drop handling # FIXME: This causes genlist to resize the horiz axis very slowly :( # Reenable this and resize the window horizontally, then try to resize it back #elm_genlist_mode_set(gl, ELM_LIST_LIMIT) bxx.pack_end(gl) gl.show() for i in range(20): gl.item_append(itc1, img[i % 9], flags=ELM_GENLIST_ITEM_NONE) grid = Gengrid(win, item_size=(conf.scale * 150, conf.scale * 150), horizontal=False, reorder_mode=False, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.callback_delete_request_add(win_del, grid) grid.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, grid_item_getcb, dropcb=grid_dropcb) grid.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, grid_item_getcb, grid_data_getcb) for i in range(20): grid.item_append(gic, img[i % 9]) bxx.pack_end(grid) grid.show() win.show()
def dnd_genlist_user_anim_clicked(obj, item=None): win = StandardWindow("dnd-genlist-user-anim", "DnD-Genlist-User-Anim", autodel=True, size=(680, 800)) bxx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bxx) bxx.show() for j in range(2): gl = Genlist(win, multi_select=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) # START Drag and Drop handling win.callback_delete_request_add(win_del, gl) gl.drop_item_container_add(ELM_SEL_FORMAT_TARGETS, gl_item_getcb, dropcb=gl_dropcb) gl.drag_item_container_add(ANIM_TIME, DRAG_TIMEOUT, gl_item_getcb, gl_data_getcb) # We add mouse-down, up callbacks to start/stop drag animation gl.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, gl_obj_mouse_down, gl) # END Drag and Drop handling # FIXME: This causes genlist to resize the horiz axis very slowly :( # Reenable this and resize the window horizontally, then try to resize it back #elm_genlist_mode_set(gl, ELM_LIST_LIMIT) bxx.pack_end(gl) gl.show() for i in range(20): gl.item_append(itc1, img[i % 9], flags=ELM_GENLIST_ITEM_NONE) win.show()
def genlist2_clicked(obj, item=None): win = Window("Genlist", ELM_WIN_BASIC, title="Genlist test 2", autodel=True, size=(320, 320)) bg = Background(win, file=os.path.join(img_path, "plant_01.jpg"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(bg) bg.show() 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() itc1 = GenlistItemClass(item_style="default", text_get_func=gl_text_get, content_get_func=gl_content_get, state_get_func=gl_state_get) gl.item_append(itc1, 1001, func=gl_item_sel) gl.item_append(itc1, 1002, func=gl_item_sel) gl.item_append(itc1, 1003, func=gl_item_sel) gl.item_append(itc1, 1004, func=gl_item_sel) gl.item_append(itc1, 1005, func=gl_item_sel) gl.item_append(itc1, 1006, func=gl_item_sel) gl.item_append(itc1, 1007, func=gl_item_sel) bx.pack_end(gl) bx2 = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) def my_gl_first(bt, gl): gli = gl.first_item if gli: gli.show() gli.selected = True bt = Button(win, text="/\\", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_first, gl) bx2.pack_end(bt) bt.show() def my_gl_last(bt, gl): gli = gl.last_item_get() if gli: gli.show() gli.selected = True bt = Button(win, text="\\/", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_last, gl) bx2.pack_end(bt) bt.show() def my_gl_disable(bt, gl): gli = gl.selected_item if gli: gli.disabled = True gli.selected = False gli.update() else: print("no item selected") bt = Button(win, text="#", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_disable, gl) bx2.pack_end(bt) bt.show() def my_gl_update_all(bt, gl): gli = gl.first_item_get() i = 0 while gli: gli.update() print(i) i = i + 1 gli = gli.next_get() bt = Button(win, text="U", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_update_all, gl) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() bx2 = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) def my_gl_clear(bt, gl): gl.clear() bt = Button(win, text="X", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_clear, gl) bx2.pack_end(bt) bt.show() class MyGlAdd: i = 0 def my_gl_add(bt, gl, itc1): gl.item_append(itc1, MyGlAdd.i, func=gl_item_sel) MyGlAdd.i = MyGlAdd.i + 1 bt = Button(win, text="+", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_add, gl, itc1) bx2.pack_end(bt) bt.show() def my_gl_del(bt, gl): gli = gl.selected_item_get() if gli: gli.delete() else: print("no item selected") bt = Button(win, text="-", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_del, gl) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() bx2 = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) class MyGlInsertBefore: i = 0 def my_gl_insert_before(bt, gl, itc1): gli = gl.selected_item_get() if gli: gl.item_insert_before(itc1, MyGlInsertBefore.i, gli, func=gl_item_sel) MyGlInsertBefore.i = MyGlInsertBefore.i + 1 else: print("no item selected") bt = Button(win, text="+ before", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_insert_before, gl, itc1) bx2.pack_end(bt) bt.show() class MyGlInsertAfter: i = 0 def my_gl_insert_after(bt, gl, itc1): gli = gl.selected_item_get() if gli: gl.item_insert_after(itc1, MyGlInsertAfter.i, gli, func=gl_item_sel) MyGlInsertAfter.i = MyGlInsertAfter.i + 1 else: print("no item selected") bt = Button(win, text="+ after", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_insert_after, gl, itc1) bx2.pack_end(bt) bt.show() def my_gl_flush(bt, gl): def my_gl_flush_delay(): cache_all_flush() Timer(1.2, my_gl_flush_delay) bt = Button(win, text="Flush", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(my_gl_flush, gl) bx2.pack_end(bt) bt.show() bx.pack_end(bx2) bx2.show() win.show()
class DiffViewer(Table): def __init__(self, parent, app): self.app = app self.commit = None self.win = parent Table.__init__(self, parent, padding=(5,5)) self.show() # description entry self.entry = Entry(self, text='Unknown', line_wrap=ELM_WRAP_MIXED, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, editable=False) self.pack(self.entry, 0, 0, 1, 1) self.entry.show() # gravatar picture self.picture = GravatarPict(self) self.picture.size_hint_align = 1.0, 0.0 self.picture.show() self.pack(self.picture, 1, 0, 1, 1) # action buttons box self.action_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1.0, 1.0)) self.pack(self.action_box, 0, 1, 2, 1) self.action_box.show() # panes panes = Panes(self, content_left_size = 0.3, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.pack(panes, 0, 2, 2, 1) panes.show() # file list self.itc = GenlistItemClass(item_style='default', text_get_func=self._gl_text_get, content_get_func=self._gl_content_get) self.diff_list = Genlist(self, homogeneous=True, mode=ELM_LIST_COMPRESS, select_mode=ELM_OBJECT_SELECT_MODE_ALWAYS, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.diff_list.callback_selected_add(self._list_selected_cb) panes.part_content_set('left', self.diff_list) # diff entry self.diff_entry = DiffedEntry(self) panes.part_content_set('right', self.diff_entry) def _gl_text_get(self, li, part, item_data): if isinstance(item_data, tuple): # in real commits mod, staged, name, new = item_data else: # in local changes (item_data is the path) mod, staged, name, new = self.app.repo.status.changes[item_data] return '{} → {}'.format(name, new) if new else name def _gl_content_get(self, li, part, item_data): if isinstance(item_data, tuple): # in real commits mod, staged, name, new = item_data else: # in local changes (item_data is the path) mod, staged, name, new = self.app.repo.status.changes[item_data] if part == 'elm.swallow.icon': return Icon(self, standard='git-mod-'+mod) elif part == 'elm.swallow.end' and staged is not None: ck = Check(self, state=staged, propagate_events=False) ck.callback_changed_add(self._stage_unstage_check_cb) ck.data['path'] = name return ck def update_action_buttons(self, buttons): self.action_box.clear() if 'checkout' in buttons: bt = Button(self, text='Checkout') bt.callback_clicked_add(lambda b: \ self.app.checkout_ref(self.commit.sha)) self.action_box.pack_end(bt) bt.show() if 'revert' in buttons: bt = Button(self, text='Revert') bt.callback_clicked_add(lambda b: \ CommitDialog(self.app, revert_commit=self.commit)) self.action_box.pack_end(bt) bt.show() if 'cherrypick' in buttons: bt = Button(self, text='Cherry-pick') bt.callback_clicked_add(lambda b: \ CommitDialog(self.app, cherrypick_commit=self.commit)) self.action_box.pack_end(bt) bt.show() if 'commit' in buttons: bt = Button(self, text='Commit', content=Icon(self, standard='git-commit')) bt.callback_clicked_add(lambda b: \ CommitDialog(self.app)) self.action_box.pack_end(bt) bt.show() if 'stash' in buttons: bt = Button(self, text='Stash', content=Icon(self, standard='git-stash')) bt.callback_clicked_add(lambda b: self.app.action_stash_save()) self.action_box.pack_end(bt) bt.show() if 'discard' in buttons: bt = Button(self, text='Discard', content=Icon(self, standard='user-trash')) bt.callback_clicked_add(lambda b: DiscardDialog(self.app)) self.action_box.pack_end(bt) bt.show() def show_commit(self, commit): self.commit = commit self.picture.email_set(commit.author_email) line1 = '<name>{}</name> <b>{}</b> {}<br>'.format(commit.sha[:9], commit.author, format_date(commit.commit_date)) line2 = line3 = line4 = '' if commit.committer and commit.committer != commit.author: line2 = '<name>Committed by:</name> <b>{}</b><br>'.format( commit.committer) if commit.title: line3 = '<bigger><b>{}</b></bigger><br>'.format( utf8_to_markup(commit.title.strip())) if commit.message: line4 = '<br>{}'.format(utf8_to_markup(commit.message.strip())) text = line1 + line2 + line3 + line4 self.entry.text = text self.update_action_buttons(['checkout', 'revert', 'cherrypick']) self.diff_entry.text = '' self.diff_list.clear() self.app.repo.request_changes(self._changes_done_cb, commit1=commit) def show_local_status(self): self.commit = None self.entry.text = '<bigger><b>Local status</b></bigger>' self.diff_entry.text = '' self.picture.email_set(None) self.update_action_buttons(['commit', 'stash', 'discard']) self.diff_list.clear() for path in sorted(self.app.repo.status.changes): self.diff_list.item_append(self.itc, path) def refresh_diff(self): if self.diff_list.selected_item: self._list_selected_cb(self.diff_list, self.diff_list.selected_item) def _stage_unstage_check_cb(self, check): path = check.data['path'] if check.state is True: self.app.repo.stage_file(self._stage_unstage_done_cb, path, path) else: self.app.repo.unstage_file(self._stage_unstage_done_cb, path, path) def _stage_unstage_done_cb(self, success, path): self.app.action_update_header() self.diff_list.realized_items_update() def _changes_done_cb(self, success, lines): for mod, name, new_name in lines: item_data = (mod, None, name, new_name) self.diff_list.item_append(self.itc, item_data) self.diff_list.first_item.selected = True def _list_selected_cb(self, li, item): if isinstance(item.data, tuple): # in real commits mod, staged, name, new = item.data else: # in local changes (item_data is the path) mod, staged, name, new = self.app.repo.status.changes[item.data] self.app.repo.request_diff(self._diff_done_cb, ref1=self.commit.sha if self.commit else None, path=name) self.diff_entry.line_wrap = \ ELM_WRAP_MIXED if options.diff_text_wrap else ELM_WRAP_NONE self.diff_entry.loading_set() def _diff_done_cb(self, lines, success): self.diff_entry.lines_set(lines)
def __init__(self, app): self.app = app Popup.__init__(self, app.win) # title self.part_text_set('title,text', 'Recent Repositories') self.part_content_set('title,icon', SafeIcon(self, 'egitu')) # main table tb = Table(self, padding=(0,4), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.content = tb tb.show() # sep sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH) tb.pack(sep, 0, 0, 1, 1) sep.show() # recent list itc = GenlistItemClass(item_style='no_icon', text_get_func=self._gl_text_get) li = Genlist(self, homogeneous=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) li.callback_selected_add(self._recent_selected_cb) recents = recent_history_get() if recents: for path in recents: li.item_append(itc, path) else: item = li.item_append(itc, None) item.disabled = True li.show() r = Rectangle(self.evas, color=(0,0,0,0), size_hint_min=(300,200), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(r, 0, 1, 1, 1) tb.pack(li, 0, 1, 1, 1) # sep sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH) tb.pack(sep, 0, 2, 1, 1) sep.show() # buttons bt = Button(self, text='Close') bt.callback_clicked_add(lambda b: self.delete()) self.part_content_set('button1', bt) bt = Button(self, text='Clone') bt.callback_clicked_add(self._clone_btn_cb) self.part_content_set('button2', bt) bt = Button(self, text='Open') bt.callback_clicked_add(self._load_btn_cb) self.part_content_set('button3', bt) # self.show()
class ComboBox(Entry): def __init__(self, parent, text=None, icon=None): Entry.__init__(self, parent, scrollable=True, single_line=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self.show() if text: self.text = text if icon: self.icon = icon ic = SafeIcon(self, 'go-down') ic.size_hint_min = 16, 16 # TODO file a bug for elm on phab ic.callback_clicked_add(self.activate) self.part_content_set('end', ic) self._itc = GenlistItemClass(item_style='default', text_get_func=self._gl_text_get, content_get_func=self._gl_content_get) self._list = Genlist(self) self._list.callback_selected_add(self._list_selected_cb) self._hover = Hover(self.parent, target=self) self._bg = Background(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) fr = Frame(self, style='pad_medium', size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) fr.content = self._list fr.show() self._table = Table(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._table.pack(self._bg, 0, 0, 1, 1) self._table.pack(fr, 0, 0, 1, 1) self._selected_func = None def callback_selected_add(self, func): self._selected_func = func @property def icon(self): return self.part_content_get('icon') @icon.setter def icon(self, icon): icon.size_hint_min = 16, 16 # TODO file a bug for elm on phab self.part_content_set('icon', icon) @property def guide(self): self.part_text_get('guide') @guide.setter def guide(self, text): self.part_text_set('guide', text) def item_append(self, label=None, icon=None, end=None): item_data = (label, icon, end) self._list.item_append(self._itc, item_data) def clear(self): self._list.clear() def activate(self, source=None): self.focus = False # :/ # TODO calculate this based on _list and parent size # print(self._list.size) # print(self._list.geometry) self._bg.size_hint_min = 0, 200 loc = self._hover.best_content_location_get(ELM_HOVER_AXIS_VERTICAL) self._hover.part_content_set(loc, self._table) self._hover.show() self._table.show() self._bg.show() self._list.show() def dismiss(self): self._hover.dismiss() def _list_selected_cb(self, gl, item): label, icon, end = item.data self.text = label if icon: self.icon = SafeIcon(self, icon) item.selected = False self.dismiss() if callable(self._selected_func): self._selected_func(self) def _gl_text_get(self, gl, part, item_data): label, icon, end = item_data return label def _gl_content_get(self, gl, part, item_data): label, icon, end = item_data if icon and part == 'elm.swallow.icon': return SafeIcon(gl, icon) elif end and part == 'elm.swallow.end': return SafeIcon(gl, end)
class MainWin(StandardWindow): def __init__(self, app): self.app = app self.prog_popup = None # the window StandardWindow.__init__(self, 'epack', 'Epack') self.autodel_set(True) self.callback_delete_request_add(lambda o: self.app.exit()) # main vertical box vbox = Box(self, size_hint_weight=EXPAND_BOTH) self.resize_object_add(vbox) vbox.show() ### header horiz box (inside a padding frame) frame = Frame(self, style='pad_medium', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(frame) frame.show() self.header_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) frame.content = self.header_box self.header_box.show() # genlist with archive content self.file_itc = GenlistItemClass(item_style="no_icon", text_get_func=gl_file_text_get) self.fold_itc = GenlistItemClass(item_style="one_icon", text_get_func=gl_fold_text_get, content_get_func=gl_fold_icon_get) self.file_list = Genlist(self, homogeneous=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.file_list.callback_expand_request_add(self._gl_expand_req_cb) self.file_list.callback_contract_request_add(self._gl_contract_req_cb) self.file_list.callback_expanded_add(self._gl_expanded_cb) self.file_list.callback_contracted_add(self._gl_contracted_cb) vbox.pack_end(self.file_list) self.file_list.show() ### footer table (inside a padding frame) frame = Frame(self, style='pad_medium', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(frame) frame.show() table = Table(frame) frame.content = table table.show() # FileSelectorButton self.fsb = DestinationButton(app, self) table.pack(self.fsb, 0, 0, 3, 1) self.fsb.show() sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ) table.pack(sep, 0, 1, 3, 1) sep.show() # extract button self.extract_btn = Button(table, text=_('Extract')) self.extract_btn.callback_clicked_add(self.extract_btn_cb) table.pack(self.extract_btn, 0, 2, 1, 2) self.extract_btn.show() sep = Separator(table, horizontal=False) table.pack(sep, 1, 2, 1, 2) sep.show() # delete-archive checkbox self.del_chk = Check(table, text=_('Delete archive after extraction'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) self.del_chk.callback_changed_add(self.del_check_cb) table.pack(self.del_chk, 2, 2, 1, 1) self.del_chk.show() # create-archive-folder checkbox self.create_folder_chk = Check(table, text=_('Create archive folder'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) table.pack(self.create_folder_chk, 2, 3, 1, 1) self.create_folder_chk.callback_changed_add( lambda c: self.update_fsb_label()) self.create_folder_chk.show() # set the correct ui state self.update_ui() # show the window self.resize(300, 380) self.show() def del_check_cb(self, check): self.app.delete_after_extract = check.state def update_ui(self, listing_in_progress=False): box = self.header_box box.clear() ui_disabled = True # file listing in progress if listing_in_progress: spin = Progressbar(box, style='wheel', pulse_mode=True) spin.pulse(True) spin.show() box.pack_end(spin) lb = Label(box, text=_('Reading archive, please wait...'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 0.5)) lb.show() box.pack_end(lb) # or header button else: if self.app.file_name is None: txt = _('No archive loaded, click to choose a file') else: ui_disabled = False txt = _('<b>Archive:</b> %s') % \ (os.path.basename(self.app.file_name)) lb = Label(box, text='<align=left>%s</align>' % txt) bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: \ FileSelectorInwin(self, _('Choose an archive'), self._archive_selected_cb, path=os.getcwd())) box.pack_end(bt) bt.show() # always show the about button sep = Separator(box) box.pack_end(sep) sep.show() ic = Icon(box, standard='dialog-info', size_hint_min=(24,24)) ic.callback_clicked_add(lambda i: InfoWin(self)) box.pack_end(ic) ic.show() for widget in (self.extract_btn, self.fsb, self.create_folder_chk, self.del_chk): widget.disabled = ui_disabled self.update_fsb_label() def _archive_selected_cb(self, path): if os.path.isfile(path): self.app.load_file(path) def update_fsb_label(self): if self.create_folder_chk.state is True: name = os.path.splitext(os.path.basename(self.app.file_name))[0] self.fsb.text = os.path.join(self.app.dest_folder, name) else: self.fsb.text = self.app.dest_folder or '' def show_error_msg(self, msg): pop = Popup(self, text=msg) pop.part_text_set('title,text', _('Error')) btn = Button(self, text=_('Continue')) btn.callback_clicked_add(lambda b: pop.delete()) pop.part_content_set('button1', btn) btn = Button(self, text=_('Exit')) btn.callback_clicked_add(lambda b: self.app.exit()) pop.part_content_set('button2', btn) pop.show() def tree_populate(self, file_list=None, parent=None): if file_list is not None: self.file_list.clear() self._file_list = file_list if parent is None: prefix = None # items must match this prefix to be listed fscount = 0 # folder must have this number of slashes dscount = 1 # files must have this number of slashes else: prefix = parent.data[:-1] fscount = prefix.count('/') + 1 dscount = fscount + 1 files = [] for path in self._file_list: if prefix and not path.startswith(prefix): continue if path.endswith('/'): if path.count('/') == dscount: self.file_list.item_append(self.fold_itc, path, parent, flags=ELM_GENLIST_ITEM_TREE) else: if path.count('/') == fscount: files.append(path) for path in files: self.file_list.item_append(self.file_itc, path, parent) def _gl_expand_req_cb(self, gl, item): item.expanded = True def _gl_expanded_cb(self, gl, item): self.tree_populate(None, item) def _gl_contract_req_cb(self, gl, item): item.expanded = False def _gl_contracted_cb(self, gl, item): item.subitems_clear() def extract_btn_cb(self, btn): self.prog_popup = None self.app.dest_folder = self.fsb.text self.app.extract_archive() def build_prog_popup(self): pp = Popup(self) pp.part_text_set('title,text', _('Extracting files, please wait...')) pp.show() vbox = Box(self) pp.part_content_set('default', vbox) vbox.show() lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(lb) lb.show() pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(pb) pb.show() bt = Button(pp, text=_('Cancel')) bt.callback_clicked_add(lambda b: self.app.abort_operation()) pp.part_content_set('button1', bt) self.prog_pbar = pb self.prog_label = lb self.prog_popup = pp def extract_progress(self, progress, cur_name): if self.prog_popup is None: self.build_prog_popup() self.prog_pbar.value = progress self.prog_label.text = cur_name def extract_finished(self): if self.prog_popup: self.prog_popup.delete() self.prog_popup = None def _open_fm_and_exit_cb(self, bt): utils.xdg_open(self.app.dest_folder) self.app.exit() def _open_term_and_exit_cb(self, bt): utils.open_in_terminal(self.app.dest_folder) self.app.exit() def ask_what_to_do_next(self): pop = Popup(self) pop.part_text_set('title,text', _('Extract completed')) box = Box(pop) pop.content = box box.show() lb = Label(pop, text=_('What to do next?'), size_hint_align=FILL_HORIZ) box.pack_end(lb) lb.show() btn = Button(pop, text=_('Open Filemanager'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_fm_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Open Terminal'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_term_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Close this popup'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: pop.delete()) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Exit'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.app.exit()) box.pack_end(btn) btn.show() pop.show()
class MainWin(StandardWindow): def __init__(self, app): self.app = app self.prog_popup = None # the window StandardWindow.__init__(self, 'epack', 'Epack') self.autodel_set(True) self.callback_delete_request_add(lambda o: self.app.exit()) ### main table (inside a padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(frame) frame.content = table = Table(frame) frame.show() ### header horiz box self.header_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) table.pack(self.header_box, 0, 0, 3, 1) self.header_box.show() # genlist with archive content (inside a small padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(frame, 0, 1, 3, 1) self.file_itc = GenlistItemClass(item_style="no_icon", text_get_func=self._gl_file_text_get) self.fold_itc = GenlistItemClass( item_style="one_icon", text_get_func=self._gl_fold_text_get, content_get_func=self._gl_fold_icon_get) self.file_list = Genlist(frame, homogeneous=True) self.file_list.callback_expand_request_add(self._gl_expand_req_cb) self.file_list.callback_contract_request_add(self._gl_contract_req_cb) self.file_list.callback_expanded_add(self._gl_expanded_cb) self.file_list.callback_contracted_add(self._gl_contracted_cb) frame.content = self.file_list frame.show() # rect hack to force a min size on the genlist r = evas.Rectangle(table.evas, size_hint_min=(250, 250), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(r, 0, 1, 3, 1) # FileSelectorButton self.fsb = DestinationButton(app, self) table.pack(self.fsb, 0, 2, 3, 1) self.fsb.show() sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ) table.pack(sep, 0, 3, 3, 1) sep.show() # extract button self.extract_btn = Button(table, text=_('Extract')) self.extract_btn.callback_clicked_add(self.extract_btn_cb) table.pack(self.extract_btn, 0, 4, 1, 2) self.extract_btn.show() sep = Separator(table, horizontal=False) table.pack(sep, 1, 4, 1, 2) sep.show() # delete-archive checkbox self.del_chk = Check(table, text=_('Delete archive after extraction'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) self.del_chk.callback_changed_add(self.del_check_cb) table.pack(self.del_chk, 2, 4, 1, 1) self.del_chk.show() # create-archive-folder checkbox self.create_folder_chk = Check(table, text=_('Create archive folder'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) table.pack(self.create_folder_chk, 2, 5, 1, 1) self.create_folder_chk.callback_changed_add( lambda c: self.update_fsb_label()) self.create_folder_chk.show() # set the correct ui state self.update_ui() # show the window self.show() def del_check_cb(self, check): self.app.delete_after_extract = check.state def update_ui(self, listing_in_progress=False): box = self.header_box box.clear() ui_disabled = True # file listing in progress if listing_in_progress: spin = Progressbar(box, style='wheel', pulse_mode=True) spin.pulse(True) spin.show() box.pack_end(spin) lb = Label(box, text=_('Reading archive, please wait...'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 0.5)) lb.show() box.pack_end(lb) # or header button else: if self.app.file_name is None: txt = _('No archive loaded, click to choose a file') else: ui_disabled = False txt = _('<b>Archive:</b> %s') % \ (os.path.basename(self.app.file_name)) txt = '<align=left>%s</align>' % txt lb = Label(box, ellipsis=True, text=txt) bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: \ FileSelectorInwin(self, _('Choose an archive'), self._archive_selected_cb, path=os.getcwd())) box.pack_end(bt) bt.show() # always show the about button sep = Separator(box) box.pack_end(sep) sep.show() ic = SafeIcon(box, 'help-about', size_hint_min=(24, 24)) ic.callback_clicked_add(lambda i: InfoWin(self)) box.pack_end(ic) ic.show() for widget in (self.extract_btn, self.fsb, self.create_folder_chk, self.del_chk): widget.disabled = ui_disabled self.update_fsb_label() def _archive_selected_cb(self, path): if os.path.isfile(path): self.app.load_file(path) def update_fsb_label(self): if self.create_folder_chk.state is True: name = os.path.splitext(os.path.basename(self.app.file_name))[0] self.fsb.text = os.path.join(self.app.dest_folder, name) else: self.fsb.text = self.app.dest_folder or '' def show_error_msg(self, msg): pop = Popup(self, text=msg) pop.part_text_set('title,text', _('Error')) btn = Button(self, text=_('Continue')) btn.callback_clicked_add(lambda b: pop.delete()) pop.part_content_set('button1', btn) btn = Button(self, text=_('Exit')) btn.callback_clicked_add(lambda b: self.app.exit()) pop.part_content_set('button2', btn) pop.show() def tree_populate(self, file_list=None, parent=None): if file_list is not None: self.file_list.clear() self._file_list = file_list if parent is None: prefix = None # items must match this prefix to be listed fscount = 0 # folder must have this number of slashes dscount = 1 # files must have this number of slashes else: prefix = parent.data[:-1] fscount = prefix.count('/') + 1 dscount = fscount + 1 files = [] for path in self._file_list: if prefix and not path.startswith(prefix): continue if path.endswith('/'): if path.count('/') == dscount: self.file_list.item_append(self.fold_itc, path, parent, flags=ELM_GENLIST_ITEM_TREE) else: if path.count('/') == fscount: files.append(path) for path in files: self.file_list.item_append(self.file_itc, path, parent) def _gl_fold_text_get(self, obj, part, item_data): return item_data[:-1].split('/')[-1] def _gl_fold_icon_get(self, obj, part, item_data): return SafeIcon(obj, 'folder') def _gl_file_text_get(self, obj, part, item_data): return item_data.split('/')[-1] def _gl_expand_req_cb(self, gl, item): item.expanded = True def _gl_expanded_cb(self, gl, item): self.tree_populate(None, item) def _gl_contract_req_cb(self, gl, item): item.expanded = False def _gl_contracted_cb(self, gl, item): item.subitems_clear() def extract_btn_cb(self, btn): self.prog_popup = None self.app.dest_folder = self.fsb.text self.app.extract_archive() def build_prog_popup(self): pp = Popup(self) pp.part_text_set('title,text', _('Extracting files, please wait...')) pp.show() vbox = Box(self) pp.part_content_set('default', vbox) vbox.show() lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(lb) lb.show() pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(pb) pb.show() bt = Button(pp, text=_('Cancel')) bt.callback_clicked_add(lambda b: self.app.abort_operation()) pp.part_content_set('button1', bt) self.prog_pbar = pb self.prog_label = lb self.prog_popup = pp def extract_progress(self, progress, cur_name): if self.prog_popup is None: self.build_prog_popup() self.prog_pbar.value = progress self.prog_label.text = cur_name def extract_finished(self): if self.prog_popup: self.prog_popup.delete() self.prog_popup = None def _open_fm_and_exit_cb(self, bt): utils.xdg_open(self.app.dest_folder) self.app.exit() def _open_term_and_exit_cb(self, bt): utils.open_in_terminal(self.app.dest_folder) self.app.exit() def ask_what_to_do_next(self): pop = Popup(self) pop.part_text_set('title,text', _('Extract completed')) box = Box(pop) pop.content = box box.show() lb = Label(pop, text=_('What to do next?'), size_hint_align=FILL_HORIZ) box.pack_end(lb) lb.show() btn = Button(pop, text=_('Open Filemanager'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_fm_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Open Terminal'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_term_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Close this popup'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: pop.delete()) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Exit'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.app.exit()) box.pack_end(btn) btn.show() pop.show()
class SignalReceiver(Frame): def __init__(self, parent): Frame.__init__(self, parent, text="Signals") self._parent = parent vbox = Box(self) vbox.show() self.content = vbox self.siglist = Genlist(self, homogeneous=True, mode=ELM_LIST_SCROLL) self.siglist.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND self.siglist.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self.siglist.callback_clicked_double_add(self.signal_clicked_cb) self.siglist.show() vbox.pack_end(self.siglist) self.itc = SignalItemClass() hbox = Box(self, horizontal=True) hbox.size_hint_align = 0.0, 0.5 hbox.show() vbox.pack_end(hbox) bt = Button(self, text='Clear') bt.callback_clicked_add(lambda b: self.siglist.clear()) hbox.pack_end(bt) bt.show() def scroll_on_signal_clicked_cb(chk): options.scroll_on_signal = chk.state ck = Check(self, text='Scroll on signal') ck.state = options.scroll_on_signal ck.callback_changed_add(scroll_on_signal_clicked_cb) hbox.pack_end(ck) ck.show() for b in session_bus, system_bus: b.add_signal_receiver(self.signal_cb, sender_keyword='sender', destination_keyword='dest', interface_keyword='iface', member_keyword='signal', path_keyword='path') def signal_cb(self, *args, **kargs): # print('*** SIGNAL RECEIVED ***') # print(json.dumps(args, indent=2)) # print(json.dumps(kargs, indent=2)) kargs['args'] = args item = self.siglist.item_append(self.itc, kargs) if options.scroll_on_signal is True: item.bring_in() if self.siglist.items_count > 200: self.siglist.first_item.delete() def signal_clicked_cb(self, gl, item): pp = Popup(self._parent) pp.part_text_set('title,text', 'Signal content') en = Entry(self, text=prettify_if_needed(item.data['args'])) en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL en.size_hint_min = 800, 800 # TODO: this should be respected :/ en.editable = False en.scrollable = True pp.content = en bt = Button(pp, text="Close") bt.callback_clicked_add(lambda b: pp.delete()) pp.part_content_set('button2', bt) def prettify_clicked_cb(chk): options.pretty_output = chk.state en.text = prettify_if_needed(item.data['args']) ck = Check(pp, text="Prettify") ck.state = options.pretty_output ck.callback_changed_add(prettify_clicked_cb) pp.part_content_set('button1', ck) pp.show()