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 cnp_clicked(obj): win = StandardWindow("copypaste", "CopyPaste", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH) win.resize_object_add(gd) gd.show() en = Entry(win, scrollable=True, line_wrap=ELM_WRAP_CHAR, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text="Elementary provides ") gd.pack(en, 10, 10, 60, 30) en.show() bt = Button(win, text="Copy from left entry") bt.callback_clicked_add(bt_copy_clicked, en) gd.pack(bt, 70, 10, 22, 30) bt.show() bt = Button(win, text="Clear clipboard") bt.callback_clicked_add(bt_clear_clicked, en) gd.pack(bt, 70, 70, 22, 20) bt.show() en = Entry(win, scrollable=True, line_wrap=ELM_WRAP_CHAR, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, text="rich copying and pasting functionality,") gd.pack(en, 10, 40, 60, 30) en.show() bt = Button(win, text="Paste to left entry") bt.callback_clicked_add(bt_paste_clicked, en) gd.pack(bt, 70, 40, 22, 30) bt.show() lb = Label(win, text="<b>Clipboard:</b>", size_hint_weight=(0.0, 0.0), size_hint_align=FILL_BOTH) gd.pack(lb, 10, 70, 60, 10) lb.show() global glb glb = Label(win, text="", size_hint_weight=(0.0, 0.0), size_hint_align=FILL_BOTH) gd.pack(glb, 10, 80, 60, 10) glb.show() win.size = 480, 200 win.show()
def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.ourList = ourList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.keys = [] ourList.go() ourList.show() self.ourItems = [] sframe = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sframe.text = "Search" self.search = search = Entry(self) search.single_line = True search.callback_changed_add(self.searchChange) sframe.content = search search.show() sframe.show() self.pack_end(ourList) self.pack_end(sframe)
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 __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 entry_anchor_clicked(obj, item=None): win = StandardWindow("entry", "Entry Anchor", autodel=True, size=(400, 400)) box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) entry = Entry(win, anchor_hover_style="popout", anchor_hover_parent=win) entry.text = "<a href=url:http://www.enlightenment.org/>Enlightenment</a>" entry.callback_anchor_clicked_add(anchor_clicked) entry.callback_anchor_hover_opened_add(anchor_hover_opened) entry.show() frame = Frame(win, size_hint_align=FILL_BOTH, text="Entry test", content=entry) frame.show() box.pack_end(frame) box.show() win.show()
def grid_clicked(obj): win = StandardWindow("grid", "Grid test", autodel=True, size=(480, 480)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH) win.resize_object_add(gd) gd.show() en = Entry(win, scrollable=True, text="Entry text 2", single_line=True) gd.pack(en, 60, 20, 30, 10) en.show() bt = Button(win, text="Next API function", disabled=True) gd.pack(bt, 30, 0, 40, 10) bt.disabled = True bt.show() bt = Button(win, text="Button") gd.pack(bt, 0, 0, 20, 20) bt.show() bt = Button(win, text="Button") gd.pack(bt, 10, 10, 40, 20) bt.show() bt = Button(win, text="Button") gd.pack(bt, 10, 30, 20, 50) bt.show() bt = Button(win, text="Button") gd.pack(bt, 80, 80, 20, 20) bt.show() bt = Button(win, text="Change") bt.callback_clicked_add(cb_change) gd.pack(bt, 40, 40, 20, 20) bt.show() re = Rectangle(win.evas, color=(128, 0, 0, 128)) gd.pack(re, 40, 70, 20, 10) re.show() re = Rectangle(win.evas, color=(0, 128, 0, 128)) gd.pack(re, 60, 70, 10, 10) re.show() re = Rectangle(win.evas, color=(0, 0, 128, 128)) gd.pack(re, 40, 80, 10, 10) re.show() re = Rectangle(win.evas, color=(128, 0, 128, 128)) gd.pack(re, 50, 80, 10, 10) re.show() re = Rectangle(win.evas, color=(128, 64, 0, 128)) gd.pack(re, 60, 80, 10, 10) re.show() win.show()
def newFile(self, obj=None, ignoreSave=False): if self.isSaved == True or ignoreSave == True: trans = Transit() trans.object_add(self.mainEn) trans.auto_reverse = True trans.effect_wipe_add(ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT) trans.duration = 0.5 trans.go() time.sleep(0.5) self.mainWindow.title_set("Untitlted - ePad") self.mainEn.delete() self.mainEn = Entry(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainEn.callback_changed_user_add(self.textEdited) self.mainEn.scrollable_set( True) # creates scrollbars rather than enlarge window self.mainEn.line_wrap_set( False) # does not allow line wrap (can be changed by user) self.mainEn.autosave_set(False) # set to false to reduce disk I/O self.mainEn.elm_event_callback_add(self.eventsCb) self.mainEn.markup_filter_append(self.textFilter) self.mainEn.show() self.mainBox.pack_end(self.mainEn) self.isNewFile = True elif self.confirmPopup == None: self.confirmSave(self.newFile)
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 __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 __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 _add_cb(bt, win, bx): en = Entry(win, scrollable=True, single_line=True, text="An entry", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.callback_focused_add(_focused_cb) en.callback_unfocused_add(_unfocused_cb) bx.pack_start(en) en.show()
def elm_input_events_clicked(obj, item=None): win = StandardWindow("inputevents", "Input Events Test", autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() entry = Entry(win, scrollable=True, size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.2)) entry.text = ( "This example will show how Elementary input events are handled. " "Typing in this entry will log in the entry box below all events " "caught by event handlers set to this Entry widget and its parent, " "the Window widget. Key up events are checked for in the callback " "and won't propagate to a parent widget." ) entry.show() log_entry = Entry(win, editable=False, scrollable=True, focus_allow=False, size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.8)) log_entry.callback_changed_add(changed_cb) log_entry.show() btn = Button(win, text="Clear log", focus_allow=False) btn.callback_clicked_add(lambda x: setattr(log_entry, "entry", "")) btn.show() box.pack_end(entry) box.pack_end(log_entry) box.pack_end(btn) entry.elm_event_callback_add(events_cb, log_entry) entry.markup_filter_append(filter_cb) win.elm_event_callback_add(events_cb, log_entry) win.resize(640, 480) win.show() entry.focus = True
def entryInit(self): self.mainEn = Entry(self.mainWindow, scrollable=True, line_wrap=self.wordwrap, autosave=False, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainEn.callback_changed_user_add(self.textEdited) self.mainEn.elm_event_callback_add(self.eventsCb) # self.mainEn.markup_filter_append(self.textFilter) self.mainEn.show() self.mainBox.pack_end(self.mainEn)
def focus3_clicked(obj, item=None): win = StandardWindow("focus3", "Focus 3", autodel=True, size=(320, 480)) win.focus_highlight_enabled = True bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() en = Entry(win, scrollable=True, single_line=True, text="An entry", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.callback_focused_add(_focused_cb) en.callback_unfocused_add(_unfocused_cb) bx.pack_end(en) en.show() bt = Button(win, text="Add", focus_allow=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_add_cb, win, bx) bx.pack_end(bt) bt.show() bt = Button(win, text="Del", focus_allow=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_del_cb, bx) bx.pack_end(bt) bt.show() bt = Button(win, text="hide", focus_allow=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bt.callback_clicked_add(_hide_cb) bx.pack_end(bt) bt.show() 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 __init__(self, parent): Popup.__init__(self, parent) self.part_text_set("title,text", "Document is encrypted") e = self.e = Entry(self, password=True) e.part_text_set("guide", "Enter Password") self.content_set(e) e.show() okb = Button(self, text="OK") self.part_content_set("button1", okb) okb.callback_clicked_add(lambda x: self.okcb()) okb.show() canb = Button(self, text="Cancel") self.part_content_set("button2", canb) canb.callback_clicked_add(lambda x: self.delete()) canb.show() self.show()
def gesture_layer_clicked(obj): w = 480 h = 800 win = Window("gesture-layer", ELM_WIN_BASIC, title="Gesture Layer", autodel=True, size=(w, h)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = Background(win, file=os.path.join(img_path, "wood_01.jpg"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(bg) bg.show() photos = [] photos.append( photo_object_add(win, None, os.path.join(img_path, "pol_sky.png"), 200, 200, 365, 400, 0)) photos.append( photo_object_add(win, None, os.path.join(img_path, "pol_twofish.png"), 40, 300, 365, 400, 45)) en = Entry(win, line_wrap=ELM_WRAP_MIXED) en.text = "You can use whatever object you want, even entries like this." postit = Layout(win, file=(os.path.join(script_path, "postit_ent.edj"), "main")) postit.part_content_set("ent", en) photos.append(photo_object_add(win, postit, None, 50, 50, 382, 400, 355)) win.show()
def buildDetailsWin(self): self.updateText = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.updateText.editable_set(False) self.updateText.scrollable_set(True) self.updateText.show() closebtn = Button(self) closebtn.text_set("Done") closebtn.callback_pressed_add(self.innerWinHide) closebtn.show() box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(self.updateText) box.pack_end(closebtn) box.show() self.innerWin = InnerWindow(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.innerWin.content_set(box)
def map_clicked(obj): win = StandardWindow("map", "Map test", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win) vbox.size_hint_weight = EXPAND_BOTH vbox.size_hint_align = FILL_BOTH win.resize_object_add(vbox) vbox.show() map_obj = Map(win, zoom=2) map_obj.size_hint_weight = EXPAND_BOTH map_obj.size_hint_align = FILL_BOTH map_obj.callback_tile_load_add(cb_map_load) map_obj.callback_tile_loaded_add(cb_map_load) map_obj.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, cb_map_mouse_down) vbox.pack_end(map_obj) map_obj.show() ### lb = Label(win, text="load_status: 0 / 0") vbox.pack_end(lb) lb.show() map_obj.data["lb_load_status"] = lb ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Goto") bt.callback_clicked_add(cb_btn_goto, map_obj) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom +") bt.callback_clicked_add(cb_btn_zoom, map_obj, 1) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom -") bt.callback_clicked_add(cb_btn_zoom, map_obj, -1) hbox.pack_end(bt) bt.show() sl = Slider(win, text="Rotation:", min_max=(0, 360), value=0, indicator_format="%3.0f") sl.callback_changed_add(cb_slider_rot, map_obj) hbox.pack_end(sl) sl.show() src_type = ELM_MAP_SOURCE_TYPE_TILE ho = Hoversel(win, hover_parent=win, text="Tiles: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Tiles") hbox.pack_end(ho) ho.show() ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() ck = Check(win, text="wheel_disabled") ck.callback_changed_add(lambda bt: map_obj.wheel_disabled_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="paused") ck.callback_changed_add(lambda bt: map_obj.paused_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="hide overlays") ck.callback_changed_add(cb_chk_overlays_hidden, map_obj) hbox.pack_end(ck) ck.show() ck = Check(win, text="pause overlays") ck.callback_changed_add(cb_chk_overlays_paused, map_obj) hbox.pack_end(ck) ck.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_ROUTE ho = Hoversel(win, hover_parent=win, text="Routes: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Routes") hbox.pack_end(ho) ho.show() lb = Label(win, text="Set Start and End point to calculate route") hbox.pack_end(lb) lb.show() map_obj.data["lb_distance"] = lb bt = Button(win, text="Calc route") bt.callback_clicked_add(cb_btn_calc_route, map_obj) hbox.pack_end(bt) bt.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_NAME ho = Hoversel(win, hover_parent=win, text="Names: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Names") hbox.pack_end(ho) ho.show() en = Entry(win, scrollable=True, text="type an address here") en.size_hint_weight = EXPAND_BOTH en.size_hint_align = FILL_BOTH en.single_line = True hbox.pack_end(en) en.show() bt = Button(win, text="Search address") bt.callback_clicked_add(cb_btn_search_name, map_obj, en) hbox.pack_end(bt) bt.show() bt = Button(win, text="Search start point") bt.callback_clicked_add(cb_btn_search_region, map_obj, en) hbox.pack_end(bt) bt.show() print_map_info(map_obj) win.show()
def __init__(self, parent, session): PreferencesDialog.__init__(self, "Session") # TODO: Construct and populate this with an Idler self.session = session widgets = {} elm_conf = Configuration() s = session.settings() t = Table(self, padding=(5, 5), homogeneous=True, size_hint_align=FILL_BOTH) self.box.pack_end(t) t.show() i = 0 INT_MIN = -2147483648 INT_MAX = 2147483647 scale = elm_conf.scale for k in dir(s): if k.startswith("__"): continue try: a = getattr(s, k) if isinstance(a, lt.disk_cache_algo_t): w = Spinner(t) w.size_hint_align = FILL_HORIZ # XXX: lt-rb python bindings don't have all values. w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys()) for name, val in lt.disk_cache_algo_t.names.items(): w.special_value_add(val, name) w.value = a elif isinstance(a, bool): w = Check(t) w.size_hint_align = 1.0, 0.0 w.style = "toggle" w.state = a elif isinstance(a, int): w = Spinner(t) w.size_hint_align = FILL_HORIZ w.min_max = INT_MIN, INT_MAX w.value = a elif isinstance(a, float): w = Slider(t) w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.unit_format = "%1.2f" if k.startswith("peer_turnover"): w.min_max = 0.0, 1.0 else: w.min_max = 0.0, 20.0 w.value = a elif k == "peer_tos": # XXX: This is an int pair in libtorrent, # which doesn't have a python equivalent. continue elif k == "user_agent": w = Entry(t) w.size_hint_align = 1.0, 0.0 w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.editable = False w.entry = cgi.escape(a) else: w = Entry(t) w.part_text_set("guide", "Enter here") w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.entry = cgi.escape(a) l = Label(t) l.text = k.replace("_", " ").capitalize() l.size_hint_align = 0.0, 0.0 l.size_hint_weight = EXPAND_HORIZ l.show() t.pack(l, 0, i, 1, 1) #w.size_hint_min = scale * 150, scale * 25 t.pack(w, 1, i, 1, 1) w.show() widgets[k] = w i += 1 except TypeError: pass #print("Error {}".format(k)) save_btn = Button(self) save_btn.text = "Apply session settings" save_btn.callback_clicked_add(self.apply_settings, widgets, session) save_btn.show() self.box.pack_end(save_btn)
def web_clicked(obj): if not elementary.need_web(): print("EFL-webkit not available!") return win = StandardWindow("web", "Web", autodel=True, size=(800, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbx) vbx.show() web = Web(win, url="http://enlightenment.org/", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, size_hint_min=(100, 100)) vbx.pack_end(web) web.show() # Debug: def dbg(*args): print(("DEBUG: %s" % args[-1], " ".join(repr(x) for x in args[1:-1]))) web.callback_link_hover_in_add(dbg, "link in") web.callback_link_hover_out_add(dbg, "link out") web.callback_uri_changed_add(dbg, "uri") web.callback_title_changed_add(dbg, "title") web.callback_load_finished_add(dbg, "load finished") web.callback_load_finished_add(dbg, "load error") web.callback_load_progress_add(dbg, "load progress") web.callback_load_provisional_add(dbg, "load provisional") web.callback_load_started_add(dbg, "load started") # JS debug to console: def console_msg(obj, msg, line, src): print(("CONSOLE: %s:%d %r" % (src, line, msg))) web.console_message_hook_set(console_msg) # navigation bar: hbx = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbx.pack_start(hbx) hbx.show() bt = Button(win, text="Back") bt.callback_clicked_add(lambda x: web.back()) hbx.pack_end(bt) bt.show() bt = Button(win, text="Forward") bt.callback_clicked_add(lambda x: web.forward()) hbx.pack_end(bt) bt.show() bt = Button(win, text="Reload") bt.callback_clicked_add(lambda x: web.reload()) hbx.pack_end(bt) bt.show() bt = Button(win, text="Stop") bt.callback_clicked_add(lambda x: web.stop()) hbx.pack_end(bt) bt.show() en = Entry(win, scrollable=True, editable=True, single_line=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) hbx.pack_end(en) en.show() # Sync navigation entry and current URI def do_change_uri(en): web.uri = en.entry def did_change_uri(web, uri, en): en.entry = uri en.callback_activated_add(do_change_uri) web.callback_uri_changed_add(did_change_uri, en) # Sync title def did_change_title(web, title, win): win.title_set("Web - %s" % title) web.callback_title_changed_add(did_change_title, win) win.show()
def __init__(self, parent, method): Popup.__init__(self, parent) self._method = method self._param_entry = None self._return_entry = None # title self.part_text_set('title,text', 'Method: %s()' % method.name) self.show() # content is vbox vbox = Box(parent) vbox.show() self.content = vbox # params label + entry if len(method.params) > 0: label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Params: ' + method.params_str label.show() vbox.pack_end(label) en = Entry(parent) self._param_entry = en en.editable = True en.scrollable = True en.single_line = True en.entry = '' en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.show() vbox.pack_end(en) sp = Separator(win) sp.horizontal = True sp.show() vbox.pack_end(sp) # returns label + entry label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Returns: ' label.text += method.returns_str if method.returns_str else 'None' label.show() vbox.pack_end(label) en = Entry(parent) self._return_entry = en en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.editable = False en.scrollable = True en.disabled = True en.single_line = True # TODO this is wrong, but the only way to show the entry :/ en.entry = '<br> <br> <br>' en.show() vbox.pack_end(en) # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state ch = Check(parent) ch.size_hint_align = 0.0, 0.5 ch.text = "Prettify output (loosing type infos)" ch.state = options.pretty_output ch.callback_changed_add(pretty_output_clicked_cb) ch.show() vbox.pack_end(ch) # popup buttons btn = Button(parent) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) self.part_content_set('button1', btn) btn = Button(parent) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) self.part_content_set('button2', btn) btn = Button(parent) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) self.part_content_set('button3', btn)
def __init__(self, rent): Box.__init__(self, rent) self.parent = rent #This appears on the button in the main swmai window self.name = "Startup Applications" #The section in the main window the button is added to self.section = "Applications" #Search terms that this module should appear for self.searchData = ["startup", "command", "applications", "apps"] #Command line argument to open this module directly self.launchArg = "--startupapps" #Should be none by default. This value is used internally by swami self.button = None self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html self.icon.standard_set('system-run') self.icon.show() self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() buttonBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) buttonBox.horizontal = True buttonApply = StandardButton(self, "Apply", "ok", self.applyPressed) buttonApply.show() buttonFlip = StandardButton(self, "Startup Commands", "preferences-system", self.flipPressed) buttonFlip.show() buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonApply) buttonBox.pack_end(buttonFlip) buttonBox.pack_end(buttonReturn) buttonBox.show() startupApplications = [] with open(StartupApplicationsFile, "a+") as startupFile: for line in startupFile: startupApplications.append(line.rstrip()) desktopFiles = [] for ourPath in ApplicationPaths: desktopFiles += [ os.path.join(dp, f) for dp, dn, filenames in os.walk(ourPath) for f in filenames if os.path.splitext(f)[1] == '.desktop' ] self.startupList = startupList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.applicationsList = applicationsList = SearchableList( self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) startupToAdd = [] applicationsToAdd = [] for d in desktopFiles: if os.access(d, os.R_OK): with open(d) as desktopFile: fileName = d.split("/")[-1] icon = None for line in desktopFile: if line[:5] == "Name=": name = line[5:][:-1] if line[:5] == "Icon=": icon = line[5:].strip() try: iconObj = Icon(self, standard=icon, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) except: iconObj = Icon(self, standard="preferences-system", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon = None if fileName in startupApplications: startupToAdd.append([name, iconObj, fileName, icon]) else: applicationsToAdd.append( [name, iconObj, fileName, icon]) else: # Broken link or file problem, inform user print "Swami IOError: [Errno 2] No such file or directory: {0}".format( d) startupToAdd.sort() applicationsToAdd.sort() for s in startupToAdd: ourItem = startupList.item_append(s[0], s[1]) ourItem.data["file"] = s[2] ourItem.data["icon"] = s[3] #ourItem.append_to(startupList) #startupList.item_append(ourItem) for a in applicationsToAdd: ourItem = applicationsList.item_append(a[0], a[1]) ourItem.data["file"] = a[2] ourItem.data["icon"] = a[3] #ourItem.append_to(applicationsList.ourList) #applicationsList.item_append(a[0], a[1]) startupList.callback_clicked_double_add(self.startupAppRemove) applicationsList.callback_clicked_double_add(self.startupAppAdd) startupList.go() startupList.show() applicationsList.show() startupFrame = Frame(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) startupFrame.text = "Startup Applications" startupFrame.content_set(startupList) startupFrame.show() otherFrame = Frame(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) otherFrame.text = "Other Applications" otherFrame.content_set(applicationsList) otherFrame.show() self.mainBox.pack_end(startupFrame) self.mainBox.pack_end(otherFrame) self.backBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.backBox.show() self.commandsList = commandsList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) with open(StartupCommandsFile, "a+") as scf: for line in scf: if line.rstrip()[-3:] == "| \\": commandsList.item_append(line.rstrip()[:-3]) else: commandsList.item_append(line.rstrip()) commandsList.callback_clicked_right_add(self.commandRightClicked) commandsList.go() commandsList.show() commandBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1, 0.5)) commandBox.horizontal = True commandBox.show() self.newCommandEntry = newCommandEntry = Entry( self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) newCommandEntry.single_line = True newCommandEntry.text = "<i>Type command here</i>" newCommandEntry.data["default text"] = True newCommandEntry.callback_clicked_add(self.entryClicked) newCommandEntry.show() newCommandButton = StandardButton(self, "Add Command", "add", self.newCmdPressed) newCommandButton.show() delCommandButton = StandardButton(self, "Delete Command", "exit", self.delCmdPressed) delCommandButton.show() commandBox.pack_end(newCommandButton) commandBox.pack_end(delCommandButton) newCommandFrame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) newCommandFrame.text = "Add Startup Command:" newCommandFrame.content_set(newCommandEntry) newCommandFrame.show() self.backBox.pack_end(commandsList) self.backBox.pack_end(newCommandFrame) self.backBox.pack_end(commandBox) self.flip = Flip(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.flip.part_content_set("front", self.mainBox) self.flip.part_content_set("back", self.backBox) self.flip.show() self.pack_end(self.flip) self.pack_end(buttonBox)
def calendar2_clicked(obj, item=None): weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] win = StandardWindow("calendar2", "Calendar 2", autodel=True) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bxh = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bxh.show() bx.pack_end(bxh) # Wide cal cal = Calendar(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, weekdays_names=weekdays, first_day_of_week=ELM_DAY_SATURDAY, interval=0.4, min_max_year=(2010, 2020)) cal.show() bx.pack_end(cal) # Top left cal cal2 = Calendar(bxh, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, select_mode=ELM_CALENDAR_SELECT_MODE_NONE) cal2.show() bxh.pack_end(cal2) # Top right cal cal3 = Calendar(bxh, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) selected_time = datetime.now() + timedelta(34) cal3.selected_time = selected_time selected_time = datetime.now() + timedelta(1) cal3.mark_add("checked", selected_time, ELM_CALENDAR_UNIQUE) del (cal3.marks) selected_time = datetime.now() cal3.mark_add("checked", selected_time, ELM_CALENDAR_DAILY) cal3.mark_add("holiday", selected_time, ELM_CALENDAR_DAILY) cal3.marks_draw() cal3.show() bxh.pack_end(cal3) en = Entry(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, editable=False) en.show() bx.pack_end(en) win.show() cal3.min_max_year = (-1, -1) # TODO: cal.format_function_set(format_month_year) selected_time = datetime.now() + timedelta(4) cal.mark_add("holiday", selected_time, ELM_CALENDAR_ANNUALLY) selected_time = datetime.now() + timedelta(1) cal.mark_add("checked", selected_time, ELM_CALENDAR_UNIQUE) selected_time = datetime.now() - timedelta(363) cal.mark_add("checked", selected_time, ELM_CALENDAR_MONTHLY) selected_time = datetime.now() - timedelta(5) mark = cal.mark_add("holiday", selected_time, ELM_CALENDAR_WEEKLY) selected_time = datetime.now() + timedelta(1) cal.mark_add("holiday", selected_time, ELM_CALENDAR_WEEKLY) mark.delete() cal.marks_draw() print_cal_info(cal, en) cal.callback_changed_add(print_cal_info_cb, en)
def __init__(self, parent, title='About', standardicon='dialog-information', version='N/A', authors='No One', licen='GPL', webaddress='', info='Something, something, turtles'): if AboutWindow.__initialized: raise InstanceError( "You can't create more than 1 instance of AboutWindow") AboutWindow.__initialized = True self.parent = parent Window.__init__(self, title, ELM_WIN_DIALOG_BASIC, autodel=True) self.callback_delete_request_add(self.cb_close) background = Background(self, size_hint_weight=EXPAND_BOTH) self.resize_object_add(background) background.show() frame = Frame(self, style='pad_large', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(frame) frame.show() hbox = Box(self, horizontal=True, padding=(12, 12)) frame.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 icon = Icon(self, size_hint_min=(64, 64)) icon.standard_set(standardicon) vbox.pack_end(icon) icon.show() ver_lb = Label(self, text=f'Version: {version}') vbox.pack_end(ver_lb) ver_lb.show() sep = Separator(self, horizontal=True) vbox.pack_end(sep) sep.show() # buttons btn = Button(self, text=(title), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.entry.text_set(info)) vbox.pack_end(btn) btn.show() btn = Button(self, text=('Website'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: xdg_open(webaddress)) vbox.pack_end(btn) btn.show() btn = Button(self, text=('Authors'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.entry.text_set(authors)) vbox.pack_end(btn) btn.show() btn = Button(self, text=('License'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.entry.text_set(licen)) vbox.pack_end(btn) btn.show() # main text self.entry = Entry(self, editable=False, scrollable=True, text=info, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.entry.callback_anchor_clicked_add(lambda e, i: xdg_open(i.name)) hbox.pack_end(self.entry) self.entry.show() self.resize(400, 200) self.show()
def __init__(self, parent, h): if not h.is_valid(): Information(parent.win, "Invalid torrent handle.") return if not h.has_metadata(): Information(parent.win, "Torrent contains no metadata.") return i = h.get_torrent_info() InnerWindow.__init__(self, parent.win) box = Box(self) box.size_hint_align = -1.0, -1.0 box.size_hint_weight = 1.0, 1.0 tname = Label(self) tname.size_hint_align = -1.0, 0.5 tname.line_wrap = ELM_WRAP_CHAR tname.ellipsis = True tname.text = "{}".format(cgi.escape(i.name())) tname.show() box.pack_end(tname) for func in i.comment, i.creation_date, i.creator: try: w = func() except Exception as e: log.debug(e) else: if w: f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = func.__name__.replace("_", " ").capitalize() l = Label(self) l.ellipsis = True l.text = cgi.escape(str(w)) l.show() f.content = l f.show() box.pack_end(f) tpriv = Check(self) tpriv.size_hint_align = 0.0, 0.0 tpriv.text = "Private" tpriv.tooltip_text_set("Whether this torrent is private.<br> \ i.e., it should not be distributed on the trackerless network<br> \ (the kademlia DHT).") tpriv.disabled = True tpriv.state = i.priv() magnet_uri = lt.make_magnet_uri(h) f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = "Magnet URI" me_box = Box(self) me_box.horizontal = True me = Entry(self) me.size_hint_align = -1.0, 0.0 me.size_hint_weight = 1.0, 0.0 #me.editable = False me.entry = magnet_uri me_box.pack_end(me) me.show() me_btn = Button(self) me_btn.text = "Copy" if hasattr(me, "cnp_selection_set"): me_btn.callback_clicked_add( lambda x: me.top_widget.cnp_selection_set( ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text)) else: import pyperclip me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri)) me_btn.show() me_box.pack_end(me_btn) me_box.show() f.content = me_box f.show() box.pack_end(f) fl_btn = Button(self) fl_btn.text = "Files ->" fl_btn.callback_clicked_add(self.file_list_cb, h) xbtn = Button(self) xbtn.text_set("Close") xbtn.callback_clicked_add(lambda x: self.delete()) for w in tpriv, fl_btn, xbtn: w.show() box.pack_end(w) box.show() nf = self.nf = Naviframe(self) nf.item_simple_push(box) self.content_set(nf) self.activate()
def tooltip_clicked(obj): win = StandardWindow("tooltips", "Tooltips", autodel=True, size=(400, 500)) 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() tb = Toolbar(win, homogeneous=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.pack_end(tb) tb.show() ti = tb.item_append("folder-new", "Open", None, None) ti.tooltip_text_set("Opens a file") ti = tb.item_append("clock", "Icon", None, None) ti.tooltip_content_cb_set(_tt_item_icon, None) ti.tooltip_style_set("transparent") bt = Button(win, text="Simple text tooltip") bt.tooltip_text_set("Simple text tooltip") bx.pack_end(bt) bt.show() def _tt_text_replace(obj, data): value = data.get("value") if not value: value = 1 obj.tooltip_text_set("count=%d" % value) value += 1 data["value"] = value bt = Button(win, text="Simple text tooltip, click to change") bt.tooltip_text_set("Initial") data = dict() bt.callback_clicked_add(_tt_text_replace, data) bx.pack_end(bt) bt.show() def _tt_text_replace_timer_cb(obj, data): _tt_text_replace(obj, data) return True def _tt_text_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Simple text tooltip, click to start changed timed") return data["timer"] = Timer(1.5, _tt_text_replace_timer_cb, obj, data) obj.text_set("Simple text tooltip, click to stop changed timed") bt = Button(win, text="Simple text tooltip, click to start changed timed") bt.tooltip_text_set("Initial") data = dict() bt.callback_clicked_add(_tt_text_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) bt = Button(win, text="Icon tooltip") bt.tooltip_content_cb_set(_tt_icon, None) bx.pack_end(bt) bt.show() def _tt_icon_replace_timer_cb(obj, data): value = data.get("value") data["value"] = not value if value: obj.tooltip_content_cb_set(_tt_icon) else: obj.tooltip_content_cb_set(_tt_icon2) return True def _tt_icon_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Icon tooltip, click to start changed timed") return data["timer"] = timer_add(1.5, _tt_icon_replace_timer_cb, obj, data) obj.text_set("Icon tooltip, click to stop changed timed") bt = Button(win, text="Icon tooltip, click to start changed timed") bt.tooltip_content_cb_set(_tt_icon) data = dict() bt.callback_clicked_add(_tt_icon_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) bt = Button(win, text="Transparent Icon tooltip") bt.tooltip_content_cb_set(_tt_icon, None) bt.tooltip_style_set("transparent") bx.pack_end(bt) bt.show() def _tt_style_replace_timer_cb(obj, data): value = data.get("value") data["value"] = not value if value: obj.tooltip_style_set() else: obj.tooltip_style_set("transparent") return True def _tt_style_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Icon tooltip style, click to start changed timed") return data["timer"] = timer_add(1.5, _tt_style_replace_timer_cb, obj, data) obj.text_set("Icon tooltip, click to stop changed timed") bt = Button(win, text="Icon tooltip style, click to start changed timed") bt.tooltip_content_cb_set(_tt_icon, None) data = dict() bt.callback_clicked_add(_tt_style_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) def _tt_visible_lock_toggle(obj, data, *args, **kargs): value = data.get("value") data["value"] = not value if value: obj.text_set("Unlocked tooltip visibility") obj.tooltip_hide() else: obj.text_set("Locked tooltip visibility") obj.tooltip_show() bt = Button(win, text="Unlocked tooltip visibility") bt.tooltip_text_set( "This tooltip is unlocked visible,<br> click the button to lock!") data = dict() bt.callback_clicked_add(_tt_visible_lock_toggle, data) bx.pack_end(bt) bt.show() def _tt_move_freeze_toggle(obj, *args, **kargs): if obj.tooltip_move_freeze_get(): obj.text_set("Unfreezed tooltip movement") obj.tooltip_move_freeze_pop() else: obj.text_set("Freezed tooltip movement") obj.tooltip_move_freeze_push() bt = Button(win, text="Freezed tooltip movement") bt.tooltip_text_set( "This tooltip has freezed movement,<br> click the button to unfreeze!") bt.tooltip_move_freeze_push() bt.callback_clicked_add(_tt_move_freeze_toggle) bx.pack_end(bt) bt.show() en = Entry(win, scrollable=True, single_line=True, entry="Hello, some scrolled entry here!", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.tooltip_text_set("Type something here!") bx.pack_end(en) en.show() lst = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, size_hint_min=(100, 100)) li = lst.item_append("Hello") li.tooltip_text_set("Something useful here?") li = lst.item_append("Icon Tooltip") li.tooltip_content_cb_set(_tt_item_icon, None) bx.pack_end(lst) lst.go() lst.show() win.show()
def __init__(self, command=None, win=None, start_callback=None, end_callback=None, *args, **kwargs): if not win: nowindow = True win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC) win.title = "eSudo" win.borderless = True 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.layer_set(11) #~ win.fullscreen = True win.show() win.activate() bg = Background(win) bg.size_hint_weight = 1.0, 1.0 win.resize_object_add(bg) bg.show() self.embedded = False else: nowindow = False self.embedded = True self.cmd = command self.start_cb = start_callback if callable(start_callback) else None self.end_cb = end_callback if callable(end_callback) else None self.args = args self.kwargs = kwargs #--------eSudo Window bz = Box(win) if nowindow: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 else: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.show() if nowindow: lbl = Label(win) lbl.style = "marker" lbl.color = 170, 170, 170, 255 lbl.size_hint_align = 0.5, 0.0 lbl.scale = 2.0 lbl.text = "<b>eSudo</b>" bz.pack_end(lbl) lbl.show() sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() fr = Frame(win) fr.text = "Command:" fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.pack_end(fr) fr.show() if nowindow: sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() self.cmdline = cmdline = Entry(win) cmdline.elm_event_callback_add(self.entry_event) cmdline.single_line = True if self.cmd: cmdline.text = self.cmd cmdline.editable = False fr.content = cmdline cmdline.scrollable_set(True) cmdline.show() if nowindow: fr = Frame(win) fr.text = "Password:"******"<b>Password:</b>" lb.size_hint_align = 0.0, 0.5 bz1.pack_end(lb) lb.show() en = self.en = Entry(win) en.name = "password" en.elm_event_callback_add(self.entry_event) en.single_line = True en.password = True en.show() if nowindow: fr.content = en else: bz1.pack_end(en) sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() btnb = Box(win) btnb.horizontal = True btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bz.pack_end(btnb) btnb.show() bt = Button(win) bt.text = "Cancel" bt.callback_clicked_add(self.esudo_cancel, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() bt = Button(win) bt.text = "OK" bt.callback_clicked_add(self.password_check, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() self.iw = iw = InnerWindow(win) iw.content = bz iw.show() iw.activate() if self.cmd: en.focus = True
def __init__(self, parent, title, rfunc, wfunc): Frame.__init__(self, parent) self.size_hint_weight = EXPAND_HORIZ self.size_hint_align = FILL_HORIZ self.text = title t = Table(self, homogeneous=True, padding=(3, 3)) t.size_hint_weight = EXPAND_HORIZ t.size_hint_align = FILL_HORIZ t.show() l = Label(self, text="Proxy type") l.size_hint_align = 0.0, 0.5 l.show() ptype = Hoversel(parent) ptype.size_hint_align = -1.0, 0.5 ptype.text = rfunc().type.name for n in self.proxy_types.iterkeys(): ptype.item_add(n, callback=lambda x, y, z=n: ptype.text_set(z)) ptype.show() t.pack(l, 0, 0, 1, 1) t.pack(ptype, 1, 0, 1, 1) l = Label(self, text="Hostname") l.size_hint_align = 0.0, 0.5 l.show() phost = Entry(parent) phost.size_hint_weight = EXPAND_HORIZ phost.size_hint_align = FILL_HORIZ phost.single_line = True phost.scrollable = True phost.entry = rfunc().hostname phost.show() t.pack(l, 0, 1, 1, 1) t.pack(phost, 1, 1, 1, 1) l = Label(self, text="Port") l.size_hint_align = 0.0, 0.5 l.show() pport = Spinner(parent) pport.size_hint_align = -1.0, 0.5 pport.min_max = 0, 65535 pport.value = rfunc().port pport.show() t.pack(l, 0, 2, 1, 1) t.pack(pport, 1, 2, 1, 1) l = Label(self, text="Username") l.size_hint_align = 0.0, 0.5 l.show() puser = Entry(parent) puser.size_hint_weight = EXPAND_HORIZ puser.size_hint_align = FILL_HORIZ puser.single_line = True puser.scrollable = True puser.entry = rfunc().username puser.show() t.pack(l, 0, 3, 1, 1) t.pack(puser, 1, 3, 1, 1) l = Label(self, text="Password") l.size_hint_align = 0.0, 0.5 l.show() ppass = Entry(parent) ppass.size_hint_weight = EXPAND_HORIZ ppass.size_hint_align = FILL_HORIZ ppass.single_line = True ppass.scrollable = True ppass.password = True ppass.entry = rfunc().password ppass.show() t.pack(l, 0, 4, 1, 1) t.pack(ppass, 1, 4, 1, 1) entries = [ptype, phost, pport, puser, ppass] save = Button(parent, text="Apply") save.callback_clicked_add(self.save_conf, wfunc, entries) save.show() t.pack(save, 0, 5, 2, 1) self.content = t