def __init__(self, parent, conf): Frame.__init__(self, parent) self.size_hint_align = -1.0, 0.0 self.size_hint_weight = 1.0, 0.0 self.text = "Data storage" self.conf = conf b = Box(parent) lbl = self.path_lbl = Label(parent) lbl.text = conf.get("Settings", "storage_path") self.dlsel = dlsel = FileselectorButton(self) dlsel.size_hint_align = -1.0, 0.0 dlsel.inwin_mode = False dlsel.folder_only = True dlsel.expandable = False dlsel.text = "Change path" dlsel.path = conf.get("Settings", "storage_path") dlsel.callback_file_chosen_add(self.save_dlpath) for w in lbl, dlsel: w.show() b.pack_end(w) b.show() self.content = b
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, rent): Box.__init__(self, rent) self.parent = rent #This appears on the button in the main swmai window self.name = "Light DM" #The section in the main window the button is added to self.section = "System Settings" #Search terms that this module should appear for self.searchData = ["lightdm", "autologin", "login", "display"] #Command line argument to open this module directly self.launchArg = "--lightdm" #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('video-display') self.icon.show() self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.config = {} with open(LightDMConf) as f: for line in f: #Sections start with [ - such as [SeatDefaults] if line[0] != "[": setting, value = line.replace("\n", "").split("=") e = Entry(self) e.single_line_set(True) e.text = value e.show() f = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) f.text = setting f.content = e f.show() self.mainBox.pack_end(f) self.config[setting] = f buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH) buttonBox.horizontal = True buttonSave = StandardButton(self, "Save Changes", "ok", self.savePressed) buttonSave.show() buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonSave) buttonBox.pack_end(buttonReturn) buttonBox.show() self.pack_end(self.mainBox) self.pack_end(buttonBox)
def __init__(self, parent, session): Frame.__init__(self, parent) self.text = "Limits" self.size_hint_align = FILL_HORIZ base = 1024 units = ( "bytes/s", "KiB/s", "MiB/s", "GiB/s", "TiB/s" ) t = Table(parent) for r, values in enumerate(( ("Upload limit", session.upload_rate_limit, session.set_upload_rate_limit), ("Download limit", session.download_rate_limit, session.set_download_rate_limit), ("Upload limit for local connections", session.local_upload_rate_limit, session.set_local_upload_rate_limit), ("Download limit for local connections", session.local_download_rate_limit, session.set_local_download_rate_limit), )): title, rfunc, wfunc = values l = Label(parent) l.text = title l.size_hint_align = FILL_HORIZ t.pack(l, 0, r, 1, 1) l.show() usw = UnitSpinner(parent, base, units) usw.size_hint_weight = EXPAND_HORIZ usw.size_hint_align = FILL_HORIZ usw.set_value(rfunc()) usw.callback_changed_add(wfunc, delay=2.0) t.pack(usw, 1, r, 1, 1) usw.show() self.content = t
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 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 __init__(self, parent, text=None, icon=None): Entry.__init__(self, parent, scrollable=True, single_line=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self.show() if text: self.text = text if icon: self.icon = icon ic = SafeIcon(self, 'go-down') ic.size_hint_min = 16, 16 # TODO file a bug for elm on phab ic.callback_clicked_add(self.activate) self.part_content_set('end', ic) self._itc = GenlistItemClass(item_style='default', text_get_func=self._gl_text_get, content_get_func=self._gl_content_get) self._list = Genlist(self) self._list.callback_selected_add(self._list_selected_cb) self._hover = Hover(self.parent, target=self) self._bg = Background(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) fr = Frame(self, style='pad_medium', size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) fr.content = self._list fr.show() self._table = Table(self, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) self._table.pack(self._bg, 0, 0, 1, 1) self._table.pack(fr, 0, 0, 1, 1) self._selected_func = None
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 FRAME(win, bx, t): bx2 = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=(EVAS_HINT_FILL, 0.0), align=(0.0, 0.5)) bx2.show() fr = Frame(bx, text=t, content=bx2, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(fr) fr.show() return fr, bx2
def genlist10_clicked(obj, item=None): win = StandardWindow("genlist-decorate-item-mode", "Genlist Decorate Item Mode", autodel=True, size=(520, 520)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bx2 = Box(win) bx2.show() fr = Frame(win, text="Decorate Item Mode Type", content=bx2) bx.pack_end(fr) fr.show() rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=0, text="Slide : Sweep genlist items to the right.") rd.show() bx2.pack_end(rd) rdg = rd rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=1, text="Rotate : Click each item.") rd.group_add(rdg) rd.show() bx2.pack_end(rd) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) gl.callback_drag_start_right_add(my_gl_mode_right, rdg) gl.callback_drag_start_left_add(my_gl_mode_left, rdg) gl.callback_drag_start_up_add(my_gl_mode_cancel, rdg) gl.callback_drag_start_down_add(my_gl_mode_cancel, rdg) gl.show() itc10 = ItemClass10(item_style="default", decorate_item_style="mode") itc10.state_get = gl_state_get for i in range(1000, 1050): GenlistItem(item_class=itc10, item_data=i, parent_item=None, flags=ELM_GENLIST_ITEM_NONE, func=gl_sel10, func_data=(i, rdg)).append_to(gl) bx.pack_end(gl) win.size = 520, 520 win.show()
def __init__(self, parent_widget, ourText=None, image=None, *args, **kwargs): Frame.__init__(self, parent_widget, *args, **kwargs) self.text = ourText self.ourImage = Image(self) self.ourImage.size_hint_weight = EXPAND_BOTH if image: self.ourImage.file_set(image) self.content_set(self.ourImage)
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 genlist10_clicked(obj, item=None): win = StandardWindow("genlist-decorate-item-mode", "Genlist Decorate Item Mode", autodel=True, size=(520, 520)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() bx2 = Box(win) bx2.show() fr = Frame(win, text="Decorate Item Mode Type", content=bx2) bx.pack_end(fr) fr.show() rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=0, text="Slide : Sweep genlist items to the right.") rd.show() bx2.pack_end(rd) rdg = rd rd = Radio(win, size_hint_weight=EXPAND_BOTH, state_value=1, text = "Rotate : Click each item.") rd.group_add(rdg) rd.show() bx2.pack_end(rd) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) gl.callback_drag_start_right_add(my_gl_mode_right, rdg) gl.callback_drag_start_left_add(my_gl_mode_left, rdg) gl.callback_drag_start_up_add(my_gl_mode_cancel, rdg) gl.callback_drag_start_down_add(my_gl_mode_cancel, rdg) gl.show() itc10 = ItemClass10(item_style="default", decorate_item_style="mode") itc10.state_get = gl_state_get for i in range(1000, 1050): GenlistItem(item_class=itc10, item_data=i, parent_item=None, flags=ELM_GENLIST_ITEM_NONE, func=gl_sel10, func_data=(i, rdg) ).append_to(gl) bx.pack_end(gl) win.size = 520, 520 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 buildMainBox(self): # build our toolbar self.mainTb = Toolbar(self, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.mainTb.item_append("remove", "Clear", self.clearPressed) self.mainTb.item_append("system-run", "Select All", self.selectAllPressed) self.mainTb.item_append("view-refresh", "Refresh", self.refreshPressed) self.mainTb.item_append("info", "Log", self.detailsPressed) self.mainTb.item_append("ok", "Apply", self.installUpdatesPressed) self.mainTb.show() # build our sortable list that displays packages that need updates titles = [("Upgrade", True), ("Package", True), ("Installed", True), ("Available", True)] scr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.packageList = sl.SortedList(scr, titles=titles, homogeneous=False, size_hint_weight=EXPAND_HORIZ) scr.content = self.packageList scr.show() # build the label that shows the package's description self.currentDescription = Label(self, size_hint_weight=FILL_BOTH) self.currentDescription.text = "Select a package for information" self.currentDescription.line_wrap_set(True) self.currentDescription.show() self.desFrame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.desFrame.text = "Description" self.desFrame.content = self.currentDescription self.desFrame.show() # add all of our objects to the box box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(self.mainTb) box.pack_end(scr) box.pack_end(self.desFrame) box.show() return box
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 __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
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): self.cfg = ConfigOption() self.userid = os.getuid() self.win = None self.bg = None self.main_box = None self.info_frame = None self.lb = None self.ps_list = None self.win = StandardWindow("my app", "eyekill", size=(320, 384)) self.win.title_set("eye kill") self.win.callback_delete_request_add(self.destroy) self.main_box = Box(self.win) self.main_box.size_hint_weight = EXPAND_BOTH self.win.resize_object_add(self.main_box) self.main_box.show() self.info_frame = Frame(self.win) self.info_frame.text_set("Information") self.main_box.pack_end(self.info_frame) self.info_frame.show() self.lb = Label(self.win) self.lb.text_set('<b>Kill process with a double click</b>') self.info_frame.content_set(self.lb) self.lb.show() self.ps_list = List(self.win) self.ps_list.size_hint_weight = EXPAND_BOTH self.ps_list.size_hint_align = FILL_BOTH self.ps_list.callback_clicked_double_add(self.kill_bill) self.update_list() self.main_box.pack_end(self.ps_list) self.ps_list.go() self.ps_list.show() self.win.resize(320, 384) self.win.show()
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 __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 __init__(self, parent, session): Frame.__init__(self, parent) self.text = "Limits" self.size_hint_align = FILL_HORIZ base = 1024 units = ("bytes/s", "KiB/s", "MiB/s", "GiB/s", "TiB/s") t = Table(parent) for r, values in enumerate(( ("Upload limit", session.upload_rate_limit, session.set_upload_rate_limit), ("Download limit", session.download_rate_limit, session.set_download_rate_limit), ("Upload limit for local connections", session.local_upload_rate_limit, session.set_local_upload_rate_limit), ("Download limit for local connections", session.local_download_rate_limit, session.set_local_download_rate_limit), )): title, rfunc, wfunc = values l = Label(parent) l.text = title l.size_hint_align = FILL_HORIZ t.pack(l, 0, r, 1, 1) l.show() usw = UnitSpinner(parent, base, units) usw.size_hint_weight = EXPAND_HORIZ usw.size_hint_align = FILL_HORIZ usw.set_value(rfunc()) usw.callback_changed_add(wfunc, delay=2.0) t.pack(usw, 1, r, 1, 1) usw.show() self.content = t
def __init__(self, rent): Box.__init__(self, rent) self.parent = rent #This appears on the button in the main swmai window self.name = "Light DM" #The section in the main window the button is added to self.section = "System Settings" #Search terms that this module should appear for self.searchData = ["lightdm", "autologin", "login", "display"] #Command line argument to open this module directly self.launchArg = "--lightdm" #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('video-display') self.icon.show() self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.config = {"sections": []} with open(LightDMConf) as f: currentSection = None for line in f: #Sections start with [ - such as [SeatDefaults] if line[0] == "[": self.config["sections"].append(line) currentSection = line.rstrip() s = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) s.text = currentSection[1:-1] s.show() sectionBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) sectionBox.show() s.content = sectionBox self.mainBox.pack_end(s) elif line[0] not in ["[", "\n"]: setting, value = line.replace("\n", "").split("=") e = Entry(self) e.single_line_set(True) e.text = value e.show() f = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) f.text = setting f.content = e f.show() sectionBox.pack_end(f) self.config[setting] = [f, currentSection] buttonBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) buttonBox.horizontal = True buttonSave = StandardButton(self, "Save Changes", "ok", self.savePressed) buttonSave.show() buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonSave) buttonBox.pack_end(buttonReturn) buttonBox.show() self.pack_end(self.mainBox) self.pack_end(buttonBox)
elementary.init() win = StandardWindow("test", "python-elementary test application", size=(320,520)) win.callback_delete_request_add(lambda o: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text_set("Please select a test from the list below<br>" "by clicking the test button to show the<br>" "test window.") lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() items = [ ("Transit", transit_clicked), ("Transit Resize", transit2_clicked), ("Transit Flip", transit3_clicked), ("Transit Zoom", transit4_clicked), ("Transit Blend", transit5_clicked), ("Transit Fade", transit6_clicked), ("Transit Resizable", transit7_clicked), ("Transit Custom", transit8_clicked), ("Transit Chain", transit9_clicked), ]
def slider_clicked(obj): win = StandardWindow("slider", "Slider", autodel=True) if obj is None: win.callback_delete_request_add(lambda x: elementary.exit()) win.show() fr = Frame(win, size_hint_weight=EXPAND_BOTH, style="pad_large") win.resize_object_add(fr) fr.show() bx = Box(win) fr.content = bx bx.show() # disabled horizontal slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Disabled", unit_format="%1.1f units", span_size=120, min_max=(50, 150), value=80, disabled=True, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl.part_content_set("icon", ic) bx.pack_end(sl) sl.show() step = step_size_calculate(0, 9) sl = Slider(bx, unit_format="%1.0f units", indicator_format="%1.0f", span_size=120, min_max=(0, 9), text="Manual step", step=step, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bx.pack_end(sl) sl.show() # normal horizontal slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) sl1 = sl = Slider(bx, text="Horizontal", unit_format="%1.1f units", indicator_format="%1.1f", span_size=120, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl.part_content_set("icon", ic) bx.pack_end(sl) ic.show() sl.show() # horizontally inverted slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Horizontal inverted", unit_format="%3.0f units", span_size=80, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) sl.part_content_set("end", ic) sl.callback_delay_changed_add(delay_change_cb) bx.pack_end(sl) sl.show() # disabled horizontally inverted slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Disabled inverted", span_size=80, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, disabled=True, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) sl.part_content_set("end", ic) bx.pack_end(sl) sl.show() # scale doubled slider sl = Slider(bx, indicator_show=False, text="Scale doubled", unit_format="%3.0f units", span_size=40, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, scale=2.0) bx.pack_end(sl) sl.show() # horizontal box bx2 = Box(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_VERT, horizontal=True) bx.pack_end(bx2) bx2.show() # vertical inverted slider ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1)) ic.show() sl = Slider(bx2, text="Vertical inverted", inverted=True, unit_format="%1.1f units", span_size=60, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False) sl.part_content_set("icon", ic) bx2.pack_end(sl) sl.show() sl1.callback_changed_add(change_cb, sl) # disabled vertical slider ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1)) sl = Slider(bx2, text="Disabled vertical", inverted=True, unit_format="%1.1f units", span_size=100, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False) # # XXX: If vertical mode is set after disabled, it's no longer disabled. # Elm bug? # sl.disabled = True sl.part_content_set("icon", ic) bx2.pack_end(sl) sl.show() # normal vertical slider sl = Slider(bx2, text="Vertical", unit_format="%1.1f units", span_size=60, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_show=False, value=0.2, scale=1.0, horizontal=False) sl.callback_changed_add(change_print_cb, sl) bx2.pack_end(sl) sl.show() # box for bottom buttons bx2 = Box(win,size_hint_weight=EXPAND_HORIZ, horizontal=True) bx.pack_end(bx2) bx2.show() bt = Button(win, text="0") bt.callback_clicked_add(bt_0, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="1") bt.callback_clicked_add(bt_1, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="+0.1") bt.callback_clicked_add(bt_p1, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="-0.1") bt.callback_clicked_add(bt_m1, sl) bt.show() bx2.pack_end(bt)
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 colorselector_clicked(obj): win = StandardWindow("colorselector", "ColorSelector test", autodel=True, size=(350, 350)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() re = Rectangle(win.evas) re.size_hint_min = (1, 100) re.show() fr = Frame(win, text="Color View", content=re, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() cs = Colorselector(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, color=(255, 160, 132, 255)) cs.callback_changed_add(cb_cs_changed, re) cs.callback_color_item_selected_add(cb_cs_item_sel, re) cs.callback_color_item_longpressed_add(cb_cs_item_lp, re) cs.show() fr = Frame(win, text="Color Selector", content=cs, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() re.color = cs.color cs.palette_color_add(255, 90, 18, 255) cs.palette_color_add(255, 213, 0, 255) cs.palette_color_add(146, 255, 11, 255) cs.palette_color_add(9, 186, 10, 255) cs.palette_color_add(86, 201, 242, 255) cs.palette_color_add(18, 83, 128, 255) cs.palette_color_add(140, 53, 238, 255) cs.palette_color_add(255, 145, 145, 255) cs.palette_color_add(255, 59, 119, 255) cs.palette_color_add(133, 100, 69, 255) cs.palette_color_add(255, 255, 119, 255) cs.palette_color_add(133, 100, 255, 255) last_item = cs.palette_items_get()[-1] last_item.color = (255, 0, 0, 255) hbox = Box(win, horizontal=True, size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Palette", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_PALETTE)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Components", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add( lambda btn: cs.mode_set(ELM_COLORSELECTOR_COMPONENTS)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Both", size_hint_align=FILL_AND_ALIGN_TOP, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: cs.mode_set(ELM_COLORSELECTOR_BOTH)) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="palette items", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(palette_items, cs) hbox.pack_end(bt) bt.show() bt = Button(win, text="palette selected item", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(selected_item_get, cs) hbox.pack_end(bt) bt.show() win.show()
def fileselector_clicked(obj, item=None): win = StandardWindow("fileselector", "File selector test", autodel=True, size=(500,500)) box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box1) box1.show() fs = Fileselector(win, is_save=True, expandable=False, folder_only=False, path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fs.callback_done_add(fs_cb_done, win) fs.callback_selected_add(fs_cb_selected, win) fs.callback_directory_open_add(fs_cb_directory_open, win) box1.pack_end(fs) fs.show() fs.custom_filter_append(custom_filter_all, filter_name="All Files") fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files") fs.mime_types_filter_append(["text/*"], "Text Files") fs.mime_types_filter_append(["image/*"], "Image Files") sep = Separator(win) box1.pack_end(sep) sep.show() vbox = Box(win) box1.pack_end(vbox) vbox.show() # Options frame fr = Frame(win, text="Options") vbox.pack_end(fr) fr.show() fbox1 = Box(win) fr.content = fbox1 fbox1.show() fbox2 = Box(win, horizontal=True) fbox1.pack_end(fbox2) fbox2.show() ck = Check(win, text="is_save", state=fs.is_save) ck.callback_changed_add(ck_cb_is_save, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="folder_only", state=fs.folder_only) ck.callback_changed_add(ck_cb_folder_only, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="expandable", state=fs.expandable) ck.callback_changed_add(ck_cb_expandable, fs) fbox2.pack_end(ck) ck.show() fbox2 = Box(win, horizontal=True) fbox1.pack_end(fbox2) fbox2.show() ck = Check(win, text="multiple selection", state=fs. multi_select) ck.callback_changed_add(ck_cb_multi_select, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="buttons", state=fs.buttons_ok_cancel) ck.callback_changed_add(ck_cb_buttons, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="hidden", state=fs.hidden_visible) ck.callback_changed_add(ck_cb_hidden, fs) fbox2.pack_end(ck) ck.show() # Getters frame fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() fbox = Box(win, horizontal=True) fr.content = fbox fbox.show() bt = Button(win, text="selected_get") bt.callback_clicked_add(bt_cb_sel_get, fs) fbox.pack_end(bt) bt.show() bt = Button(win, text="path_get") bt.callback_clicked_add(bt_cb_path_get, fs) fbox.pack_end(bt) bt.show() bt = Button(win, text="selected_paths") bt.callback_clicked_add(bt_cb_paths_get, fs) fbox.pack_end(bt) bt.show() # Mode frame fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() fbox = Box(win, horizontal=True) fr.content = fbox fbox.show() rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST) rd.callback_changed_add(rd_cb_mode, fs) fbox.pack_end(rd) rd.show() rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID) rd.callback_changed_add(rd_cb_mode, fs) rd.group_add(rdg) fbox.pack_end(rd) rd.show() # Thumbsize frame fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() sl = Slider(win, min_max=(4, 130), unit_format="%.0f px", value=fs.thumbnail_size[0]) sl.callback_delay_changed_add(sl_cb_thumb_size, fs) fr.content = sl sl.show() # Sort method frame fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() hs = Hoversel(win, text="File name (asc)") sorts = ( ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC), ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC), ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC), ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC), ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC), ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC), ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC), ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC), ) for sort in sorts: hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1]) fr.content = hs hs.show() win.show()
class Application(object): def __init__(self): self.cfg = ConfigOption() self.userid = os.getuid() self.win = None self.bg = None self.main_box = None self.info_frame = None self.lb = None self.ps_list = None self.win = StandardWindow("my app", "eyekill", size=(320, 384)) self.win.title_set("eye kill") self.win.callback_delete_request_add(self.destroy) self.main_box = Box(self.win) self.main_box.size_hint_weight = EXPAND_BOTH self.win.resize_object_add(self.main_box) self.main_box.show() self.info_frame = Frame(self.win) self.info_frame.text_set("Information") self.main_box.pack_end(self.info_frame) self.info_frame.show() self.lb = Label(self.win) self.lb.text_set('<b>Kill process with a double click</b>') self.info_frame.content_set(self.lb) self.lb.show() self.ps_list = List(self.win) self.ps_list.size_hint_weight = EXPAND_BOTH self.ps_list.size_hint_align = FILL_BOTH self.ps_list.callback_clicked_double_add(self.kill_bill) self.update_list() self.main_box.pack_end(self.ps_list) self.ps_list.go() self.ps_list.show() self.win.resize(320, 384) self.win.show() def destroy(self, obj): # FIXME: but here self.cfg.save()??? elementary.exit() def update_list(self): if bool(self.cfg.get_desktop()): for de in self.cfg.get_desktop(): ps = psutil.Process(get_pid_by_name(de)) pl = ps.children() for p in pl: if p.uids().real == self.userid: if p.name not in self.cfg.get_process(): short_info = '%s / %s / %s' % (p.pid, p.name(), p.status()) self.ps_list.item_append(label=short_info, callback=self.update_info, p=p) else: pl = psutil.get_pid_list() for p in pl: p = psutil.Process(p) if p.uids().real == self.userid: if p.name() not in self.cfg.get_process(): short_info = '%s / %s / %s' % (p.pid, p.name(), p.status()) self.ps_list.item_append(label=short_info, callback=self.update_info, p=p) def update_info(self, li, it, p): info = ("PID %i STAT %s TIME %s<br/>MEM %s CPU %s COMMAND %s" % \ (p.pid,\ p.status(),\ p.get_cpu_times().user,\ hbytes(p.get_memory_info().rss),\ p.get_cpu_percent(interval=0),\ p.name())) self.lb.text_set(info) def kill_bill(self, obj, cb_data): bill = cb_data.data_get()[1]['p'].pid print("%s ... Gotcha" % bill) os.kill(bill, signal.SIGTERM) if (os.kill(bill, 0)): os.kill(bill, signal.SIGKILL) item = obj.selected_item_get() item.disabled_set(True)
def __init__(self, app): self.app = app self.prog_popup = None # the window StandardWindow.__init__(self, 'epack', 'Epack') self.autodel_set(True) self.callback_delete_request_add(lambda o: self.app.exit()) # main vertical box vbox = Box(self, size_hint_weight=EXPAND_BOTH) self.resize_object_add(vbox) vbox.show() ### header horiz box (inside a padding frame) frame = Frame(self, style='pad_medium', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(frame) frame.show() self.header_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) frame.content = self.header_box self.header_box.show() # genlist with archive content self.file_itc = GenlistItemClass(item_style="no_icon", text_get_func=gl_file_text_get) self.fold_itc = GenlistItemClass(item_style="one_icon", text_get_func=gl_fold_text_get, content_get_func=gl_fold_icon_get) self.file_list = Genlist(self, homogeneous=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.file_list.callback_expand_request_add(self._gl_expand_req_cb) self.file_list.callback_contract_request_add(self._gl_contract_req_cb) self.file_list.callback_expanded_add(self._gl_expanded_cb) self.file_list.callback_contracted_add(self._gl_contracted_cb) vbox.pack_end(self.file_list) self.file_list.show() ### footer table (inside a padding frame) frame = Frame(self, style='pad_medium', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(frame) frame.show() table = Table(frame) frame.content = table table.show() # FileSelectorButton self.fsb = DestinationButton(app, self) table.pack(self.fsb, 0, 0, 3, 1) self.fsb.show() sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ) table.pack(sep, 0, 1, 3, 1) sep.show() # extract button self.extract_btn = Button(table, text=_('Extract')) self.extract_btn.callback_clicked_add(self.extract_btn_cb) table.pack(self.extract_btn, 0, 2, 1, 2) self.extract_btn.show() sep = Separator(table, horizontal=False) table.pack(sep, 1, 2, 1, 2) sep.show() # delete-archive checkbox self.del_chk = Check(table, text=_('Delete archive after extraction'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) self.del_chk.callback_changed_add(self.del_check_cb) table.pack(self.del_chk, 2, 2, 1, 1) self.del_chk.show() # create-archive-folder checkbox self.create_folder_chk = Check(table, text=_('Create archive folder'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 1.0)) table.pack(self.create_folder_chk, 2, 3, 1, 1) self.create_folder_chk.callback_changed_add( lambda c: self.update_fsb_label()) self.create_folder_chk.show() # set the correct ui state self.update_ui() # show the window self.resize(300, 380) 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()
win = StandardWindow("test", "python-elementary test application", size=(320, 520)) win.callback_delete_request_add(lambda o: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text_set("Please select a test from the list below<br>" "by clicking the test button to show the<br>" "test window.") lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() items = [ ("Conformant", conformant_clicked), ("Conformant 2", conformant2_clicked), ] li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box0.pack_end(li) li.show() for item in items: li.item_append(item[0], callback=item[1])
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()
def fileselector_clicked(obj, item=None): win = StandardWindow("fileselector", "File selector test", autodel=True, size=(500, 500)) box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box1) box1.show() fs = Fileselector(win, is_save=True, expandable=False, folder_only=False, path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fs.callback_done_add(fs_cb_done, win) fs.callback_selected_add(fs_cb_selected, win) fs.callback_directory_open_add(fs_cb_directory_open, win) box1.pack_end(fs) fs.show() fs.custom_filter_append(custom_filter_all, filter_name="All Files") fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files") fs.mime_types_filter_append(["text/*"], "Text Files") fs.mime_types_filter_append(["image/*"], "Image Files") sep = Separator(win) box1.pack_end(sep) sep.show() vbox = Box(win) box1.pack_end(vbox) vbox.show() # Options frame fr = Frame(win, text="Options") vbox.pack_end(fr) fr.show() fbox1 = Box(win) fr.content = fbox1 fbox1.show() fbox2 = Box(win, horizontal=True) fbox1.pack_end(fbox2) fbox2.show() ck = Check(win, text="is_save", state=fs.is_save) ck.callback_changed_add(ck_cb_is_save, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="folder_only", state=fs.folder_only) ck.callback_changed_add(ck_cb_folder_only, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="expandable", state=fs.expandable) ck.callback_changed_add(ck_cb_expandable, fs) fbox2.pack_end(ck) ck.show() fbox2 = Box(win, horizontal=True) fbox1.pack_end(fbox2) fbox2.show() ck = Check(win, text="multiple selection", state=fs.multi_select) ck.callback_changed_add(ck_cb_multi_select, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="buttons", state=fs.buttons_ok_cancel) ck.callback_changed_add(ck_cb_buttons, fs) fbox2.pack_end(ck) ck.show() ck = Check(win, text="hidden", state=fs.hidden_visible) ck.callback_changed_add(ck_cb_hidden, fs) fbox2.pack_end(ck) ck.show() # Getters frame fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() fbox = Box(win, horizontal=True) fr.content = fbox fbox.show() bt = Button(win, text="selected_get") bt.callback_clicked_add(bt_cb_sel_get, fs) fbox.pack_end(bt) bt.show() bt = Button(win, text="path_get") bt.callback_clicked_add(bt_cb_path_get, fs) fbox.pack_end(bt) bt.show() bt = Button(win, text="selected_paths") bt.callback_clicked_add(bt_cb_paths_get, fs) fbox.pack_end(bt) bt.show() # Mode frame fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() fbox = Box(win, horizontal=True) fr.content = fbox fbox.show() rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST) rd.callback_changed_add(rd_cb_mode, fs) fbox.pack_end(rd) rd.show() rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID) rd.callback_changed_add(rd_cb_mode, fs) rd.group_add(rdg) fbox.pack_end(rd) rd.show() # Thumbsize frame fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() sl = Slider(win, min_max=(4, 130), unit_format="%.0f px", value=fs.thumbnail_size[0]) sl.callback_delay_changed_add(sl_cb_thumb_size, fs) fr.content = sl sl.show() # Sort method frame fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH) vbox.pack_end(fr) fr.show() hs = Hoversel(win, text="File name (asc)") sorts = ( ("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC), ("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC), ("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC), ("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC), ("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC), ("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC), ("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC), ("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC), ) for sort in sorts: hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1]) fr.content = hs hs.show() win.show()
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, 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) 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: 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]) 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) 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 slider_clicked(obj): win = StandardWindow("slider", "Slider", autodel=True) if obj is None: win.callback_delete_request_add(lambda x: elementary.exit()) win.show() fr = Frame(win, size_hint_weight=EXPAND_BOTH, style="pad_large") win.resize_object_add(fr) fr.show() bx = Box(win) fr.content = bx bx.show() # disabled horizontal slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Disabled", unit_format="%1.1f units", span_size=120, min_max=(50, 150), value=80, disabled=True, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl.part_content_set("icon", ic) bx.pack_end(sl) sl.show() step = step_size_calculate(0, 9) sl = Slider(bx, unit_format="%1.0f units", indicator_format="%1.0f", span_size=120, min_max=(0, 9), text="Manual step", step=step, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bx.pack_end(sl) sl.show() # normal horizontal slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) sl1 = sl = Slider(bx, text="Horizontal", unit_format="%1.1f units", indicator_format="%1.1f", span_size=120, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl.part_content_set("icon", ic) bx.pack_end(sl) ic.show() sl.show() # horizontally inverted slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Horizontal inverted", unit_format="%3.0f units", span_size=80, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) sl.part_content_set("end", ic) sl.callback_delay_changed_add(delay_change_cb) bx.pack_end(sl) sl.show() # disabled horizontally inverted slider ic = Icon(bx, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() sl = Slider(bx, text="Disabled inverted", span_size=80, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, disabled=True, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) sl.part_content_set("end", ic) bx.pack_end(sl) sl.show() # scale doubled slider sl = Slider(bx, indicator_show=False, text="Scale doubled", unit_format="%3.0f units", span_size=40, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ, indicator_format="%3.0f", min_max=(50, 150), value=80, inverted=True, scale=2.0) bx.pack_end(sl) sl.show() # horizontal box bx2 = Box(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_VERT, horizontal=True) bx.pack_end(bx2) bx2.show() # vertical inverted slider ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1)) ic.show() sl = Slider(bx2, text="Vertical inverted", inverted=True, unit_format="%1.1f units", span_size=60, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False) sl.part_content_set("icon", ic) bx2.pack_end(sl) sl.show() sl1.callback_changed_add(change_cb, sl) # disabled vertical slider ic = Icon(bx2, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1)) sl = Slider(bx2, text="Disabled vertical", inverted=True, unit_format="%1.1f units", span_size=100, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_format="%1.1f", value=0.2, scale=1.0, horizontal=False) # # XXX: If vertical mode is set after disabled, it's no longer disabled. # Elm bug? # sl.disabled = True sl.part_content_set("icon", ic) bx2.pack_end(sl) sl.show() # normal vertical slider sl = Slider(bx2, text="Vertical", unit_format="%1.1f units", span_size=60, size_hint_align=FILL_VERT, size_hint_weight=EXPAND_VERT, indicator_show=False, value=0.2, scale=1.0, horizontal=False) sl.callback_changed_add(change_print_cb, sl) bx2.pack_end(sl) sl.show() # box for bottom buttons bx2 = Box(win, size_hint_weight=EXPAND_HORIZ, horizontal=True) bx.pack_end(bx2) bx2.show() bt = Button(win, text="0") bt.callback_clicked_add(bt_0, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="1") bt.callback_clicked_add(bt_1, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="+0.1") bt.callback_clicked_add(bt_p1, sl) bt.show() bx2.pack_end(bt) bt = Button(win, text="-0.1") bt.callback_clicked_add(bt_m1, sl) bt.show() bx2.pack_end(bt)
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 Window.__init__(self, title, ELM_WIN_DIALOG_BASIC, autodel=True) self.callback_delete_request_add(self.close_inst) background = Background(self, size_hint_weight=EXPAND_BOTH) self.resize_object_add(background) background.show() 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, size_hint_min=(64,64)) ic.standard_set(standardicon) 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=(title), size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: self.entry.text_set(info)) vbox.pack_end(bt) bt.show() bt = Button(self, text=('Website'),size_hint_align=FILL_HORIZ) bt.callback_clicked_add(lambda b: xdg_open(webaddress)) 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(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(licen)) vbox.pack_end(bt) bt.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 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, windowGrid, name): offset = 0 if (name == 'Yau'): offset = 50 self.BaseBox = Box(windowGrid, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL)) windowGrid.pack(self.BaseBox, offset, 0, 50, 100) self.BaseBox.show() self.frame = Frame(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL), text=name) self.BaseBox.pack_end(self.frame) self.frame.show() self.FrameBox = Box(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL)) self.frame.content_set(self.FrameBox) self.FrameBox.show() self.FrameCheck = Check(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), text="{0} Frame Check".format(name)) self.FrameBox.pack_end(self.FrameCheck) self.FrameCheck.show() self.FrameSeparator = Separator(self.BaseBox, horizontal=True, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5)) self.FrameBox.pack_end(self.FrameSeparator) self.FrameSeparator.show() self.FrameScroller = Scroller( self.BaseBox, content_min_limit=(True, False), size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL), scrollbar_policy=(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF)) self.FrameBox.pack_end(self.FrameScroller) self.FrameScroller.show() self.FrameTable = Table(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.FrameScroller.content_set(self.FrameTable) self.FrameTable.show() self.BaseLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Base:") self.FrameTable.pack(self.BaseLabel, 0, 0, 1, 1) self.BaseLabel.show() self.BaseEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.BaseEntry, 1, 0, 1, 1) self.BaseEntry.show() self.SecretLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Secret:") self.FrameTable.pack(self.SecretLabel, 2, 0, 1, 1) self.SecretLabel.show() self.SecretEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.SecretEntry, 3, 0, 1, 1) self.SecretEntry.show() self.SignalLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Signal:") self.FrameTable.pack(self.SignalLabel, 4, 0, 1, 1) self.SignalLabel.show() self.SignalEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.SignalEntry, 5, 0, 1, 1) self.SignalEntry.show() self.ChannelLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Channel:") self.FrameTable.pack(self.ChannelLabel, 0, 1, 1, 1) self.ChannelLabel.show() self.ChannelEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ChannelEntry, 1, 1, 1, 1) self.ChannelEntry.show() self.PoleLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Pole:") self.FrameTable.pack(self.PoleLabel, 2, 1, 1, 1) self.PoleLabel.show() self.PoleEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.PoleEntry, 3, 1, 1, 1) self.PoleEntry.show() self.IdentityLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Identity:") self.FrameTable.pack(self.IdentityLabel, 4, 1, 1, 1) self.IdentityLabel.show() self.IdentityEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.IdentityEntry, 5, 1, 1, 1) self.IdentityEntry.show() self.FoundationLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Foundation:") self.FrameTable.pack(self.FoundationLabel, 0, 2, 1, 1) self.FoundationLabel.show() self.FoundationEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.FoundationEntry, 1, 2, 1, 1) self.FoundationEntry.show() self.ElementLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Element:") self.FrameTable.pack(self.ElementLabel, 2, 2, 1, 1) self.ElementLabel.show() self.ElementEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ElementEntry, 3, 2, 1, 1) self.ElementEntry.show() self.DynamoLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Dynamo:") self.FrameTable.pack(self.DynamoLabel, 4, 2, 1, 1) self.DynamoLabel.show() self.DynamoEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.DynamoEntry, 5, 2, 1, 1) self.DynamoEntry.show() self.ManifoldLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Manifold:") self.FrameTable.pack(self.ManifoldLabel, 0, 3, 1, 1) self.ManifoldLabel.show() self.ManifoldEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ManifoldEntry, 1, 3, 1, 1) self.ManifoldEntry.show() self.RingLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Ring:") self.FrameTable.pack(self.RingLabel, 2, 3, 1, 1) self.RingLabel.show() self.RingEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.RingEntry, 3, 3, 1, 1) self.RingEntry.show() self.BarnLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Barn:") self.FrameTable.pack(self.BarnLabel, 4, 3, 1, 1) self.BarnLabel.show() self.BarnEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.BarnEntry, 5, 3, 1, 1) self.BarnEntry.show() self.VoltpereLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Voltpere:") self.FrameTable.pack(self.VoltpereLabel, 0, 4, 1, 1) self.VoltpereLabel.show() self.VoltpereEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.VoltpereEntry, 1, 4, 5, 1) self.VoltpereEntry.show() self.AmpereLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Ampere:") self.FrameTable.pack(self.AmpereLabel, 0, 5, 1, 1) self.AmpereLabel.show() self.AmpereEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.AmpereEntry, 1, 5, 2, 1) self.AmpereEntry.show() self.HenryLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Henry:") self.FrameTable.pack(self.HenryLabel, 0, 6, 1, 1) self.HenryLabel.show() self.HenryEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.HenryEntry, 1, 6, 2, 1) self.HenryEntry.show() self.MaxwellLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Maxwell:") self.FrameTable.pack(self.MaxwellLabel, 0, 7, 1, 1) self.MaxwellLabel.show() self.MaxwellEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.MaxwellEntry, 1, 7, 2, 1) self.MaxwellEntry.show() self.FermatLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Fermat:") self.FrameTable.pack(self.FermatLabel, 0, 8, 1, 1) self.FermatLabel.show() self.FermatEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.FermatEntry, 1, 8, 2, 1) self.FermatEntry.show() self.PropelButton = Button(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Propel") self.FrameTable.pack(self.PropelButton, 4, 8, 1, 1) self.PropelButton.show() self.PropelButton.callback_clicked_add(self.propelClicked)
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='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, 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 populate(self): # main vertical box box = Box(self, size_hint_weight = EXPAND_BOTH) self.resize_object_add(box) box.show() ### header fr = Frame(self, style='outdent_bottom', size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) box.pack_end(fr) fr.show() tb = Table(self, padding=(3,3), size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) fr.content = tb tb.show() # main menu button bt = MainMenuButton(self.app) tb.pack(bt, 0, 0, 1, 1) bt.show() # editable description entry self.caption_label = EditableDescription(self.app) tb.pack(self.caption_label, 1, 0, 1, 1) self.caption_label.show() # status label + button lb = Entry(self, editable=False, line_wrap=ELM_WRAP_NONE) lb.text_style_user_push("DEFAULT='align=center'") tb.pack(lb, 2, 0, 1, 1) lb.show() self.status_label = lb # branch selector self.branch_selector = Hoversel(self, text='HEAD', disabled=True, content=SafeIcon(self, 'git-branch')) self.branch_selector.callback_selected_add(self.branch_selected_cb) tb.pack(self.branch_selector, 3, 0, 1, 1) self.branch_selector.show() # pull button bt = Button(self, text='Pull', disabled=True, content=SafeIcon(self, 'git-pull')) bt.callback_clicked_add(self.app.action_pull) tb.pack(bt, 4, 0, 1, 1) bt.show() self.pull_btn = bt # push button bt = Button(self, text='Push', disabled=True, content=SafeIcon(self, 'git-push')) bt.callback_clicked_add(self.app.action_push) tb.pack(bt, 5, 0, 1, 1) bt.show() self.push_btn = bt ### Tree panes panes1 = Panes(self, content_left_min_size=200, content_left_size=0.0, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(panes1) panes1.show() # the sidebar on the left self.sidebar = Sidebar(self, self.app) panes1.part_content_set('left', self.sidebar) ### Main content (left + right panes) panes2 = Panes(self, content_left_size=0.5, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) panes1.part_content_set('right', panes2) panes2.show() # the dag graph in the center self.graph = DagGraph(self, self.app) panes2.part_content_set('left', self.graph) # the diff viewer on the right self.diff_view = DiffViewer(self, self.app) self.diff_view.size_hint_weight = EXPAND_BOTH self.diff_view.size_hint_align = 0.0, 0.0 panes2.part_content_set('right', self.diff_view) # self.show()
def __init__(self, parent, app): self.app = app DialogWindow.__init__(self, parent, 'Egitu-tags', 'Tags', size=(350,350), autodel=True) # main vertical box (inside a padding frame) vbox = Box(self, padding=(0, 6), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fr = Frame(self, style='pad_medium', size_hint_weight=EXPAND_BOTH) self.resize_object_add(fr) fr.content = vbox fr.show() vbox.show() # title en = Entry(self, editable=False, single_line=True, text='<title>%s</title>' % 'Tags', size_hint_expand=EXPAND_HORIZ) vbox.pack_end(en) en.show() # tag list self.itc = GenlistItemClass(item_style='one_icon', text_get_func=self._gl_text_get, content_get_func=self._gl_content_get) li = Genlist(self, homogeneous=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) li.callback_selected_add(self._list_selected_cb) vbox.pack_end(li) li.show() self.tags_list = li # buttons hbox = Box(self, horizontal=True, size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH) vbox.pack_end(hbox) hbox.show() bt = Button(self, text='Create', content=Icon(self, standard='git-tag')) bt.callback_clicked_add(lambda b: CreateTagPopup(self, self.app)) hbox.pack_end(bt) bt.show() bt = Button(self, text='Delete', content=Icon(self, standard='user-trash')) bt.callback_clicked_add(self._delete_clicked_cb) hbox.pack_end(bt) bt.show() self.delete_btn = bt bt = Button(self, text='Checkout') bt.callback_clicked_add(self._checkout_clicked_cb) hbox.pack_end(bt) bt.show() self.checkout_btn = bt sep = Separator(self, size_hint_expand=EXPAND_HORIZ) hbox.pack_end(sep) bt = Button(self, text='Close') bt.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(bt) bt.show() # self.populate() self.show()
def __init__(self, app): self.app = app DialogWindow.__init__(self, app.win, 'egitu-remotes', 'Remotes', autodel=True, size=(600,400)) # main vertical box (inside a padding frame) fr = Frame(self, style='pad_medium', size_hint_weight=EXPAND_BOTH) self.resize_object_add(fr) fr.show() box = Box(fr, padding=(6,6)) fr.content = box box.show() # panes panes = Panes(box, content_left_size=0.25, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(panes) panes.show() ### remotes List (on the left) li = List(panes) li.callback_selected_add(self._list_selected_cb) panes.part_content_set('left', li) li.show() self.remotes_list = li ### remote info (on the right) tb = Table(self, padding=(4, 4)) panes.part_content_set('right', tb) tb.show() # url lb = Label(self, text='URL', size_hint_align=(0.0,0.5)) tb.pack(lb, 0, 0, 1, 1) lb.show() en = Entry(self, single_line=True, scrollable=True, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) en.callback_changed_user_add(lambda e: \ setattr(self.save_url_btn, 'disabled', False)) tb.pack(en, 1, 0, 1, 1) en.show() self.url_entry = en # fetch lb = Label(self, text='Fetch', size_hint_align=(0.0,0.5)) tb.pack(lb, 0, 1, 1, 1) lb.show() en = Entry(self, single_line=True, scrollable=True, editable=False, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) tb.pack(en, 1, 1, 1, 1) en.show() self.fetch_entry = en # save button bt = Button(self, text='Save', disabled=True, size_hint_expand=EXPAND_VERT, size_hint_fill=FILL_VERT) bt.callback_clicked_add(self._save_url_clicked_cb) tb.pack(bt, 2, 0, 1, 1) bt.show() self.save_url_btn = bt # big info entry en = Entry(panes, scrollable=True, editable=False, line_wrap=ELM_WRAP_NONE, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) en.callback_clicked_add(self._info_clicked_cb) tb.pack(en, 0, 2, 3, 1) en.show() self.info_entry = en ### buttons bar hbox = Box(box, horizontal=True, size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH) box.pack_end(hbox) hbox.show() bt = Button(hbox, text='Add') bt.callback_clicked_add(lambda b: RemoteAddPopup(self, self.app.repo)) hbox.pack_end(bt) bt.show() bt = Button(hbox, text='Remove') bt.callback_clicked_add(self._remove_btn_cb) hbox.pack_end(bt) bt.show() bt = Button(hbox, text='Refresh') bt.callback_clicked_add(lambda b: self.restart_dialog()) hbox.pack_end(bt) bt.show() sep = Separator(hbox, size_hint_expand=EXPAND_HORIZ) hbox.pack_end(sep) bt = Button(hbox, text='Close') bt.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(bt) bt.show() # populate and show the dialog window self.restart_dialog() self.show()
def frame_clicked(obj): win = StandardWindow("frame", "Frame test", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() # frame 1 (label) lbl = Label(win, text="content") fr = Frame(win, size_hint_align=FILL_BOTH, text="Frame (label)", content=lbl) vbox.pack_end(fr) fr.show() # frame 1 (icon) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) fr = Frame(win, size_hint_align=FILL_BOTH, text="Frame (icon)", content=ic) vbox.pack_end(fr) fr.show() # frame 2 (collapsable label) lbl = Label(win, text="content") fr = Frame(win, size_hint_align=FILL_BOTH, autocollapse=True, text="Frame (collapsable label)", content=lbl) vbox.pack_end(fr) fr.show() # frame 3(collapsable icon) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) fr = Frame(win, size_hint_align=FILL_BOTH, autocollapse=True, text="Frame (collapsable icon)", content=ic) vbox.pack_end(fr) fr.show() win.show()