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): StandardWindow.__init__(self, "ex8", "ElmEx - Button and Popup", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourButton = StandardButton(self, "Show Popup", "start-here", self.buttonPressed) ourButton.size_hint_weight = EXPAND_HORIZ ourButton.size_hint_align = FILL_BOTH ourButton.show() ourButton2 = StandardButton(self, "Show About", "dialog-information", self.button2Pressed) ourButton2.size_hint_weight = EXPAND_HORIZ ourButton2.size_hint_align = FILL_BOTH ourButton2.show() mainBox = Box(self) mainBox.size_hint_weight = EXPAND_BOTH mainBox.size_hint_align = FILL_BOTH mainBox.pack_end(ourButton) mainBox.pack_end(ourButton2) mainBox.show() self.resize_object_add(mainBox)
def __init__(self, parent): Frame.__init__(self, parent, text="Signals") self._parent = parent vbox = Box(self) vbox.show() self.content = vbox self.siglist = Genlist(self, homogeneous=True, mode=ELM_LIST_SCROLL) self.siglist.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND self.siglist.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self.siglist.callback_clicked_double_add(self.signal_clicked_cb) self.siglist.show() vbox.pack_end(self.siglist) self.itc = SignalItemClass() hbox = Box(self, horizontal=True) hbox.size_hint_align = 0.0, 0.5 hbox.show() vbox.pack_end(hbox) bt = Button(self, text='Clear') bt.callback_clicked_add(lambda b: self.siglist.clear()) hbox.pack_end(bt) bt.show() def scroll_on_signal_clicked_cb(chk): options.scroll_on_signal = chk.state ck = Check(self, text='Scroll on signal') ck.state = options.scroll_on_signal ck.callback_changed_add(scroll_on_signal_clicked_cb) hbox.pack_end(ck) ck.show() for b in session_bus, system_bus: b.add_signal_receiver(self.signal_cb, sender_keyword='sender', destination_keyword='dest', interface_keyword='iface', member_keyword='signal', path_keyword='path')
def __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, 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 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, method): StandardWindow.__init__(self, "espionage", "Method", autodel=True) self._method = method self._param_entry = None self._return_entry = None # content is vbox (with surrounding pad frame) pad = Frame(self, style='pad_medium') pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self.resize_object_add(pad) pad.show() vbox = Box(self) vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL pad.content = vbox vbox.show() # title f = "font_size=16 align=0.5 font_weight=Bold" en = Entry(self, text='<font %s>%s()</>' % (f, method.name)) en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 en.size_hint_align = EVAS_HINT_FILL, 0.0 en.editable = False vbox.pack_end(en) en.show() # params label + entry if len(method.params) > 0: label = Entry(self, editable=False) label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 label.size_hint_align = EVAS_HINT_FILL, 0.0 pars = colored_params(method.params, omit_braces=True) label.text = 'Params: %s' % (pars if method.params else 'None') vbox.pack_end(label) label.show() en = Entry(self, editable=True, scrollable=True, single_line=True) en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 en.size_hint_align = EVAS_HINT_FILL, 0.0 self._param_entry = en vbox.pack_end(en) en.show() # returns label + entry label = Entry(self, editable=False) label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 label.size_hint_align = EVAS_HINT_FILL, 0.0 rets = colored_params(method.returns, omit_braces=True) label.text = 'Returns: %s' % (rets if method.returns else 'None') vbox.pack_end(label) label.show() en = Entry(self, editable=False, scrollable=True) en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL self._return_entry = en vbox.pack_end(en) en.show() # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state ch = Check(self) 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) sep = Separator(self, horizontal=True) vbox.pack_end(sep) sep.show() # buttons hbox = Box(self, horizontal=True) hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0 hbox.size_hint_align = EVAS_HINT_FILL, 0.5 vbox.pack_end(hbox) hbox.show() btn = Button(self) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(btn) btn.show() btn = Button(self) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) hbox.pack_end(btn) btn.show() btn = Button(self) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) hbox.pack_end(btn) btn.show() # show the window self.resize(300, 300) self.show()