def gl_icons_get(gl): # Start icons animation before actually drag-starts yposret = 0 icons = [] xm, ym = gl.evas.pointer_canvas_xy items = list(gl.selected_items) gli, yposret = gl.at_xy_item_get(xm, ym) if gli is not None: # Add the item mouse is over to the list if NOT seleced if not gli in items: items.append(gli) for it in items: # Now add icons to animation window o = it.part_content_get("elm.swallow.icon") if o is not None: f, g = o.file x, y, w, h = o.geometry ic = Icon(gl, file=(f, g), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, pos=(x, y), size=(w, h)) ic.show() icons.append(ic) return icons
def grid_icons_get(grid): # Start icons animation before actually drag-starts xposret, yposret = 0, 0 icons = [] xm, ym = grid.evas.pointer_canvas_xy items = list(grid.selected_items) print(items) gli, xposret, yposret = grid.at_xy_item_get(xm, ym) if gli is not None: # Add the item mouse is over to the list if NOT seleced if not gli in items: items.append(gli) print(items) for gli in items: # Now add icons to animation window o = gli.part_content_get("elm.swallow.icon") if o is not None: ic = Icon(grid, file=o.file, pos=o.pos, size=o.size, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) ic.show() icons.append(ic) return icons
def content_get(self, obj, part, data): checked = data[1] # "edit" EDC layout is like below. each part is swallow part. # the existing item is swllowed to elm.swallow.edit.content part. # -------------------------------------------------------------------- # | elm.edit.icon.1 | elm.swallow.decorate.content | elm.edit.icon,2 | # -------------------------------------------------------------------- if part == "elm.swallow.end": ic = Icon(obj, file=os.path.join(img_path, "bubble.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) return ic elif part == "elm.edit.icon.1": ck = Check(obj, state=checked, propagate_events=False) ck.show() return ck elif part == "elm.edit.icon.2": icn = Icon(obj, file=os.path.join(img_path, "icon_06.png"), propagate_events=False, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) icn.callback_clicked_add(edit_icon_clicked_cb, data) return icn else: return
def content_get(self, obj, part, data, *args): if part == "elm.swallow.icon": icon = Icon(obj, file=os.path.join(img_path, data), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) icon.show() return icon return None
def gl_icons_get(gl): # Start icons animation before actually drag-starts yposret = 0 icons = [] xm, ym = gl.evas.pointer_canvas_xy items = list(gl.selected_items) gli, yposret = gl.at_xy_item_get(xm, ym) if gli is not None: # Add the item mouse is over to the list if NOT seleced if not gli in items: items.append(gli) for it in items: # Now add icons to animation window o = it.part_content_get("elm.swallow.icon") if o is not None: f, g = o.file x, y, w, h = o.geometry ic = Icon(gl, file=(f, g), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, pos=(x,y), size=(w,h)) ic.show() icons.append(ic) return icons
def gl_createicon(win, xoff, yoff, data): it = data o = it.part_content_get("elm.swallow.icon") if o is None: return w = h = 30 f, g = o.file xm, ym = o.evas.pointer_canvas_xy if xoff is not None: xoff = xm - (w/2) if yoff is not None: yoff = ym - (h/2) icon = Icon(win, file=(f, g), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) if (xoff is not None) and (yoff is not None): icon.move(xoff, yoff) icon.resize(w, h) return icon, xoff, yoff
def gl_anim_start(anim_st): # Start icons animation before actually drag-starts yposret = 0 items = list(anim_st.gl.selected_items) gli, yposret = anim_st.gl.at_xy_item_get(anim_st.mdx, anim_st.mdy) if gli is not None: # Add the item mouse is over to the list if NOT seleced if not gli in items: items.append(gli) for gli in items: # Now add icons to animation window o = gli.part_content_get("elm.swallow.icon") if o is not None: st = AnimIconSt() ic = Icon(anim_st.gl, file=o.file, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, pos=o.pos, size=o.size) st.start_x, st.start_y = o.pos ic.show() st.o = ic anim_st.icons.append(st) anim_st.tm = None anim_st.ea = AnimatorTimeline(drag_anim_play, DRAG_TIMEOUT, anim_st) return ECORE_CALLBACK_CANCEL
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 DeepIcon(parent, name, size): global _cachedPaths if _cachedPaths == None: _cachedPaths = {} _createCachedPaths() ic = None try: ic = Icon(parent, standard=name, order_lookup=ELM_ICON_LOOKUP_FDO_THEME, \ size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), \ size_hint_min=(size,size)) except: try: ic = Icon(parent, standard=_coerceIcon(name,size), order_lookup=ELM_ICON_LOOKUP_FDO_THEME, \ size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), \ size_hint_min=(size,size)) except: try: ic = Icon(parent, standard='image-missing', order_lookup=ELM_ICON_LOOKUP_FDO_THEME, \ size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), \ size_hint_min=(size,size)) except: try: ic = Icon(parent, standard=_coerceIcon('image-missing',size), order_lookup=ELM_ICON_LOOKUP_FDO_THEME, \ size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), \ size_hint_min=(size,size)) except: ic = Icon(parent, standard='close', order_lookup=ELM_ICON_LOOKUP_FDO_THEME, \ size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), \ size_hint_min=(size,size)) return ic
def __init__(self, rent): Box.__init__(self, rent) self.parent = rent #This appears on the button in the main swmai window self.name = "Skel" #The section in the main window the button is added to self.section = "The Body" #Search terms that this module should appear for self.searchData = [] #Command line argument to open this module directly self.launchArg = "--skel" #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('icon-name') self.icon.show() self.mainBox = Box(self, size_hint_weight = EXPAND_BOTH) self.mainBox.show() buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH) buttonBox.horizontal = True buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonReturn) buttonBox.show() self.pack_end(self.mainBox) self.pack_end(buttonBox)
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 = Icon(self, standard='arrow-down') ic.size_hint_min = 20, 20 # 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 box_transition_clicked(obj, item=None): win = StandardWindow("box-layout-transition", "Box Layout Transition", autodel=True) vbox = Box(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() bx = Box(win, layout=ELM_BOX_LAYOUT_HORIZONTAL, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(bx) bx.show() sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() bt = Button(win, text="layout: %s" % layout_list[current_layout]) bt.callback_clicked_add(box_transition_button_cb, bx) vbox.pack_end(bt) bt.show() for i in range(4): ic = Icon(win, file=ic_file, resizable=(0, 0), size_hint_align=(0.5, 0.5)) bx.pack_end(ic) ic.show() win.show()
def __init__(self, app): # create the main window StandardWindow.__init__(self, "eepdater", "eepDater - System Updater", autodel=True, size=(320, 320)) self.callback_delete_request_add(lambda o: elementary.exit()) self.app = app icon = Icon(self) icon.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND) icon.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL) icon.standard_set('software-center') icon.show() self.icon_object_set(icon.object_get()) # build the two main boxes self.mainBox = self.buildMainBox() self.loadBox = self.buildLoadBox() # build the information details inwin object self.buildDetailsWin() # the flip object has the load screen on one side and the GUI on the other 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.loadBox) self.resize_object_add(self.flip) self.flip.show() # show the window self.show()
def addTab(self, widget, tabName, canClose=True, disabled=False): self.tabs.append(widget) btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT) btn.text = tabName btn.data["widget"] = widget btn.disabled = disabled btn.callback_clicked_add(self.showTab, widget) btn.show() icn = Icon(self.buttonBox) icn.standard_set("gtk-close") icn.show() cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT) cls.data["widget"] = widget cls.callback_clicked_add(self.closeTab) cls.disabled = disabled if canClose: cls.show() sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT) sep.show() self.buttonBox.pack_end(btn) self.buttonBox.pack_end(cls) self.buttonBox.pack_end(sep) #Arguments go: btn, cls, sep widget.data["close"] = cls widget.data["button"] = btn widget.data["sep"] = sep self.showTab(widget=widget)
def content_get(self, gg, part, data): if not part == "elm.swallow.icon": ic = Icon(gg, scale=0.5, file=os.path.join(img_path, "icon_%02i.png" % (data % 4)), resizable=(0, 0), size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, 0.5)) ic.show() return ic
def content_get(self, obj, part, data): ic = Icon(obj) if part == "elm.swallow.end": f = os.path.join(img_path, "bubble.png") else: f = os.path.join(img_path, "logo_small.png") ic.file = f ic.size_hint_aspect = EVAS_ASPECT_CONTROL_VERTICAL, 1, 1 return ic
def __init__(self, parent, icon_name, **kargs): Icon.__init__(self, parent, **kargs) if icon_name.startswith('git-'): self.file = (theme_file_get(), 'elm/icon/%s/default' % icon_name) else: try: self.standard = icon_name except RuntimeWarning: print("ERROR: Cannot find icon: '%s'" % icon_name)
def __init__(self, ourParent, ourText, ourIcon=None, ourCB=None, *args, **kwargs): Button.__init__(self, ourParent, *args, **kwargs) icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon.standard_set(ourIcon) icon.show() self.text = ourText self.content_set(icon) self.callback_clicked_add(ourCB)
def fileExists(self, filePath): self.confirmPopup = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) # Add a table to hold dialog image and text to Popup tb = Table(self.confirmPopup, size_hint_weight=EXPAND_BOTH) self.confirmPopup.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self.confirmPopup, thumb='True') icon.standard_set('dialog-question') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self.confirmPopup, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self.confirmPopup, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) current_file = os.path.basename(filePath) dialogLabel.text = "'%s' already exists. Overwrite?<br><br>" \ % (current_file) tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Close without saving button no_btt = Button(self.mainWindow) no_btt.text = "No" no_btt.callback_clicked_add(self.closePopup, self.confirmPopup) no_btt.show() # Save the file and then close button sav_btt = Button(self.mainWindow) sav_btt.text = "Yes" sav_btt.callback_clicked_add(self.doSelected) sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup) sav_btt.show() # add buttons to popup self.confirmPopup.part_content_set("button1", no_btt) self.confirmPopup.part_content_set("button3", sav_btt) self.confirmPopup.show()
def photo_object_add(parent, ic, icon, x, y, w, h, angle): po = Photo_Object() po.base_zoom = po.zoom = BASE_ZOOM if ic: po.ic = ic else: po.ic = Icon(parent) po.ic.file = icon po.bx = x po.by = y po.bw = w po.bh = h # Add shadow po.shadow = Icon(po.ic, file=os.path.join(img_path, "pol_shadow.png")) po.shadow.size = SHADOW_W, SHADOW_H po.shadow.show() po.hit = Polygon(parent.evas) po.hit.precise_is_inside = True po.hit.repeat_events = True po.hit.color = 0, 0, 0, 0 po.ic.pos = 0, 0 po.ic.size = po.bw, po.bh po.ic.show() po.hit.show() po.gl = GestureLayer(po.ic, hold_events=True) po.gl.attach(po.hit) # FIXME: Add a po.rotate start so we take the first angle!!!! po.gl.cb_set(ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE, rotate_move, po) po.gl.cb_set(ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END, rotate_end, po) po.gl.cb_set(ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT, rotate_end, po) po.gl.cb_set(ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START, zoom_start, po) po.gl.cb_set(ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE, zoom_move, po) po.gl.cb_set(ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_END, zoom_end, po) po.gl.cb_set(ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_ABORT, zoom_end, po) po.gl.cb_set(ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_START, momentum_start, po) po.gl.cb_set(ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_MOVE, momentum_move, po) po.gl.cb_set(ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_END, momentum_end, po) po.gl.cb_set(ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_ABORT, momentum_end, po) po.rotate = po.base_rotate = angle po.shadow_zoom = 1.3 apply_changes(po) return po
def buttons_clicked(obj): win = StandardWindow("buttons", "Buttons", focus_highlight_enabled=True, autodel=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ic.show() bt = Button(win, text="Icon sized to button", content=ic) bx.pack_end(bt) bt.show() ic = Icon(win, file=ic_file, resizable=(False, False)) ic.show() bt = Button(win, text="Icon no scale", content=ic) bx.pack_end(bt) bt.show() bt = Button(win, text="No icon") bx.pack_end(bt) bt.show() ic = Icon(win, file=ic_file, resizable=(False, False)) bt = Button(win, content=ic) bx.pack_end(bt) bt.show() ic.show() win.show()
def go_active(self): self.orig_text = self.text self.focus = False self.editable = True self.scrollable = True self.text_style_user_push("DEFAULT='font_size=18'") self.tooltip_unset() ic = Icon(self, standard='close', size_hint_min=(20,20)) ic.callback_clicked_add(self._done_cb, False) self.part_content_set('end', ic) self.focus = True
def bt_clicked(obj): win = StandardWindow("preload-prescale", "Preload & Prescale", autodel=True, size=(350, 350)) ic = Icon(win, file=os.path.join(img_path, "insanely_huge_test_image.jpg"), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, resizable=(True, True), aspect_fixed=True, preload_disabled=True, prescale=True) win.resize_object_add(ic) ic.show() win.show()
def icon_transparent_clicked(obj, item=None): win = Window("icon-transparent", ELM_WIN_BASIC, title="Icon Transparent", autodel=True, alpha=True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) icon = Icon(win, file=os.path.join(img_path, "logo.png"), resizable=(False, False)) win.resize_object_add(icon) icon.show() win.show()
def update_ui(self, listing_in_progress=False): box = self.header_box box.clear() ui_disabled = True # file listing in progress if listing_in_progress: spin = Progressbar(box, style='wheel', pulse_mode=True) spin.pulse(True) spin.show() box.pack_end(spin) lb = Label(box, text=_('Reading archive, please wait...'), size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.0, 0.5)) lb.show() box.pack_end(lb) # or header button else: if self.app.file_name is None: txt = _('No archive loaded, click to choose a file') else: ui_disabled = False txt = _('<b>Archive:</b> %s') % \ (os.path.basename(self.app.file_name)) lb = Label(box, text='<align=left>%s</align>' % txt) bt = Button(box, content=lb, size_hint_weight=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ) bt.callback_clicked_add(lambda b: \ FileSelectorInwin(self, _('Choose an archive'), self._archive_selected_cb, path=os.getcwd())) box.pack_end(bt) bt.show() # always show the about button sep = Separator(box) box.pack_end(sep) sep.show() ic = Icon(box, standard='dialog-info', size_hint_min=(24,24)) ic.callback_clicked_add(lambda i: InfoWin(self)) box.pack_end(ic) ic.show() for widget in (self.extract_btn, self.fsb, self.create_folder_chk, self.del_chk): widget.disabled = ui_disabled self.update_fsb_label()
def box_horiz_clicked(obj, item=None): win = StandardWindow("box-horiz", "Box Horiz", autodel=True) bx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() for align in ((0.5, 0.5), (0.5, 0.0), (0.0, EVAS_HINT_EXPAND)): ic = Icon(win, file=ic_file, resizable=(0, 0), size_hint_align=align) bx.pack_end(ic) ic.show() win.show()
def content_get(self, gen_lst, part, data): '''Return Icon for GenlistItem''' icon = None if part == 'elm.swallow.icon': try: icon = Icon(gen_lst, standard='file') except RuntimeWarning: try: icon = Icon(gen_lst, standard='gtk-file') except RuntimeWarning: if not FileGLIC.error: print('ERROR: Cannot find gtk-file icon') FileGLIC.error = True return icon
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()
def hover_clicked(obj, item=None): win = StandardWindow("hover", "Hover", autodel=True, size=(320, 320)) bx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(bx) bx.show() hv = Hover(win) bt = Button(win, text="Button") bt.callback_clicked_add(hover_bt1_clicked, hv) bx.pack_end(bt) bt.show() hv.target = bt bt = Button(win, text="Popup") hv.part_content_set("middle", bt) bt.show() bx = Box(win) ic = Icon(win, file=os.path.join(img_path, "logo_small.png"), resizable=(False, False)) bx.pack_end(ic) ic.show() for t in "Top 1", "Top 2", "Top 3": bt = Button(win, text=t) bx.pack_end(bt) bt.show() bx.show() hv.part_content_set("top", bx) bt = Button(win, text="Bottom") hv.part_content_set("bottom", bt) bt.show() bt = Button(win, text="Left") hv.part_content_set("left", bt) bt.show() bt = Button(win, text="Right") hv.part_content_set("right", bt) bt.show() win.show()
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, 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) self.mainBox.show() buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH) buttonBox.horizontal = True buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonReturn) buttonBox.show() self.pack_end(self.mainBox) self.pack_end(buttonBox)
def errorPopup(window, errorMsg): errorPopup = Popup(window, size_hint_weight=EXPAND_BOTH) errorPopup.callback_block_clicked_add(lambda obj: errorPopup.delete()) # Add a table to hold dialog image and text to Popup tb = Table(errorPopup, size_hint_weight=EXPAND_BOTH) errorPopup.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(errorPopup, thumb='True') icon.standard_set('dialog-warning') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(errorPopup, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(errorPopup, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) dialogLabel.text = errorMsg tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Ok Button ok_btt = Button(errorPopup) ok_btt.text = "Ok" ok_btt.callback_clicked_add(lambda obj: errorPopup.delete()) ok_btt.show() # add button to popup errorPopup.part_content_set("button3", ok_btt) errorPopup.show()
def __init__(self, ourParent, ourMsg, ourIcon=None, *args, **kwargs): Popup.__init__(self, ourParent, *args, **kwargs) self.callback_block_clicked_add(lambda obj: self.delete()) # Add a table to hold dialog image and text to Popup tb = Table(self, size_hint_weight=EXPAND_BOTH) self.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self, thumb='True') icon.standard_set(ourIcon) # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) dialogLabel.text = ourMsg tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Ok Button ok_btt = Button(self) ok_btt.text = "Ok" ok_btt.callback_clicked_add(lambda obj: self.delete()) ok_btt.show() # add button to popup self.part_content_set("button3", ok_btt)
def addButtonPressed(self, btn): toAppend = "file://%s%s"%(self.filepathEntry.text, self.selectedFolder.text.replace(" ", "%20")) con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("gtk-directory") con.show() it = self.bookmarksList.item_append(self.selectedFolder.text, icon=con) it.data["path"] = "%s%s"%(self.filepathEntry.text, self.selectedFolder.text) self.bookmarksList.go() self.addButton.disabled = True self.removeButton.disabled = False with open(os.path.expanduser('~/.config/gtk-3.0/bookmarks'),'a') as f: f.write( toAppend + " " + self.selectedFolder.text + "\n" )
def icon_clicked(obj, item=None): win = StandardWindow("icon test", "Icon Test", autodel=True, size=(400, 400)) win.show() box = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box) box.show() ic = Icon(box, file=os.path.join(img_path, "logo.png"), resizable=(True, True), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(ic) ic.show() hbox = Box(box, horizontal=True, size_hint_weight=EXPAND_HORIZ) box.pack_end(hbox) hbox.show() # Test Aspect Fixed tg = Check(hbox, text="Aspect Fixed", state=True) tg.callback_changed_add(aspect_fixed_cb, ic) hbox.pack_end(tg) tg.show() # Test Fill Outside tg = Check(hbox, text="Fill Outside") tg.callback_changed_add(fill_outside_cb, ic) hbox.pack_end(tg) tg.show() # Test Smooth tg = Check(hbox, text="Smooth", state=True) tg.callback_changed_add(smooth_cb, ic) hbox.pack_end(tg) tg.show() # Test Preload, Prescale bt = Button(hbox, text="Preload & Prescale") bt.callback_clicked_add(bt_clicked) hbox.pack_end(bt) bt.show()
def page4(bt, nf): ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png")) bt = Button(nf, content=ic) bt.callback_clicked_add(page5, nf) content = Photo(nf, file=os.path.join(img_path, "rock_02.jpg"), fill_inside=True, style="shadow") item = nf.item_push("Page 4", None, bt, content, "basic") ic = Icon(nf, file=os.path.join(img_path, "logo_small.png")) item.part_content_set("icon", ic) item.part_text_set("subtitle", "Title area visibility test") item.title_enabled = (False, False) content.callback_clicked_add(title_visible, item)
def cb_menu_overlay_bubble(menu, item, Map, lon, lat): ov = Map.overlay_add(lon, lat) bub = Map.overlay_bubble_add() bub.follow(ov) lb = Label(Map, text="You can push contents here") bub.content_append(lb) lb.show() ic = Icon(Map, file=os.path.join(img_path, "sky_01.jpg")) ic.size_hint_min = 50, 50 bub.content_append(ic) ic.show() bt = Button(Map, text="clear me") bt.callback_clicked_add(lambda bt:bub.content_clear()) bub.content_append(bt) bt.show()
class TestElmIcon(unittest.TestCase): def setUp(self): self.w = Window("t", ELM_WIN_BASIC) self.o = Icon(self.w) def tearDown(self): self.o.delete() self.w.delete() def testIconConstructor(self): self.assertIsNotNone(self.o) self.assertEqual(Eo.parent_get(self.o), self.w) def testIconStandard(self): self.o.standard = u"elementary" self.assertEqual(u"elementary", self.o.standard) def testIconStandardException(self): self.assertRaises(RuntimeWarning, setattr, self.o, "standard", u"this_fails")
class TestElmIcon(unittest.TestCase): def setUp(self): self.w = Window("t", ELM_WIN_BASIC) self.o = Icon(self.w) def tearDown(self): self.o.delete() self.w.delete() def testIconConstructor(self): self.assertIsNotNone(self.o) self.assertEqual(Eo.parent_get(self.o), self.w) def testIconStandard(self): self.o.standard = u"elementary" self.assertEqual(u"elementary", self.o.standard) def testIconStandardException(self): self.assertRaises( RuntimeWarning, setattr, self.o, "standard", u"this_fails")
def content_get(self, gl, part, data): if not part == "elm.swallow.end": bt = Button(gl, text="OK", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) else: bt = Icon(gl, file=os.path.join(img_path, "logo_small.png"), size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) return bt
def __init__(self, app, parent): self.app = app self._text = '' Button.__init__(self, parent,size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.callback_clicked_add(self._btn_clicked_cb) box = Box(self, horizontal=True, padding=(3,0)) self.content = box box.show() icon = Icon(box, standard='folder', size_hint_min=(16,16)) box.pack_end(icon) icon.show() self.label = Label(box, ellipsis=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) box.pack_end(self.label) self.label.show()
def startupAppAdd(self, lst, itm): text = itm.text dataFile = itm.data["file"] dataIcon = itm.data["icon"] itm.delete() if dataIcon: iconObj = Icon(self, standard=dataIcon, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) else: iconObj = Icon(self, standard="preferences-system", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) ourItem = self.startupList.item_append(text, iconObj) ourItem.data["file"] = dataFile ourItem.data["icon"] = dataIcon self.startupList.go()
def gl_createicon(win, xoff, yoff, data): it = data o = it.part_content_get("elm.swallow.icon") if o is None: return w = h = 30 f, g = o.file xm, ym = o.evas.pointer_canvas_xy if xoff is not None: xoff = xm - (w / 2) if yoff is not None: yoff = ym - (h / 2) icon = Icon(win, file=(f, g), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) if (xoff is not None) and (yoff is not None): icon.move(xoff, yoff) icon.resize(w, h) return icon, xoff, yoff
def page2(bt, nf): ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png")) bt = Button(nf, content=ic) bt.callback_clicked_add(page3, nf) content = Photo(nf, file=os.path.join(img_path, "plant_01.jpg"), fill_inside=True, style="shadow") item = nf.item_push("Page 2", None, bt, content, "basic") item.part_text_set("subtitle", "Here is sub-title part!")
def _initialize(self, parent_widget, show_func, del_func): sel_btn = self._sel_btn = Button(parent_widget, style="anchor", text=self._name, size_hint_align=ALIGN_LEFT, disabled=(not self._canSelect)) sel_btn.callback_clicked_add(lambda x, y=self.content: show_func(y)) sel_btn.show() icn = Icon(parent_widget, standard="window-close") icn.show() cls_btn = self._cls_btn = Button(parent_widget, style="anchor", content=icn, size_hint_align=ALIGN_LEFT, disabled=(not self._canClose)) cls_btn.callback_clicked_add(lambda x, y=self.content: del_func(y)) if self._canClose: cls_btn.show() self._sep = Separator(parent_widget, size_hint_align=ALIGN_LEFT) self._sep.show()
def page3(bt, nf): bt = Button(nf, text="Prev") bt.callback_clicked_add(navi_pop, nf) bt2 = Button(nf, text="Next") bt2.callback_clicked_add(page4, nf) content = Photo(nf, file=os.path.join(img_path, "rock_01.jpg"), fill_inside=True, style="shadow") item = nf.item_push("Page 3", bt, bt2, content, "basic") ic = Icon(nf, file=os.path.join(img_path, "logo_small.png")) item.part_content_set("icon", ic)
def __init__(self, rent): Box.__init__(self, rent) self.parent = rent self.name = "Keyboard Layout" self.section = "System Settings" self.searchData = ["keyboard", "layout", "system", "input"] self.launchArg = "--keyboard" 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('input-keyboard') self.icon.show() #print(list(KeyboardLayouts)) self.keyboardList = keyboardList = SearchableList(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) keyboardList.callback_item_focused_add(self.enableKBSelect) self.keys = list(KeyboardLayouts) self.keys.sort() for kbl in self.keys: keyboardList.item_append(kbl) keyboardList.show() self.mainBox = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH) self.mainBox.pack_end(keyboardList) self.mainBox.show() buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH) buttonBox.horizontal = True self.buttonKBSelect = buttonKBSelect = StandardButton(self, "Apply Selected", "ok", self.applyPressed) buttonKBSelect.disabled = True buttonKBSelect.show() buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed) buttonReturn.show() buttonBox.pack_end(buttonKBSelect) buttonBox.pack_end(buttonReturn) buttonBox.show() self.pack_end(self.mainBox) self.pack_end(buttonBox)
def content_get(self, obj, part, item_data): if part == "elm.swallow.icon": h = item_data s = h.status() ic = Icon(obj) if h.is_paused(): try: ic.standard = "player_pause" except RuntimeError: self.log.debug("Setting torrent ic failed") elif h.is_seed(): try: ic.standard = "up" except RuntimeError: self.log.debug("Setting torrent ic failed") else: try: ic.standard = "down" except RuntimeError: self.log.debug("Setting torrent ic failed") ic.tooltip_text_set(self.state_str[s.state]) ic.size_hint_aspect_set(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1) return ic
def cb_popup_center_title_content_3button(li, item, win): ic = Icon(win, file=os.path.join(img_path, "logo_small.png")) bt = Button(win, text="Content", content=ic) popup = Popup(win, size_hint_weight=EXPAND_BOTH, content=bt) popup.part_text_set("title,text", "Title") bt = Button(win, text="OK") popup.part_content_set("button1", bt) bt = Button(win, text="Cancel") popup.part_content_set("button2", bt) bt = Button(win, text="Close") bt.callback_clicked_add(cb_bnt_close, popup) popup.part_content_set("button3", bt) popup.show()