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): 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 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 addTab(self, widget, tabName, canClose=True, disabled=False): self.tabs.append(widget) btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT) btn.text = tabName btn.data["widget"] = widget btn.disabled = disabled btn.callback_clicked_add(self.showTab, widget) btn.show() icn = Icon(self.buttonBox) icn.standard_set("gtk-close") icn.show() cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT) cls.data["widget"] = widget cls.callback_clicked_add(self.closeTab) cls.disabled = disabled if canClose: cls.show() sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT) sep.show() self.buttonBox.pack_end(btn) self.buttonBox.pack_end(cls) self.buttonBox.pack_end(sep) #Arguments go: btn, cls, sep widget.data["close"] = cls widget.data["button"] = btn widget.data["sep"] = sep self.showTab(widget=widget)
def box_transition_clicked(obj, item=None): win = StandardWindow("box-layout-transition", "Box Layout Transition", autodel=True) vbox = Box(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() bx = Box(win, layout=ELM_BOX_LAYOUT_HORIZONTAL, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(bx) bx.show() sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() bt = Button(win, text="layout: %s" % layout_list[current_layout]) bt.callback_clicked_add(box_transition_button_cb, bx) vbox.pack_end(bt) bt.show() for i in range(4): ic = Icon(win, file=ic_file, resizable=(0, 0), size_hint_align=(0.5, 0.5)) bx.pack_end(ic) ic.show() win.show()
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 __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 __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 __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 __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 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 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 header_row_pack(self, titles): """Takes a list (or a tuple) of tuples (string, bool) and packs them to the first row of the table.""" assert isinstance(titles, (list, tuple)) for t in titles: assert isinstance(t, tuple) assert len(t) == 2 title, sortable = t assert isinstance(title, basestring) assert isinstance(sortable, bool) def sort_btn_cb(button, col): if self.sort_column == col: self.reverse() else: self.sort_by_column(col) for count, t in enumerate(titles): title, sortable = t btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text=title) btn.callback_clicked_add(sort_btn_cb, count) if not sortable: btn.disabled = True btn.show() self.pack(btn, count, 0, 1, 1) self.header_row.append(btn)
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 buildLoadBox(self): # build the load label loadLable = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) loadLable.text = "<b>Processing</b>" loadLable.show() # build the spinning wheel wheel = Progressbar(self, pulse_mode=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) wheel.pulse(True) wheel.show() detailsbtn = Button(self, style="anchor") detailsbtn.text_set("Details") detailsbtn.callback_pressed_add(self.innerWinShow) detailsbtn.show() # build the status label self.statusLabel = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.statusLabel.show() # put all the built objects in a vertical box box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(loadLable) box.pack_end(wheel) box.pack_end(self.statusLabel) box.pack_end(detailsbtn) box.show() return box
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 addPackage(self, pak): row = [] ourCheck = Check(self) ourCheck.data['packageName'] = pak.name ourCheck.callback_changed_add(self.app.checkChange) ourCheck.show() row.append(ourCheck) ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ourName.text = pak.name ourName.data["packageDes"] = pak.candidate.description ourName.callback_pressed_add(self.packagePressed) ourName.show() row.append(ourName) ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) ourVersion.text = pak.installed.version ourVersion.show() row.append(ourVersion) newVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) newVersion.text = pak.candidate.version newVersion.show() row.append(newVersion) self.app.packagesToUpdate[pak.name] = {'check':ourCheck, 'selected':False} self.packageList.row_pack(row, sort=False)
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 table5_clicked(obj, item=None): win = StandardWindow("table5", "Table 5", autodel=True) tb = Table(win, homogeneous=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 0, 34, 33) bt.show() bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 67, 33, 33, 34) bt.show() bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 67, 34, 33) bt.show() bt = Button(win, text="D", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 0, 33, 33, 34) bt.show() bt = Button(win, text="X", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tb.pack(bt, 33, 33, 34, 34) bt.show() win.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 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 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 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 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 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): 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 __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 fileExists(self, filePath): self.confirmPopup = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) # Add a table to hold dialog image and text to Popup tb = Table(self.confirmPopup, size_hint_weight=EXPAND_BOTH) self.confirmPopup.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self.confirmPopup, thumb='True') icon.standard_set('dialog-question') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self.confirmPopup, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self.confirmPopup, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) current_file = os.path.basename(filePath) dialogLabel.text = "'%s' already exists. Overwrite?<br><br>" \ % (current_file) tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Close without saving button no_btt = Button(self.mainWindow) no_btt.text = "No" no_btt.callback_clicked_add(self.closePopup, self.confirmPopup) no_btt.show() # Save the file and then close button sav_btt = Button(self.mainWindow) sav_btt.text = "Yes" sav_btt.callback_clicked_add(self.doSelected) sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup) sav_btt.show() # add buttons to popup self.confirmPopup.part_content_set("button1", no_btt) self.confirmPopup.part_content_set("button3", sav_btt) self.confirmPopup.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 __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 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 __init__( self ): win = StandardWindow("Testing", "Elementary Sorted Table") 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: ( <String - 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) lb = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) lb.text=str(data) """For integer data we also need to assign value to "sort_data" because otherwise things get sorted as text""" lb.data["sort_data"] = data lb.show() #Append our label to the row row.append(lb) #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 __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 header_row_pack(self, titles): """Takes a list (or a tuple) of tuples (string, bool) and packs them to the first row of the table.""" assert isinstance(titles, (list, tuple)) for _t in titles: assert isinstance(_t, tuple) assert len(_t) == 2 title, sortable = _t try: assert isinstance(title, str) except TypeError: assert isinstance(title, str) assert isinstance(sortable, bool) def sort_btn_cb(button, col): """ Sort or reverse if sort button pressed. """ if self.sort_column == col: self.reverse() else: self.sort_by_column(col) for count, _t in enumerate(titles): title, sortable = _t btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text=title) btn.callback_clicked_add(sort_btn_cb, count) if not sortable: btn.disabled = True btn.show() self.header_box.pack_end(btn) self.header_row.append(btn) elm_list = ScrollableList(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) elm_list.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF) elm_list.mode_set(ELM_LIST_EXPAND) elm_list.go() elm_list.show() self.list_box.pack_end(elm_list) self.lists.append(elm_list) sep = Separator(self) sep.show() self.header_box.pack_end(sep) self.header_box.pack_end(sep)
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 __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 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 conformant_clicked(obj, item=None): win = StandardWindow("conformant", "Conformant", autodel=True, conformant=True, size=(240,240)) conform = Conformant(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(conform) conform.show() bx = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en = ScrollableEntry(win, single_line=True, bounce=(True, False), text="This is the top entry here", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.show() bx.pack_end(en) btn = Button(win, text="Test Conformant", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(btn) btn.show() en = ScrollableEntry(win, single_line=True, bounce=(True, False), text="This is the middle entry here", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.show() bx.pack_end(en) btn = Button(win, text="Test Conformant", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(btn) btn.show() en = ScrollableEntry(win, bounce=(False, True), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.text = \ "This is a multi-line entry at the bottom<br/>" \ "This can contain more than 1 line of text and be " \ "scrolled around to allow for entering of lots of " \ "content. It is also to test to see that autoscroll " \ "moves to the right part of a larger multi-line " \ "text entry that is inside of a scroller than can be " \ "scrolled around, thus changing the expected position " \ "as well as cursor changes updating auto-scroll when " \ "it is enabled." en.show() bx.pack_end(en) conform.content = bx bx.show() win.show()
def __init__(self, parent): DialogWindow.__init__(self, parent, 'epack-info', 'Epack', autodel=True) fr = Frame(self, style='pad_large', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(fr) fr.show() hbox = Box(self, horizontal=True, padding=(12,12)) fr.content = hbox hbox.show() vbox = Box(self, align=(0.0,0.0), padding=(6,6), size_hint_weight=EXPAND_VERT, size_hint_align=FILL_VERT) hbox.pack_end(vbox) vbox.show() # icon + version ic = Icon(self, standard='epack', size_hint_min=(64,64)) vbox.pack_end(ic) ic.show() lb = Label(self, text=_('Version: %s') % __version__) vbox.pack_end(lb) lb.show() sep = Separator(self, horizontal=True) vbox.pack_end(sep) sep.show() # buttons bt = Button(self, text=_('Epack'), size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: self.entry.text_set(utils.INFO)) vbox.pack_end(bt) bt.show() bt = Button(self, text=_('Website'),size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: utils.xdg_open(utils.GITHUB)) vbox.pack_end(bt) bt.show() bt = Button(self, text=_('Authors'), size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: self.entry.text_set(utils.AUTHORS)) vbox.pack_end(bt) bt.show() bt = Button(self, text=_('License'), size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: self.entry.text_set(utils.LICENSE)) vbox.pack_end(bt) bt.show() # main text self.entry = Entry(self, editable=False, scrollable=True, text=utils.INFO, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.entry.callback_anchor_clicked_add(lambda e,i: utils.xdg_open(i.name)) hbox.pack_end(self.entry) self.entry.show() self.resize(400, 200) self.show()
def buttons_clicked(obj): win = StandardWindow("buttons", "Buttons", focus_highlight_enabled=True, autodel=True) 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() ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() bt = Button(win, text="Icon sized to button", content=ic) bx.pack_end(bt) bt.show() ic = Icon(win, file=ic_file, resizable=(False, False)) ic.show() bt = Button(win, text="Icon no scale", content=ic) bx.pack_end(bt) bt.show() bt = Button(win, text="No icon") bx.pack_end(bt) bt.show() ic = Icon(win, file=ic_file, resizable=(False, False)) bt = Button(win, content=ic) bx.pack_end(bt) bt.show() ic.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 core_evas_smart_clicked(obj, item=None): win = StandardWindow("evassmart", "Evas Smart Object Test", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.show() win.resize_object_add(box) b = Button(win, text="Add one", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_add_cb) box.pack_end(b) b.show() b = Button(win, text="Del last", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_del_cb) box.pack_end(b) b.show() b = Button(win, text="Hide all", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_hide_cb) box.pack_end(b) b.show() b = Button(win, text="Show all", size_hint_align=(0.0,0.0)) b.callback_clicked_add(btn_show_cb) box.pack_end(b) b.show() win.resize(320, 320) win.show()
def __init__(self): StandardWindow.__init__(self, "ex7", "Naviframe", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) staticImage = staticImage = Image(self) staticImage.size_hint_weight = EXPAND_BOTH staticImage.file_set("images/logo.png") staticImage.tooltip_text_set("A picture!") staticImage.show() ourLabel = ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hey look some text!" ourLabel.show() self.nf = Naviframe(self) self.nf.size_hint_weight = EXPAND_BOTH self.nf.size_hint_align = FILL_BOTH self.nf.show() buttonOne = Button(self) buttonOne.size_hint_weight = EXPAND_BOTH buttonOne.text = "Show image" buttonOne.callback_clicked_add(self.buttonPressed, staticImage) buttonOne.show() buttonTwo = Button(self) buttonTwo.size_hint_weight = EXPAND_BOTH buttonTwo.text = "Show label" buttonTwo.callback_clicked_add(self.buttonPressed, ourLabel) buttonTwo.show() buttonBox = Box(self) buttonBox.size_hint_weight = EXPAND_HORIZ buttonBox.horizontal_set(True) buttonBox.pack_end(buttonOne) buttonBox.pack_end(buttonTwo) buttonBox.show() mainBox = Box(self) mainBox.size_hint_weight = EXPAND_BOTH mainBox.pack_end(self.nf) mainBox.pack_end(buttonBox) mainBox.show() self.nf.item_simple_push(staticImage) self.resize_object_add(mainBox)
def __init__(self, parent_widget, titles=None, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.outPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.outPut.editable_set(False) self.outPut.scrollable_set(True) self.outPut.callback_changed_add(self.changedCb) self.outPut.show() frame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) frame.text = "Input:" frame.autocollapse_set(True) frame.collapse_go(True) frame.show() bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.horizontal = True bx.show() frame.content = bx self.inPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.inPut.single_line_set(True) self.inPut.callback_activated_add(self.enterPressed) self.inPut.show() enterButton = Button(self) enterButton.text = "Execute" enterButton.callback_pressed_add(self.enterPressed) enterButton.show() bx.pack_end(self.inPut) bx.pack_end(enterButton) self.pack_end(self.outPut) self.pack_end(frame) self.cmd_exe = None self.done_cb = None
def __init__(self, ourParent, ourMsg, ourIcon=None, *args, **kwargs): Popup.__init__(self, ourParent, *args, **kwargs) self.callback_block_clicked_add(lambda obj: self.delete()) # Add a table to hold dialog image and text to Popup tb = Table(self, size_hint_weight=EXPAND_BOTH) self.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self, thumb='True') icon.standard_set(ourIcon) # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) dialogLabel.text = ourMsg tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Ok Button ok_btt = Button(self) ok_btt.text = "Ok" ok_btt.callback_clicked_add(lambda obj: self.delete()) ok_btt.show() # add button to popup self.part_content_set("button3", ok_btt)
def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.output = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.output.editable_set(False) self.output.scrollable_set(True) self.output.callback_changed_add(self.cb_changed) self.output.show() frame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) frame.text = 'Input:' frame.autocollapse_set(True) frame.collapse_go(True) frame.show() hbx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) hbx.horizontal = True hbx.show() frame.content = hbx self.input = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.input.single_line_set(True) self.input.callback_activated_add(self.cb_enter) self.input.show() enter_btn = Button(self) enter_btn.text = 'Execute' enter_btn.callback_pressed_add(self.cb_enter) enter_btn.show() hbx.pack_end(self.input) hbx.pack_end(enter_btn) self.pack_end(self.output) self.pack_end(frame) self.cmd_exe = None self.done_cb = None
def icon_clicked(obj, item=None): win = StandardWindow("icon test", "Icon Test", autodel=True, size=(400, 400)) win.show() box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() ic = Icon(box, file=os.path.join(img_path, "logo.png"), resizable=(True, True), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(ic) ic.show() hbox = Box(box, horizontal=True, size_hint_weight=EXPAND_HORIZ) box.pack_end(hbox) hbox.show() # Test Aspect Fixed tg = Check(hbox, text="Aspect Fixed", state=True) tg.callback_changed_add(aspect_fixed_cb, ic) hbox.pack_end(tg) tg.show() # Test Fill Outside tg = Check(hbox, text="Fill Outside") tg.callback_changed_add(fill_outside_cb, ic) hbox.pack_end(tg) tg.show() # Test Smooth tg = Check(hbox, text="Smooth", state=True) tg.callback_changed_add(smooth_cb, ic) hbox.pack_end(tg) tg.show() # Test Preload, Prescale bt = Button(hbox, text="Preload & Prescale") bt.callback_clicked_add(bt_clicked) hbox.pack_end(bt) bt.show()
def box_vert2_clicked(obj, item=None): win = StandardWindow("box-vert2", "Box Vert 2", autodel=True) bx = Box(win, size_hint_weight=(0.0, 0.0)) win.resize_object_add(bx) bx.show() for i in range(5): bt = Button(win, text="Button %d" % i, size_hint_align=FILL_BOTH, size_hint_weight=(0.0, 0.0)) bt.callback_clicked_add(boxvert2_del_cb, bx) bx.pack_end(bt) bt.show() win.show()
def cb_menu_overlay_bubble(menu, item, Map, lon, lat): ov = Map.overlay_add(lon, lat) bub = Map.overlay_bubble_add() bub.follow(ov) lb = Label(Map, text="You can push contents here") bub.content_append(lb) lb.show() ic = Icon(Map, file=os.path.join(img_path, "sky_01.jpg")) ic.size_hint_min = 50, 50 bub.content_append(ic) ic.show() bt = Button(Map, text="clear me") bt.callback_clicked_add(lambda bt:bub.content_clear()) bub.content_append(bt) bt.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, session): self.session = session Frame.__init__(self, parent) self.size_hint_align = -1.0, 0.0 self.text = "Encryption settings" pes = self.pes = session.get_pe_settings() b = Box(parent) enc_values = lt.enc_policy.disabled, lt.enc_policy.enabled, lt.enc_policy.forced enc_levels = lt.enc_level.plaintext, lt.enc_level.rc4, lt.enc_level.both inc = self.inc = ActSWithLabel(parent, "Incoming encryption", enc_values, pes.in_enc_policy) b.pack_end(inc) inc.show() out = self.out = ActSWithLabel(parent, "Outgoing encryption", enc_values, pes.out_enc_policy) b.pack_end(out) out.show() lvl = self.lvl = ActSWithLabel(parent, "Allowed encryption level", enc_levels, pes.allowed_enc_level) b.pack_end(lvl) lvl.show() prf = self.prf = Check(parent) prf.style = "toggle" prf.text = "Prefer RC4 ecryption" prf.state = pes.prefer_rc4 b.pack_end(prf) prf.show() a_btn = Button(parent) a_btn.text = "Apply" a_btn.callback_clicked_add(self.apply) b.pack_end(a_btn) a_btn.show() b.show() self.content = b