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 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, 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, 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
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