def __init__(self, parent): InnerWindow.__init__(self, parent) vbox = Box(self) vbox.show() self.content = vbox title = Label(self, scale=2.0, text='Edone %s' % VERSION) title.show() vbox.pack_end(title) en = Entry(self, text=INFO, editable=False, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.show() vbox.pack_end(en) sep = Separator(self, horizontal=True) sep.show() vbox.pack_end(sep) close = Button(self, text='Close') close.callback_clicked_add(lambda b: self.delete()) close.show() vbox.pack_end(close) self.activate()
def naviframe_clicked(obj): win = StandardWindow("naviframe", "Naviframe test", autodel=True, size=(400, 400)) win.focus_highlight_enabled = True if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) nf = Naviframe(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(nf) nf.show() bt = Button(win, text="Next") bt.callback_clicked_add(page2, nf) content = Photo(nf, file=os.path.join(img_path, "logo.png"), fill_inside=True, style="shadow") item = nf.item_push("Page 1", None, bt, content, "basic") nf.data["page1"] = item win.show()
def _populate_done_cb(self, success): # draw the last date piece if self._last_date: self.date_add(self._last_date, self._last_date_row, self._current_row) # draw still-open connections lines (and clear the old ones) while self._open_connection_lines: l = self._open_connection_lines.pop() l.delete() for key in self._open_connections: for child_col, child_row, new_col in self._open_connections[key]: l = self.connection_add(child_col, child_row, child_col, self._current_row) self._open_connection_lines.append(l) # add the "show more" button if necessary if self._open_connections: bt = Button(self, text="Show more commits", size_hint_align=(0,0)) bt.callback_clicked_add(self._show_more_clicked_cb) self.pack(bt, 0, self._current_row + 1, 10, 2) bt.show() # show the first commit in the diff view if self._first_commit is not None: self.win.show_commit(self._first_commit) self._first_commit = None
def __init__(self, repo, win): self.repo = repo self.win = win self.confirmed = False StandardWindow.__init__(self, 'Egitu', 'Egitu', autodel=True) vbox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(vbox) vbox.show() # title en = Entry(self, editable=False, text='<title><align=center>Commit changes</align></title>', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(en) en.show() panes = Panes(self, content_left_size = 0.2, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(panes) panes.show() # message entry en = Entry(self, editable=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set('guide', 'Enter commit message here') panes.part_content_set("left", en) en.show() self.msg_entry = en # diff entry self.diff_entry = DiffedEntry(self) panes.part_content_set("right", self.diff_entry) self.diff_entry.show() # buttons hbox = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(self, text="Cancel") bt.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(bt) bt.show() bt = Button(self, text="Commit") bt.callback_clicked_add(self.commit_button_cb) hbox.pack_end(bt) bt.show() # show the window and give focus to the editable entry self.size = 500, 500 self.show() en.focus = True # load the diff repo.request_diff(self.diff_done_cb, only_staged=True)
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 anchor_hover_opened(obj, event_info): print("We should have EntryAnchorHoverInfo here: %s" % (event_info)) print("EntryAnchorHoverInfo has the following properties and methods: %s" % (dir(event_info))) print(event_info.anchor_info.name) btn = Button(obj, text="Testing entry anchor") event_info.hover.part_content_set("middle", btn) btn.show()
def __init__(self, cmd, exec_cb): DialogWindow.__init__(self, _app_instance.win, 'egitu-review', 'Git Command Review', autodel=True, size=(300,50)) # main table (inside a padding frame) fr = Frame(self, style='default', text='Command to execute', size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self.resize_object_add(fr) fr.show() tb = Table(self, padding=(6,6), size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) fr.content = tb tb.show() # cmd entry en = Entry(self, single_line=True, scrollable=True, text=utf8_to_markup(cmd), size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) tb.pack(en, 0, 0, 2, 1) en.show() # buttons bt = Button(self, text='Close', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: self.delete()) tb.pack(bt, 0, 1, 1, 1) bt.show() bt = Button(self, text='Execute', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(self._exec_clicked_cb, en, exec_cb) tb.pack(bt, 1, 1, 1, 1) bt.show() # self.show()
def panel_clicked(obj): win = StandardWindow("panel", "Panel test", autodel=True, size=(300, 300)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bt = Button(win, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bt.show() panel = Panel(win, orient=ELM_PANEL_ORIENT_LEFT, content=bt, size_hint_weight=EXPAND_VERT, size_hint_align=FILL_VERT_ALIGN_LEFT) bx.pack_end(panel) panel.show() win.show()
def __init__(self, cmd): self.cmd = cmd self.cmd_exe = None win = self.win = Window("ecore-ex", ELM_WIN_DIALOG_BASIC) win.title = "Ecore Example" win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL win.resize(300, 200) win.callback_delete_request_add(lambda o: elementary.exit()) win.show() win.activate() self.sendEntry = Entry(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.sendEntry.show() self.sendButton = Button(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.sendButton.text = "Send!" self.sendButton.callback_pressed_add(self.sendPressed) self.sendButton.show() box = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) box.pack_end(self.sendEntry) box.pack_end(self.sendButton) box.show() win.resize_object_add(box) self.run_command(cmd)
def menu_create(search, win): tbx.clear() for category in items: frame = Frame(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text=category[0]) frame.show() tbx.pack_end(frame) tbx2 = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) frame.content_set(tbx2) tbx2.show() cnt = 0 for test in category[1]: if (search == None) or (test[0].lower().find(search.lower()) > -1): bt = Button(win, text=test[0]) bt.callback_clicked_add(selected_cb, test[1], test[2]) bt.show() tbx2.pack_end(bt) cnt += 1 if cnt < 1: frame.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()
def cb_popup_center_title_text_1button(li, item, win): popup = Popup(win, size_hint_weight=EXPAND_BOTH) popup.text = "This Popup has content area and " \ "action area set, action area has one button Close" bt = Button(win, text="Close") bt.callback_clicked_add(cb_bnt_close, popup) popup.part_content_set("button1", bt) popup.show()
def transit2_clicked(obj, item=None): win = StandardWindow("transit2", "Transit 2", autodel=True, size=(400, 400)) bt = Button(win, text="Resizing Effect", pos=(50, 100), size=(100, 50)) bt.show() bt.callback_clicked_add(transit_resizing) win.show()
def __init__(self, parent, app, branch): self.app = app self.branch = branch Popup.__init__(self, parent) self.part_text_set("title,text", "Delete branch") self.part_content_set("title,icon", Icon(self, standard="user-trash")) # main vertical box box = Box(self) self.content = box box.show() # sep sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH) box.pack_end(sep) sep.show() # label en = Entry( self, editable=False, text="%s<br><br><hilight>%s</hilight><br>" % ("Are you sure you want to delete this branch?", branch.name), size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH, ) box.pack_end(en) en.show() # force checkbox ck = Check( self, text="Force delete (even if not fully merged)", size_hint_expand=EXPAND_BOTH, size_hint_align=(0.0, 0.5), ) box.pack_end(ck) ck.show() self.force_chk = ck # buttons sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH) box.pack_end(sep) sep.show() bt = Button(self, text="Cancel") bt.callback_clicked_add(lambda b: self.delete()) self.part_content_set("button1", bt) bt.show() bt = Button(self, text="Delete branch") bt.callback_clicked_add(self._delete_btn_cb) self.part_content_set("button2", bt) bt.show() # self.show()
def transit4_clicked(obj, item=None): win = StandardWindow("transit4", "Transit 4", autodel=True, size=(300, 300)) bt = Button(win, text="Zoom Effect", size=(100, 50), pos=(100, 125)) bt.show() bt.callback_clicked_add(transit_zoom) win.show()
def __init__(self, canvas, title, text): n = Popup(canvas) n.part_text_set("title,text", title) n.text = text b = Button(canvas) b.text = "OK" b.callback_clicked_add(lambda x: n.delete()) n.part_content_set("button1", b) n.show()
def __init__(self, ourParent, ourText, ourIcon=None, ourCB=None, *args, **kwargs): Button.__init__(self, ourParent, *args, **kwargs) icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon.standard_set(ourIcon) icon.show() self.text = ourText self.content_set(icon) self.callback_clicked_add(ourCB)
def __init__(self, parent, repo): self.repo = repo Popup.__init__(self, parent) self.part_text_set("title,text", "Add remote") tb = Table(self, padding=(3, 3), size_hint_expand=EXPAND_BOTH) self.content = tb tb.show() # name lb = Label(tb, text="Name") tb.pack(lb, 0, 0, 1, 1) lb.show() en = Entry( tb, editable=True, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH ) en.part_text_set("guide", "Name for the new remote") en.callback_changed_user_add(lambda e: self.err_unset()) tb.pack(en, 1, 0, 1, 1) en.show() self.name_entry = en # url lb = Label(tb, text="URL") tb.pack(lb, 0, 1, 1, 1) lb.show() en = Entry( tb, editable=True, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH ) en.part_text_set("guide", "git://git.example.com/repo.git") en.callback_changed_user_add(lambda e: self.err_unset()) tb.pack(en, 1, 1, 1, 1) en.show() self.url_entry = en # error label lb = Label(tb, text="", size_hint_expand=EXPAND_HORIZ) tb.pack(lb, 0, 2, 2, 1) lb.show() self.error_label = lb # buttons bt = Button(self, text="Cancel") bt.callback_clicked_add(lambda b: self.delete()) self.part_content_set("button1", bt) bt.show() bt = Button(self, text="Add remote") bt.callback_clicked_add(self._add_btn_cb) self.part_content_set("button2", bt) bt.show() self.show()
def showDialog(self, title, msg): dia = Popup(self) dia.part_text_set("title,text", title) dia.part_text_set("default", msg) bt = Button(dia, text="Ok") bt.callback_clicked_add(lambda b: dia.delete()) dia.part_content_set("button1", bt) dia.show()
def aboutPress( self, obj, it ): #About popup self.popupAbout = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) self.popupAbout.text = "ePad - A simple text editor written in python and elementary<br><br> " \ "By: Jeff Hoogland" bt = Button(self.mainWindow, text="Done") bt.callback_clicked_add(self.aboutClose) self.popupAbout.part_content_set("button1", bt) self.popupAbout.show() it.selected_set(False)
def aboutPress(self, obj, it): #About popup self.popupAbout = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) self.popupAbout.text = "ePad - A simple text editor written in python and elementary<br><br> " \ "By: Jeff Hoogland" bt = Button(self.mainWindow, text="Done") bt.callback_clicked_add(self.aboutClose) self.popupAbout.part_content_set("button1", bt) self.popupAbout.show() it.selected_set(False)
def panes_clicked(obj): win = StandardWindow("panes", "Panes test", autodel=True, size=(320, 480)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) panes = Panes(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(panes) panes.callback_clicked_add(cb_panes, "clicked") panes.callback_clicked_double_add(cb_panes, "clicked,double") panes.callback_press_add(cb_panes, "press") panes.callback_unpress_add(cb_panes, "unpress") panes.show() bt = Button(win, text="Left") panes.part_content_set("left", bt) bt.show() panes_h = Panes(win, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) panes_h.horizontal = True panes.part_content_set("right", panes_h) panes_h.show() bt = Button(win, text="Up") panes_h.part_content_set("left", bt) bt.show() bt = Button(win, text="Down") panes_h.part_content_set("right", bt) bt.show() win.show()
def select_torrent(self): sel = Fileselector(self.win) sel.expandable = False sel.path_set(os.path.expanduser("~")) sel.size_hint_weight_set(1.0, 1.0) sel.size_hint_align_set(-1.0, -1.0) sel.show() sf = Frame(self.win) sf.size_hint_weight_set(1.0, 1.0) sf.size_hint_align_set(-1.0, -1.0) sf.text = "Select torrent file" sf.content = sel sf.show() magnet = Entry(self.win) magnet.single_line = True magnet.scrollable = True if hasattr(magnet, "cnp_selection_get"): magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT) else: import pyperclip t = pyperclip.paste() if t is not None and t.startswith("magnet:"): magnet.entry = t magnet.show() mf = Frame(self.win) mf.size_hint_weight_set(1.0, 0.0) mf.size_hint_align_set(-1.0, 0.0) mf.text = "Or enter magnet URI here" mf.content = magnet mf.show() mbtn = Button(self.win) mbtn.text = "Done" mbtn.show() mbox = Box(self.win) mbox.size_hint_weight_set(1.0, 0.0) mbox.size_hint_align_set(-1.0, 0.0) mbox.horizontal = True mbox.pack_end(mf) mbox.pack_end(mbtn) mbox.show() box = Box(self.win) box.size_hint_weight = (1.0, 1.0) box.size_hint_align = (-1.0, -1.0) box.pack_end(sf) box.pack_end(mbox) box.show() inwin = InnerWindow(self.win) inwin.content = box sel.callback_done_add(self.add_torrent_cb) sel.callback_done_add(lambda x, y: inwin.delete()) mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet) mbtn.callback_clicked_add(lambda x: inwin.delete()) inwin.activate()
def page2(bt, nf): ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png")) bt = Button(nf, content=ic) bt.callback_clicked_add(page3, nf) content = Photo(nf, file=os.path.join(img_path, "plant_01.jpg"), fill_inside=True, style="shadow") item = nf.item_push("Page 2", None, bt, content, "basic") item.part_text_set("subtitle", "Here is sub-title part!")
def __init__(self, parent, title, msg): Popup.__init__(self, parent) self.part_text_set('title,text', title) self.part_text_set('default', msg) b = Button(self, text='Close') b.callback_clicked_add(lambda b: self.delete()) b.show() self.part_content_set('button1', b) self.show()
def image_clicked(obj): win = StandardWindow("image", "Image 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, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, file=os.path.join(img_path, "logo.png")) vbox.pack_end(im) im.show() sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL, size_hint_align=FILL_BOTH) vbox.pack_end(hbox) hbox.show() for rot in orients: b = Button(win, text=rot[0]) hbox.pack_end(b) b.callback_clicked_add(lambda b, y=rot[1]: im.orient_set(y)) b.show() sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH) vbox.pack_end(hbox) hbox.show() b = Button(win, text="Set remote URL") hbox.pack_end(b) b.callback_clicked_add(lambda b: im.file_set(remote_url)) b.show() pb = Progressbar(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) hbox.pack_end(pb) pb.show() im.callback_download_start_add(_cb_im_download_start, pb) im.callback_download_done_add(_cb_im_download_done) im.callback_download_progress_add(_cb_im_download_progress, pb) im.callback_download_error_add(_cb_im_download_error, pb) win.show()
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 aboutPress(self, obj, it): # About popup self.popupAbout = Popup(self._canvas, size_hint_weight=EXPAND_BOTH) self.popupAbout.part_text_set("title,text", "ePad version {0}".format(__version__)) self.popupAbout.text = ("A simple text editor written in " "python and elementary<br><br> " "By: Jeff Hoogland") bt = Button(self._canvas, text="Done") bt.callback_clicked_add(self.aboutClose) self.popupAbout.part_content_set("button1", bt) self.popupAbout.show()
def __init__(self, canvas, exit_func): n = Popup(canvas) n.part_text_set("title,text", "Confirm exit") n.text = "Are you sure you wish to exit Epour?" b = Button(canvas) b.text = "Yes" b.callback_clicked_add(lambda x: exit_func()) n.part_content_set("button1", b) b = Button(canvas) b.text = "No" b.callback_clicked_add(lambda x: n.delete()) n.part_content_set("button2", b) n.show()
def __init__(self, parent, title=None, msg=None): Popup.__init__(self, parent) self.part_text_set('title,text', title or 'Error') if not msg: msg = 'Unknown error' self.part_text_set('default', '<align=left>'+msg+'</align>') b = Button(self, text='Close') b.callback_clicked_add(lambda b: self.delete()) b.show() self.part_content_set('button1', b) self.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 __init__(self, parent, app): self.app = app Popup.__init__(self, parent) self.part_text_set('title,text', 'Save current status') self.part_content_set('title,icon', SafeIcon(self, 'git-stash')) # main vertical box box = Box(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self.content = box box.show() # separator sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ) box.pack_end(sep) sep.show() # description en = Entry(self, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) en.part_text_set('guide', 'Stash description (or empty for the default)') en.text = 'WIP on ' + app.repo.status.head_describe box.pack_end(en) en.show() # include untracked ck = Check(self, text='Include untracked files', state=True, size_hint_expand=EXPAND_HORIZ, size_hint_align=(0.0,0.5)) box.pack_end(ck) ck.show() # separator sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_HORIZ) box.pack_end(sep) sep.show() # buttons bt = Button(self, text='Close') bt.callback_clicked_add(lambda b: self.delete()) self.part_content_set('button1', bt) bt.show() bt = Button(self, text='Stash', content=SafeIcon(self, 'git-stash')) bt.callback_clicked_add(self._stash_clicked_cb, en, ck) self.part_content_set('button2', bt) bt.show() # focus to the entry and show en.select_all() en.focus = True self.show()
def focus5_clicked(obj, item=None): theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj")) win = StandardWindow("focus5", "Focus Custom", autodel=True, size=(320, 320)) win.focus_highlight_enabled = True win.focus_highlight_animate = True win.focus_highlight_style = "glow" fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH); win.resize_object_add(fr) fr.show() bx = Box(fr) fr.content = bx bx.show() chk = Check(bx, text='Enable glow effect on "Glow" Button', state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(chk) chk.show() spinner = Spinner(bx, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(spinner) spinner.show() bt = Button(bx, text="Glow Button", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bt.callback_focused_add(_glow_effect_on_cb, win, chk) bt.callback_unfocused_add(_glow_effect_off_cb, win, chk) bx.pack_end(bt) bt.show() sp = Separator(bx, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(sp) sp.show() bx2 = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range (1, 5): bt = Button(bx2, text="Button %d" % i, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt) bt.show() win.show()
def transit7_clicked(obj, item=None): win = StandardWindow("transit7", "Transit 7", autodel=True, size=(400, 400)) bt = Button(win, text="Front Button - Resizable Flip Effect", pos=(50, 100), size=(250, 30)) bt.show() bt2 = Button(win, text="Back Button - Resizable Flip Effect", pos=(50, 100), size=(300, 200)) win.show() bt.callback_clicked_add(transit_resizable_flip, bt2) bt2.callback_clicked_add(transit_resizable_flip, bt)
def aboutPress(self, obj, it): # About popup self.popupAbout = Popup(self._canvas, size_hint_weight=EXPAND_BOTH) self.popupAbout.part_text_set("title,text", "ePad version {0}".format(__version__)) self.popupAbout.text = ( "A simple text editor written in " "python and elementary<br><br> " "By: Jeff Hoogland" ) bt = Button(self._canvas, text="Done") bt.callback_clicked_add(self.aboutClose) self.popupAbout.part_content_set("button1", bt) self.popupAbout.show()
def __init__(self): StandardWindow.__init__(self, "ex2", "Hello Elementary", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hello Elementary!" ourLabel.show() ourButton = Button(self) ourButton.size_hint_weight = EXPAND_BOTH ourButton.text = "Goodbye Elementary" ourButton.callback_clicked_add(self.buttonPressed) ourButton.show() ourBox = Box(self) ourBox.size_hint_weight = EXPAND_BOTH ourBox.pack_end(ourLabel) ourBox.pack_end(ourButton) ourBox.show() self.resize_object_add(ourBox)
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 page4(bt, nf): ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png")) bt = Button(nf, content=ic) bt.callback_clicked_add(page5, nf) content = Photo(nf, file=os.path.join(img_path, "rock_02.jpg"), fill_inside=True, style="shadow") item = nf.item_push("Page 4", None, bt, content, "basic") ic = Icon(nf, file=os.path.join(img_path, "logo_small.png")) item.part_content_set("icon", ic) item.part_text_set("subtitle", "Title area visibility test") item.title_enabled = (False, False) content.callback_clicked_add(title_visible, item)
def calendar_clicked(obj, item=None): win = StandardWindow("calendar", "Calendar", autodel=True) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bt = Button(bx, text="Next API function") bt.callback_clicked_add(api_bt_clicked, api) bx.pack_end(bt) if api["state"] == API_STATE_LAST: bt.disabled = True bt.show() the_time = datetime(2010, 12, 31) cal = Calendar(bx, first_day_of_week=ELM_DAY_MONDAY, size_hint_weight=EXPAND_BOTH, selected_time=the_time, min_max_year=(2010, 2012)) api["cal"] = cal bx.pack_end(cal) cal.show() win.show()
def buildSubs(self): self.subWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300)) self.subWin.title = "Life Tracker Assignment" bg = Background(self.subWin, size_hint_weight=EXPAND_BOTH) bg.show() self.subWin.resize_object_add(bg) self.subWin.callback_delete_request_add(lambda o: elm.exit()) self.ourWin = Window("lifetracker", ELM_WIN_DIALOG_BASIC, self, size=(300, 300)) self.ourWin.title = "Life Tracker Key Strokes" bg = Background(self.ourWin, size_hint_weight=EXPAND_BOTH) bg.show() self.ourWin.resize_object_add(bg) self.ourWin.callback_delete_request_add(lambda o: elm.exit()) self.ourWin.elm_event_callback_add(self.eventsCb) self.ourLife = ourLabel = Entry(self.ourWin, editable=False) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.size_hint_align = FILL_BOTH ourLabel.text_style_user_push("DEFAULT='font_size=20'") ourLabel.text = "Up and Down for Their Life, Left and Right for Mine" ourLabel.show() self.ourEntry = ourEntry = Entry(self.subWin) ourEntry.size_hint_weight = EXPAND_HORIZ ourEntry.size_hint_align = (-1, 0) ourEntry.single_line_set(True) ourEntry.text_style_user_push("DEFAULT='font_size=50'") ourEntry.callback_activated_add(self.ourLifeUpdate) ourEntry.text = "20" ourEntry.show() self.theirEntry = theirEntry = Entry(self.subWin) theirEntry.size_hint_weight = EXPAND_HORIZ theirEntry.size_hint_align = (-1, 0) theirEntry.single_line_set(True) theirEntry.text_style_user_push("DEFAULT='font_size=50'") theirEntry.callback_activated_add(self.theirLifeUpdate) theirEntry.text = "20" theirEntry.show() resetBtn = Button(self.subWin) resetBtn.text = "Reset life totals" resetBtn.callback_pressed_add(self.resetLifeTotals) resetBtn.show() entryBox = Box(self.subWin) entryBox.size_hint_weight = EXPAND_HORIZ entryBox.pack_end(ourEntry) entryBox.pack_end(theirEntry) entryBox.pack_end(resetBtn) entryBox.show() self.ourWin.resize_object_add(ourLabel) self.subWin.resize_object_add(entryBox) self.ourWin.show() self.subWin.show() self.ourWin.center(True, True) self.subWin.center(True, True)
def __init__(self, parent, session): Frame.__init__(self, parent) self.session = session self.size_hint_align = FILL_HORIZ self.text = "Listen port (range)" port = session.listen_port() b = Box(parent) b.size_hint_weight = EXPAND_HORIZ lp = self.lp = RangeSpinners( parent, low=session.conf.getint("Settings", "listen_low"), high=session.conf.getint("Settings", "listen_high"), minim=0, maxim=65535) lp.show() b.pack_end(lp) save = Button(parent) save.text = "Apply" save.callback_clicked_add(self.save_cb) save.show() b.pack_end(save) b.show() self.content = b
def cb_popup_center_title_content_3button(li, item, win): ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) bt = Button(win, text="Content", content=ic) popup = Popup(win, size_hint_weight=EXPAND_BOTH, content=bt) popup.part_text_set("title,text", "Title") bt = Button(win, text="OK") popup.part_content_set("button1", bt) bt = Button(win, text="Cancel") popup.part_content_set("button2", bt) bt = Button(win, text="Close") bt.callback_clicked_add(cb_bnt_close, popup) popup.part_content_set("button3", bt) popup.show()
def transit8_clicked(obj, item=None): win = StandardWindow("transit8", "Transit 8", autodel=True, size=(400, 400)) bt = Button(win, text="Button - Custom Effect", pos=(50, 50), size=(150, 150)) bt.show() # Adding Transit trans = Transit() trans.auto_reverse = True trans.tween_mode = ELM_TRANSIT_TWEEN_MODE_DECELERATE trans.object_add(bt) trans.effect_add(CustomEffect(150, 150, 50, 50)) trans.duration = 5.0 trans.repeat_times = -1 trans.go() win.show()
def __init__(self, parent, text, *args, ic_btn=None, cb_onclick=None, **kwargs): Button.__init__(self, parent, *args, **kwargs) icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon.standard_set(ic_btn) icon.show() self.text = text self.content_set(icon) if cb_onclick: self.callback_clicked_add(cb_onclick)
def __init__(self): win = StandardWindow("Testing", "Elementary Sorted Table") # pylint: disable=no-member win.callback_delete_request_add(lambda o: elm.exit()) # Build the titles for the table. The titles is a list of tuples # with the following format: # ( <str - Header Text>, <Bool - Sortable> )''' titles = [] for i in range(COLUMNS): titles.append(("Column " + str(i), True if i != 2 else False)) # Create our sorted list object slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) # Populate the rows in our table for _i in range(ROWS): # Each row is a list with the number of elements # that must equal the number of headers row = [] for j in range(COLUMNS): # Row elements can be ANY elementary object if j == 0: # For the first column in each row, we will create a button # that will delete the row when pressed btn = Button(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) btn.text = "Delete row" btn.callback_clicked_add( lambda x, y=row: slist.row_unpack(y, delete=True)) btn.show() # Add the btn created to our row row.append(btn) else: # For each other row create a label with a random number data = random.randint(0, ROWS * COLUMNS) label = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) label.text = str(data) # For integer data we also need to assign value to "sort_data" # because otherwise things get sorted as text label.data["sort_data"] = data label.show() # Append our label to the row row.append(label) # Add the row into the SortedList slist.row_pack(row, sort=False) # Show the list slist.show() win.resize_object_add(slist) win.resize(600, 400) win.show()
def cursor_clicked(obj, item=None): win = StandardWindow("cursors", "Cursors", autodel=True, size=(320, 480)) win.autodel_set(True) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() ck = Clock(win, cursor="clock") bx.pack_end(ck) ck.show() bt = Button(win, text="Coffee Mug", cursor="coffee_mug") bx.pack_end(bt) bt.show() bt = Button(win, text="Cursor unset", cursor="bogosity") bt.cursor_unset() bx.pack_end(bt) bt.show() lst = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, cursor="watch") lst.item_append("watch over list") lst.item_append("watch over list") bx.pack_end(lst) lst.go() lst.show() en = Entry(win, scrollable=True, single_line=True, entry="Xterm cursor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, cursor="xterm") bx.pack_end(en) en.show() win.show()
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 cb_popup_center_text_1button_hide_show(li, item, win): global times global g_popup times += 1 if g_popup is not None: g_popup.text = "You have checked this popup %d times." % times g_popup.show() return g_popup = Popup(win, size_hint_weight=EXPAND_BOTH) g_popup.text = "Hide this popup by using the button." \ "When you click list item again, you will see this popup again." bt = Button(win, text="Hide") bt.callback_clicked_add(lambda b: g_popup.hide()) g_popup.part_content_set("button1", bt) g_popup.show()
def cb_item6(li, item): box = Box(li, size_hint_min=(200, 150)) sc = Scroller(li, bounce=(False, True), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.show() bt = Button(li, text="Ctxpop will be on the top of layer", size_hint_min=(190, 140)) bt.callback_clicked_add(cb_btn) sc.content = bt box.pack_end(sc) cp = Ctxpopup(li, content=box) cp.callback_dismissed_add(cb_dismissed) (x, y) = li.evas.pointer_canvas_xy_get() cp.move(x, y) cp.show() bt.data["ctxpopup"] = cp
def content_get(self, gl, part, data): if not part == "elm.swallow.end": bt = Button(gl, text="OK", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) else: bt = Icon(gl, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) return bt