def addPackage(self, pak): row = [] ourCheck = Check(self) ourCheck.data['packageName'] = pak.name ourCheck.callback_changed_add(self.app.checkChange) ourCheck.show() row.append(ourCheck) ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ourName.text = pak.name ourName.data["packageDes"] = pak.candidate.description ourName.callback_pressed_add(self.packagePressed) ourName.show() row.append(ourName) ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) ourVersion.text = pak.installed.version ourVersion.show() row.append(ourVersion) newVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) newVersion.text = pak.candidate.version newVersion.show() row.append(newVersion) self.app.packagesToUpdate[pak.name] = {'check':ourCheck, 'selected':False} self.packageList.row_pack(row, sort=False)
def _settings_open(self, obj, it): h = Hover(self) t = it.track_object h.pos = t.bottom_center del t del it.track_object l = List(h) l.mode = ELM_LIST_EXPAND h.part_content_set("bottom", l) l.show() chk = Check(self, text="Scroll By Page") chk.state = self.settings["scroll_by_page"] def _scroll_by_page_cb(obj): target_state = obj.state self.settings["scroll_by_page"] = target_state if self.tabs.currentContent: if target_state: self.tabs.currentContent.scroll_freeze() else: self.tabs.currentContent.scroll_thaw() h.dismiss() chk.callback_changed_add(_scroll_by_page_cb) l.item_append(None, chk) l.go() h.show()
def signal_clicked_cb(self, gl, item): pp = Popup(self._parent) pp.part_text_set('title,text', 'Signal content') en = Entry(self, text=prettify_if_needed(item.data['args'])) en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL en.size_hint_min = 800, 800 # TODO: this should be respected :/ en.editable = False en.scrollable = True pp.content = en bt = Button(pp, text="Close") bt.callback_clicked_add(lambda b: pp.delete()) pp.part_content_set('button2', bt) def prettify_clicked_cb(chk): options.pretty_output = chk.state en.text = prettify_if_needed(item.data['args']) ck = Check(pp, text="Prettify") ck.state = options.pretty_output ck.callback_changed_add(prettify_clicked_cb) pp.part_content_set('button1', ck) pp.show()
def content_get(self, obj, part, data): file_entry, progress, n, h = data if part == "elm.swallow.icon": check = Check(obj) check.tooltip_text_set("Enable/disable file download") check.state = h.file_priorities()[n] check.callback_changed_add(self.toggle_file_enabled, n, h) return check
def _gl_content_get(self, li, part, item_data): if isinstance(item_data, tuple): # in real commits mod, staged, name, new = item_data else: # in local changes (item_data is the path) mod, staged, name, new = self.app.repo.status.changes[item_data] if part == 'elm.swallow.icon': return Icon(self, standard='git-mod-'+mod) elif part == 'elm.swallow.end' and staged is not None: ck = Check(self, state=staged, propagate_events=False) ck.callback_changed_add(self._stage_unstage_check_cb) ck.data['path'] = name return ck
def show_local_status(self): sortd = sorted(self.repo.status.changes, key=lambda c: c[2]) for mod, staged, name in sortd: icon_name = 'mod_{}.png'.format(mod.lower()) icon = Icon(self, file=theme_resource_get(icon_name)) check = Check(self, text="", state=staged) check.callback_changed_add(self.stage_unstage_cb) check.data['path'] = name it = self.diff_list.item_append(name, icon, check) it.data['change'] = mod, name self.diff_list.go()
def check_clicked(obj): win = StandardWindow("check", "Check test", 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)) ck = Check(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ, text="Icon sized to check", content=ic, state=True ) ck.callback_changed_add(ck_1) bx.pack_end(ck) ck.show() ic.show() ic = Icon(win, file=ic_file, resizable=(0, 0)) ck = Check(win, text="Icon no scale", content=ic) ck.callback_changed_add(ck_2) bx.pack_end(ck) ck.show() ic.show() ck = Check(win, text="Label Only") ck.callback_changed_add(ck_3) bx.pack_end(ck) ck.show() ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)) ck = Check(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ, text="Disabled check", content=ic, state=True ) ck.callback_changed_add(ck_never) bx.pack_end(ck) ck.disabled_set(True) ck.show() ic.show() ic = Icon(win, file=ic_file, size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1), resizable=(0, 0)) ck = Check(win, content=ic) ck.callback_changed_add(ck_4) bx.pack_end(ck) ck.show() ic.show() win.show()
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 index_clicked(obj): win = StandardWindow("index", "Index test", autodel=True, size=(320, 480)) 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() # index idx = Index(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) idx.callback_delay_changed_add(cb_idx_delay_changed) idx.callback_changed_add(cb_idx_changed) idx.callback_selected_add(cb_idx_selected) win.resize_object_add(idx) idx.show() # genlist itc = GenlistItemClass(item_style="default", text_get_func=gl_text_get) # content_get_func=gl_content_get, # state_get_func=gl_state_get) gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(gl) gl.show() for i in 'ABCDEFGHILMNOPQRSTUVZ': for j in 'acegikmo': gl_item = gl.item_append(itc, i + j) if j == 'a': idx_item = idx.item_append(i, cb_idx_item, gl_item) idx_item.data["gl_item"] = gl_item idx.level_go(0) sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() ck = Check(win, text="autohide_disabled") ck.callback_changed_add(lambda ck: idx.autohide_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="indicator_disabled") ck.callback_changed_add(lambda ck: idx.indicator_disabled_set(ck.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="horizontal") ck.callback_changed_add(lambda ck: idx.horizontal_set(ck.state)) hbox.pack_end(ck) ck.show() win.show()
def addPackage(self, pak): row = [] ourCheck = Check(self) ourCheck.data['packageName'] = pak.name ourCheck.callback_changed_add(self.app.checkChange) ourCheck.show() row.append(ourCheck) ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ourName.text = pak.name ourName.data["packageDes"] = pak.candidate.description ourName.callback_pressed_add(self.packagePressed) ourName.show() row.append(ourName) ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) ourVersion.text = pak.installed.version ourVersion.show() row.append(ourVersion) newVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) newVersion.text = pak.candidate.version newVersion.show() row.append(newVersion) self.app.packagesToUpdate[pak.name] = { 'check': ourCheck, 'selected': False } self.packageList.row_pack(row, sort=False)
def _settings_open(self, obj, it): h = Hover(self) t = it.track_object h.pos = t.bottom_center del t del it.track_object l = List(h) l.mode = ELM_LIST_EXPAND h.part_content_set("bottom", l) l.show() chk = Check(self, text="Scroll By Page") chk.state = self.settings["scroll_by_page"] def _scroll_by_page_cb(obj): self.settings["scroll_by_page"] = obj.state h.dismiss() chk.callback_changed_add(_scroll_by_page_cb) l.item_append(None, chk) l.go() h.show()
def __init__(self, parent, session): self.session = session conf = session.conf PreferencesDialog.__init__(self, "General") limits = Limits(self, session) ports = ListenPorts(self, session) pe = EncryptionSettings(self, session) dlsel = DataStorageSelector(self, conf) pad = Rectangle(self.evas) pad.color = 0, 0, 0, 0 pad.size_hint_min = 0, 10 sep1 = Separator(self) sep1.horizontal = True chk1 = Check(self) chk1.size_hint_align = 0.0, 0.0 chk1.text = "Delete original .torrent file when added" chk1.state = conf.getboolean("Settings", "delete_original") chk1.callback_changed_add(lambda x: conf.set("Settings", "delete_original", str(bool(chk1.state)))) chk2 = Check(self) chk2.size_hint_align = 0.0, 0.0 chk2.text = "Ask for confirmation on exit" chk2.state = conf.getboolean("Settings", "confirmations") chk2.callback_changed_add(lambda x: conf.set("Settings", "confirmations", str(bool(chk2.state)))) sep2 = Separator(self) sep2.horizontal = True for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2: w.show() self.box.pack_end(w)
def __init__(self, parent, session): self.session = session conf = session.conf PreferencesDialog.__init__(self, "General") limits = Limits(self, session) ports = ListenPorts(self, session) pe = EncryptionSettings(self, session) dlsel = DataStorageSelector(self, conf) pad = Rectangle(self.evas) pad.color = 0, 0, 0, 0 pad.size_hint_min = 0, 10 sep1 = Separator(self) sep1.horizontal = True chk1 = Check(self) chk1.size_hint_align = 0.0, 0.0 chk1.text = "Delete original .torrent file when added" chk1.state = conf.getboolean("Settings", "delete_original") chk1.callback_changed_add(lambda x: conf.set( "Settings", "delete_original", str(bool(chk1.state)))) chk2 = Check(self) chk2.size_hint_align = 0.0, 0.0 chk2.text = "Ask for confirmation on exit" chk2.state = conf.getboolean("Settings", "confirmations") chk2.callback_changed_add(lambda x: conf.set( "Settings", "confirmations", str(bool(chk2.state)))) sep2 = Separator(self) sep2.horizontal = True for w in ports, limits, dlsel, pe, pad, sep1, chk1, chk2, sep2: w.show() self.box.pack_end(w)
def fileselector_entry_clicked(obj, item=None): win = StandardWindow("fileselector", "File selector test", autodel=True, size=(240, 150)) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() fse = FileselectorEntry(win, text="Select a file", inwin_mode=False, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(fse) fse.show() sep = Separator(win, horizontal=True) vbox.pack_end(sep) sep.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) vbox.pack_end(hbox) hbox.show() ck = Check(win, text="inwin", state=fse.inwin_mode) ck.callback_changed_add(toggle_inwin, fse) hbox.pack_end(ck) ck.show() ck = Check(win, text="folder_only", state=fse.folder_only) ck.callback_changed_add(toggle_folder_only, fse) hbox.pack_end(ck) ck.show() ck = Check(win, text="is_save", state=fse.is_save) ck.callback_changed_add(toggle_is_save, fse) hbox.pack_end(ck) ck.show() ck = Check(win, text="expandable", state=fse.expandable) ck.callback_changed_add(toggle_expandable, fse) hbox.pack_end(ck) ck.show() win.show()
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()
class MainWin(StandardWindow): 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 del_check_cb(self, check): self.app.delete_after_extract = check.state 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 _archive_selected_cb(self, path): if os.path.isfile(path): self.app.load_file(path) def update_fsb_label(self): if self.create_folder_chk.state is True: name = os.path.splitext(os.path.basename(self.app.file_name))[0] self.fsb.text = os.path.join(self.app.dest_folder, name) else: self.fsb.text = self.app.dest_folder or '' def show_error_msg(self, msg): pop = Popup(self, text=msg) pop.part_text_set('title,text', _('Error')) btn = Button(self, text=_('Continue')) btn.callback_clicked_add(lambda b: pop.delete()) pop.part_content_set('button1', btn) btn = Button(self, text=_('Exit')) btn.callback_clicked_add(lambda b: self.app.exit()) pop.part_content_set('button2', btn) pop.show() def tree_populate(self, file_list=None, parent=None): if file_list is not None: self.file_list.clear() self._file_list = file_list if parent is None: prefix = None # items must match this prefix to be listed fscount = 0 # folder must have this number of slashes dscount = 1 # files must have this number of slashes else: prefix = parent.data[:-1] fscount = prefix.count('/') + 1 dscount = fscount + 1 files = [] for path in self._file_list: if prefix and not path.startswith(prefix): continue if path.endswith('/'): if path.count('/') == dscount: self.file_list.item_append(self.fold_itc, path, parent, flags=ELM_GENLIST_ITEM_TREE) else: if path.count('/') == fscount: files.append(path) for path in files: self.file_list.item_append(self.file_itc, path, parent) def _gl_expand_req_cb(self, gl, item): item.expanded = True def _gl_expanded_cb(self, gl, item): self.tree_populate(None, item) def _gl_contract_req_cb(self, gl, item): item.expanded = False def _gl_contracted_cb(self, gl, item): item.subitems_clear() def extract_btn_cb(self, btn): self.prog_popup = None self.app.dest_folder = self.fsb.text self.app.extract_archive() def build_prog_popup(self): pp = Popup(self) pp.part_text_set('title,text', _('Extracting files, please wait...')) pp.show() vbox = Box(self) pp.part_content_set('default', vbox) vbox.show() lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(lb) lb.show() pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(pb) pb.show() bt = Button(pp, text=_('Cancel')) bt.callback_clicked_add(lambda b: self.app.abort_operation()) pp.part_content_set('button1', bt) self.prog_pbar = pb self.prog_label = lb self.prog_popup = pp def extract_progress(self, progress, cur_name): if self.prog_popup is None: self.build_prog_popup() self.prog_pbar.value = progress self.prog_label.text = cur_name def extract_finished(self): if self.prog_popup: self.prog_popup.delete() self.prog_popup = None def _open_fm_and_exit_cb(self, bt): utils.xdg_open(self.app.dest_folder) self.app.exit() def _open_term_and_exit_cb(self, bt): utils.open_in_terminal(self.app.dest_folder) self.app.exit() def ask_what_to_do_next(self): pop = Popup(self) pop.part_text_set('title,text', _('Extract completed')) box = Box(pop) pop.content = box box.show() lb = Label(pop, text=_('What to do next?'), size_hint_align=FILL_HORIZ) box.pack_end(lb) lb.show() btn = Button(pop, text=_('Open Filemanager'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_fm_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Open Terminal'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_term_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Close this popup'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: pop.delete()) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Exit'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.app.exit()) box.pack_end(btn) btn.show() pop.show()
def __init__(self, app, revert_commit=None, cherrypick_commit=None): self.app = app self.confirmed = False self.revert_commit = revert_commit self.cherrypick_commit = cherrypick_commit DialogWindow.__init__(self, app.win, 'Egitu', 'Egitu', size=(500,500), autodel=True) vbox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(vbox) vbox.show() # title if revert_commit: title = 'Revert commit' elif cherrypick_commit: title = 'Cherry-pick commit' else: title = 'Commit changes' en = Entry(self, editable=False, text='<title><align=center>%s</align></title>' % title, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(en) en.show() # auto-commit checkbox (for revert and cherry-pick) if revert_commit or cherrypick_commit: ck = Check(vbox, state=True) ck.text = 'Automatically commit, in branch: %s' % \ app.repo.status.current_branch.name ck.callback_changed_add(lambda c: self.msg_entry.disabled_set(not c.state)) vbox.pack_end(ck) ck.show() self.autocommit_chk = ck # Panes panes = Panes(self, content_left_size = 0.2, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(panes) panes.show() # message entry en = Entry(self, editable=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set('guide', 'Enter commit message here') panes.part_content_set("left", en) if revert_commit: en.text = 'Revert "%s"<br><br>This reverts commit %s.<br><br>' % \ (utf8_to_markup(revert_commit.title), revert_commit.sha) elif cherrypick_commit: en.text = '%s<br><br>%s<br>(cherry picked from commit %s)<br>' % \ (utf8_to_markup(cherrypick_commit.title), utf8_to_markup(cherrypick_commit.message), cherrypick_commit.sha) en.cursor_end_set() en.show() self.msg_entry = en # diff entry self.diff_entry = DiffedEntry(self) panes.part_content_set('right', self.diff_entry) self.diff_entry.show() # buttons hbox = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(self, text='Cancel') bt.callback_clicked_add(lambda b: self.delete()) hbox.pack_end(bt) bt.show() if revert_commit: label = 'Revert' elif cherrypick_commit: label = 'Cherry-pick' else: label = 'Commit' bt = Button(self, text=label) bt.callback_clicked_add(self.commit_button_cb) hbox.pack_end(bt) bt.show() # show the window and give focus to the editable entry self.show() en.focus = True # load the diff if revert_commit: app.repo.request_diff(self.diff_done_cb, revert=True, ref1=revert_commit.sha) elif cherrypick_commit: app.repo.request_diff(self.diff_done_cb, ref1=cherrypick_commit.sha) else: app.repo.request_diff(self.diff_done_cb, only_staged=True)
def gengrid_clicked(obj): global item_count item_count = 25 win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 800)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) tb = Table(win, homogeneous=False, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() # gengrid itc = GengridItemClass(item_style="default", text_get_func=gg_text_get, content_get_func=gg_content_get, state_get_func=gg_state_get, del_func=gg_del) gg = ScrollableGengrid(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, horizontal=False, bounce=(False, True), item_size=(80, 80), align=(0.5, 0.0)) tb.pack(gg, 0, 0, 6, 1) gg.callback_selected_add(gg_sel) gg.callback_unselected_add(gg_unsel) gg.callback_clicked_double_add(gg_clicked_double) gg.show() # add the first items for i in range(item_count): gg.item_append(itc, i, None) # multi select def multi_select_changed(bt, gg): gg.multi_select_set(bt.state) print((gg.multi_select)) bt = Check(win, text="MultiSelect", state=gg.multi_select) bt.callback_changed_add(multi_select_changed, gg) tb.pack(bt, 0, 1, 1, 1) bt.show() # horizontal def horizontal_changed(bt, gg): gg.horizontal_set(bt.state) bt = Check(win, text="Horizontal") bt.callback_changed_add(horizontal_changed, gg) tb.pack(bt, 1, 1, 1, 1) bt.show() # bounce h def bounce_h_changed(bt, gg): (h_bounce, v_bounce) = gg.bounce_get() gg.bounce_set(bt.state, v_bounce) print((gg.bounce_get())) bt = Check(win, text="BounceH") h_bounce = gg.bounce[0] bt.state = h_bounce bt.callback_changed_add(bounce_h_changed, gg) tb.pack(bt, 4, 1, 1, 1) bt.show() # bounce v def bounce_v_changed(bt, gg): (h_bounce, v_bounce) = gg.bounce_get() gg.bounce_set(h_bounce, bt.state) print((gg.bounce_get())) bt = Check(win, text="BounceV") v_bounce = gg.bounce[1] bt.state = v_bounce bt.callback_changed_add(bounce_v_changed, gg) tb.pack(bt, 5, 1, 1, 1) bt.show() # item size def item_size_w_changed(sl, gg): (w, h) = gg.item_size_get() gg.item_size_set(sl.value, h) print((gg.item_size_get())) def item_size_h_changed(sl, gg): (w, h) = gg.item_size_get() gg.item_size_set(w, sl.value) print((gg.item_size_get())) (w, h) = gg.item_size sl = Slider(win, text="ItemSizeW", min_max=(0, 500), indicator_format="%.0f", unit_format="%.0f", span_size=100, value=w) sl.callback_changed_add(item_size_w_changed, gg) tb.pack(sl, 0, 2, 2, 1) sl.show() sl = Slider(win, text="ItemSizeH", min_max=(0, 500), indicator_format="%.0f", unit_format="%.0f", span_size=100, value=h) sl.callback_changed_add(item_size_h_changed, gg) tb.pack(sl, 0, 3, 2, 1) sl.show() # align def alignx_changed(sl, gg): (ax, ay) = gg.align gg.align = sl.value, ay print(gg.align) def aligny_changed(sl, gg): (ax, ay) = gg.align gg.align = ax, sl.value print(gg.align) (ax, ay) = gg.align sl = Slider(win, text="AlignX", min_max=(0.0, 1.0), indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ax) sl.callback_changed_add(alignx_changed, gg) tb.pack(sl, 0, 4, 2, 1) sl.show() sl = Slider(win, text="AlignY", min_max=(0.0, 1.0), indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ay) sl.callback_changed_add(aligny_changed, gg) tb.pack(sl, 0, 5, 2, 1) sl.show() # select first def select_first_clicked(bt, gg): ggi = gg.first_item if ggi: ggi.selected = not ggi.selected bt = Button(win, size_hint_align=FILL_HORIZ, text="Select first") bt.callback_clicked_add(select_first_clicked, gg) tb.pack(bt, 2, 2, 1, 1) bt.show() # select last def select_last_clicked(bt, gg): ggi = gg.last_item if ggi: ggi.selected = not ggi.selected bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Select last") bt.callback_clicked_add(select_last_clicked, gg) tb.pack(bt, 3, 2, 1, 1) bt.show() # selection del def seldel_clicked(bt, gg): for ggi in gg.selected_items_get(): ggi.delete() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Sel del") bt.callback_clicked_add(seldel_clicked, gg) tb.pack(bt, 4, 2, 1, 1) bt.show() # clear def clear_clicked(bt, gg): global item_count item_count = 0 gg.clear() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Clear") bt.callback_clicked_add(clear_clicked, gg) tb.pack(bt, 5, 2, 1, 1) bt.show() # show first/last def show_clicked(bt, gg, first): ggi = gg.first_item if first else gg.last_item if ggi: ggi.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show first") bt.callback_clicked_add(show_clicked, gg, True) tb.pack(bt, 2, 3, 1, 1) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show last") bt.callback_clicked_add(show_clicked, gg, False) tb.pack(bt, 3, 3, 1, 1) bt.show() # bring-in first/last def bring_in_clicked(bt, gg, first): ggi = gg.first_item if first else gg.last_item if ggi: ggi.bring_in() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn first") bt.callback_clicked_add(bring_in_clicked, gg, True) tb.pack(bt, 4, 3, 1, 1) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn last") bt.callback_clicked_add(bring_in_clicked, gg, False) tb.pack(bt, 5, 3, 1, 1) bt.show() # append def append_clicked(bt, gg, n): global item_count while n: item_count += 1 gg.item_append(itc, item_count, None) n -= 1 bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1") bt.callback_clicked_add(append_clicked, gg, 1) tb.pack(bt, 2, 4, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 100") bt.callback_clicked_add(append_clicked, gg, 100) tb.pack(bt, 3, 4, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1000") bt.callback_clicked_add(append_clicked, gg, 1000) tb.pack(bt, 4, 4, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 10000 :)") bt.callback_clicked_add(append_clicked, gg, 10000) tb.pack(bt, 5, 4, 1, 1) bt.show() # prepend def prepend_clicked(bt, gg): global item_count item_count += 1 gg.item_prepend(itc, item_count) bt = Button(win, size_hint_align=FILL_HORIZ, text="Prepend") bt.callback_clicked_add(prepend_clicked, gg) tb.pack(bt, 2, 5, 1, 1) bt.show() # insert_before def ins_before_clicked(bt, gg): global item_count item_count += 1 before = gg.selected_item_get() if before: gg.item_insert_before(itc, item_count, before) else: print("nothing selected") bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins before") bt.callback_clicked_add(ins_before_clicked, gg) tb.pack(bt, 3, 5, 1, 1) bt.show() # insert_after def ins_after_clicked(bt, gg): global item_count item_count += 1 after = gg.selected_item_get() if after: gg.item_insert_after(itc, item_count, after) else: print("nothing selected") bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins after") bt.callback_clicked_add(ins_after_clicked, gg) tb.pack(bt, 4, 5, 1, 1) bt.show() print(gg) win.show()
def __init__(self, parent, method): Popup.__init__(self, parent) self._method = method self._param_entry = None self._return_entry = None # title self.part_text_set('title,text', 'Method: %s()' % method.name) self.show() # content is vbox vbox = Box(parent) vbox.show() self.content = vbox # params label + entry if len(method.params) > 0: label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Params: ' + method.params_str label.show() vbox.pack_end(label) en = Entry(parent) self._param_entry = en en.editable = True en.scrollable = True en.single_line = True en.entry = '' en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.show() vbox.pack_end(en) sp = Separator(win) sp.horizontal = True sp.show() vbox.pack_end(sp) # returns label + entry label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Returns: ' label.text += method.returns_str if method.returns_str else 'None' label.show() vbox.pack_end(label) en = Entry(parent) self._return_entry = en en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.editable = False en.scrollable = True en.disabled = True en.single_line = True # TODO this is wrong, but the only way to show the entry :/ en.entry = '<br> <br> <br>' en.show() vbox.pack_end(en) # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state ch = Check(parent) ch.size_hint_align = 0.0, 0.5 ch.text = "Prettify output (loosing type infos)" ch.state = options.pretty_output ch.callback_changed_add(pretty_output_clicked_cb) ch.show() vbox.pack_end(ch) # popup buttons btn = Button(parent) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) self.part_content_set('button1', btn) btn = Button(parent) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) self.part_content_set('button2', btn) btn = Button(parent) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) self.part_content_set('button3', btn)
def __init__(self, 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 __init__(self): # Dialog Window Basics self.findDialog = Window("find", ELM_WIN_DIALOG_BASIC) self.findDialog.callback_delete_request_add(self.closeFind) # Set Window Icon # Icons work in ubuntu min everything compiled # but not bodhi rc3 icon = Icon(self.findDialog, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon.standard_set('edit-find-replace') icon.show() self.findDialog.icon_object_set(icon.object_get()) # Set Dialog background background = Background(self.findDialog, size_hint_weight=EXPAND_BOTH) self.findDialog.resize_object_add(background) background.show() # Main box to hold shit mainBox = Box(self.findDialog, size_hint_weight=EXPAND_BOTH) self.findDialog.resize_object_add(mainBox) mainBox.show() # Search Section # Horizontal Box to hold search stuff seachBox = Box(self.findDialog, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, padding=PADDING) seachBox.show() mainBox.pack_end(seachBox) # Label for search entry seachLabel = Label(self.findDialog, text="Search for:", size_hint_weight=EXPAND_NONE, size_hint_align=FILL_HORIZ) seachBox.pack_end(seachLabel) seachLabel.show() # Search Entry self.sent = Entry(self.findDialog, scrollable=True, single_line=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.sent.callback_activated_add(self.find) # Enter activates find fn self.sent.show() seachBox.pack_end(self.sent) # Check boxs for Search Options # FIXME: add callbacks These states should be in config file caseCk = Check(self.findDialog, text="Case sensitive", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ, state=CASE_SENSITIVE) caseCk.callback_changed_add(self.ckCase) caseCk.show() mainBox.pack_end(caseCk) wordCk = Check(self.findDialog, text="Match only a whole word", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ, state=WHOLE_WORD) wordCk.callback_changed_add(self.ckWord) wordCk.show() mainBox.pack_end(wordCk) # Dialog Buttons # Horizontal Box for Dialog Buttons buttonBox = Box(self.findDialog, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, padding=PADDING) buttonBox.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0) buttonBox.show() mainBox.pack_end(buttonBox) # Cancel Button cancelBtn = Button(self.findDialog, text="Cancel", size_hint_weight=EXPAND_NONE) cancelBtn.callback_clicked_add(self.closeFind) cancelBtn.show() buttonBox.pack_end(cancelBtn) # Ok Button okBtn = Button(self.findDialog, text=" Find ", size_hint_weight=EXPAND_NONE) okBtn.callback_clicked_add(self.find) okBtn.show() buttonBox.pack_end(okBtn) # Ensure the min height self.findDialog.resize(300, 1) self.findDialog.show()
box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = ("Please select a test from the list below by clicking<br>" "the test button to show the test window.") lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() tg = Check(win, style="toggle", text="UI-Mirroring:") tg.callback_changed_add(cb_mirroring) box0.pack_end(tg) tg.show() bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) box0.pack_end(bx1) bx1.show() lb = Label(win, text="Filter:") bx1.pack_end(lb) lb.show() en = Entry(win,
def map_clicked(obj): win = StandardWindow("map", "Map test", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win) vbox.size_hint_weight = EXPAND_BOTH vbox.size_hint_align = FILL_BOTH win.resize_object_add(vbox) vbox.show() map_obj = Map(win, zoom=2) map_obj.size_hint_weight = EXPAND_BOTH map_obj.size_hint_align = FILL_BOTH map_obj.callback_tile_load_add(cb_map_load) map_obj.callback_tile_loaded_add(cb_map_load) map_obj.event_callback_add(EVAS_CALLBACK_MOUSE_DOWN, cb_map_mouse_down) vbox.pack_end(map_obj) map_obj.show() ### lb = Label(win, text="load_status: 0 / 0") vbox.pack_end(lb) lb.show() map_obj.data["lb_load_status"] = lb ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Goto") bt.callback_clicked_add(cb_btn_goto, map_obj) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom +") bt.callback_clicked_add(cb_btn_zoom, map_obj, 1) hbox.pack_end(bt) bt.show() bt = Button(win, text="Zoom -") bt.callback_clicked_add(cb_btn_zoom, map_obj, -1) hbox.pack_end(bt) bt.show() sl = Slider(win, text="Rotation:", min_max=(0, 360), value=0, indicator_format="%3.0f") sl.callback_changed_add(cb_slider_rot, map_obj) hbox.pack_end(sl) sl.show() src_type = ELM_MAP_SOURCE_TYPE_TILE ho = Hoversel(win, hover_parent=win, text="Tiles: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Tiles") hbox.pack_end(ho) ho.show() ### hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() ck = Check(win, text="wheel_disabled") ck.callback_changed_add(lambda bt: map_obj.wheel_disabled_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="paused") ck.callback_changed_add(lambda bt: map_obj.paused_set(bt.state)) hbox.pack_end(ck) ck.show() ck = Check(win, text="hide overlays") ck.callback_changed_add(cb_chk_overlays_hidden, map_obj) hbox.pack_end(ck) ck.show() ck = Check(win, text="pause overlays") ck.callback_changed_add(cb_chk_overlays_paused, map_obj) hbox.pack_end(ck) ck.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_ROUTE ho = Hoversel(win, hover_parent=win, text="Routes: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Routes") hbox.pack_end(ho) ho.show() lb = Label(win, text="Set Start and End point to calculate route") hbox.pack_end(lb) lb.show() map_obj.data["lb_distance"] = lb bt = Button(win, text="Calc route") bt.callback_clicked_add(cb_btn_calc_route, map_obj) hbox.pack_end(bt) bt.show() ### sp = Separator(win, horizontal=True) sp.show() vbox.pack_end(sp) hbox = Box(win, horizontal=True) hbox.size_hint_weight = EXPAND_HORIZ hbox.size_hint_align = FILL_HORIZ vbox.pack_end(hbox) hbox.show() src_type = ELM_MAP_SOURCE_TYPE_NAME ho = Hoversel(win, hover_parent=win, text="Names: %s" % (map_obj.source_get(src_type))) for src in map_obj.sources_get(src_type): ho.item_add(src) ho.callback_selected_add(cb_hovsel_selected, map_obj, src_type, "Names") hbox.pack_end(ho) ho.show() en = Entry(win, scrollable=True, text="type an address here") en.size_hint_weight = EXPAND_BOTH en.size_hint_align = FILL_BOTH en.single_line = True hbox.pack_end(en) en.show() bt = Button(win, text="Search address") bt.callback_clicked_add(cb_btn_search_name, map_obj, en) hbox.pack_end(bt) bt.show() bt = Button(win, text="Search start point") bt.callback_clicked_add(cb_btn_search_region, map_obj, en) hbox.pack_end(bt) bt.show() print_map_info(map_obj) win.show()
win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = ( "Please select a test from the list below by clicking<br>" "the test button to show the test window." ) lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() tg = Check(win, style="toggle", text="UI-Mirroring:") tg.callback_changed_add(cb_mirroring) box0.pack_end(tg) tg.show() bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) box0.pack_end(bx1) bx1.show() lb = Label(win, text="Filter:") bx1.pack_end(lb) lb.show() en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set("guide", "Type widget name here to search.")
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): StandardWindow.__init__(self, "espionage", "EFL DBus Spy - Espionage") self.autodel_set(True) self.callback_delete_request_add(lambda o: elm.exit()) box = Box(self) self.resize_object_add(box) box.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND box.show() tb = Table(self) box.pack_end(tb) tb.show() lb = Label(self, text="Connect to:", scale=1.3) tb.pack(lb, 0, 0, 1, 2) lb.show() flip = FlipSelector(self, scale=1.3) flip.item_append("Session Bus", self.flip_selected_cb, session_bus) flip.item_append("System Bus", self.flip_selected_cb, system_bus) tb.pack(flip, 1, 0, 1, 2) flip.show() chk = Check(self, text="Show private services") chk.size_hint_align = 0.0, 1.0 chk.state = options.show_private_stuff chk.callback_changed_add(self.show_private_cb) tb.pack(chk, 2, 0, 1, 1) chk.show() chk = Check(self, text="Show DBus introspectables") chk.size_hint_align = 0.0, 0.0 chk.state = options.show_introspect_stuff chk.callback_changed_add(self.show_introspectables_cb) tb.pack(chk, 2, 1, 1, 1) chk.show() vpanes = Panes(self, horizontal=True) vpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND vpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL vpanes.content_left_size = 2.0 / 3 box.pack_end(vpanes) vpanes.show() hpanes = Panes(self) hpanes.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND hpanes.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL hpanes.content_left_size = 1.0 / 3 vpanes.part_content_set("left", hpanes) self.panes = hpanes hpanes.show() self.names_list = NamesList(self) hpanes.part_content_set("left", self.names_list) self.detail_list = DetailList(self) hpanes.part_content_set("right", self.detail_list) self.sigs_receiver = SignalReceiver(self) vpanes.part_content_set("right", self.sigs_receiver) self.resize(700, 500) self.show()
def mapbuf_clicked(obj, item=None): global mb_list win = Window("mapbuf", ELM_WIN_BASIC, title="Mapbuf test", autodel=True, size=(480, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = Background(win, file=os.path.join(img_path, "sky_04.jpg"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(bg) bg.show() vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() # launcher sc = Scroller(win, bounce=(True, False), policy=SCROLL_POLICY_OFF, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sc) bx = Box(win, horizontal=True, homogeneous=True) bx.show() for k in range(8): tb = Table(win, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) tb.show() pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 0, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 11, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 0, 1, 1, 10) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 6, 1, 1, 10) mb = Mapbuf(win, content=tb) mb.point_color_set(k % 4, 255, 0, 0, 255) mb_list.append(mb) bx.pack_end(mb) mb.show() n = m = 0 for j in range(5): for i in range(5): ic = Icon(win, scale=0.5, file=os.path.join(img_path, "icon_%02d.png" % (n)), resizable=(False, False), size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER) tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1) ic.show() lb = Label(win, style="marker", text=names[m]) tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1) lb.show() n = n + 1 if n < 23 else 0 m = m + 1 if m < 15 else 0 sc.content = bx sc.page_relative_set(1.0, 1.0) sc.show() # controls hbox = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_start(hbox) hbox.show() ck = Check(win, text="Map", state=False) ck.callback_changed_add(cb_ck_map) hbox.pack_end(ck) ck.show() ck = Check(win, text="Alpha", state=True) ck.callback_changed_add(cb_ck_alpha) hbox.pack_end(ck) ck.show() ck = Check(win, text="Smooth", state=True) ck.callback_changed_add(cb_ck_smooth) hbox.pack_end(ck) ck.show() ck = Check(win, text="FS", state=False) ck.callback_changed_add(cb_ck_fs, win) hbox.pack_end(ck) ck.show() bt = Button(win, text="Close", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_close, win) 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 MainWin(StandardWindow): 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 table (inside a padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(frame) frame.content = table = Table(frame) frame.show() ### header horiz box self.header_box = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) table.pack(self.header_box, 0, 0, 3, 1) self.header_box.show() # genlist with archive content (inside a small padding frame) frame = Frame(self, style='pad_small', size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(frame, 0, 1, 3, 1) self.file_itc = GenlistItemClass(item_style="no_icon", text_get_func=self._gl_file_text_get) self.fold_itc = GenlistItemClass( item_style="one_icon", text_get_func=self._gl_fold_text_get, content_get_func=self._gl_fold_icon_get) self.file_list = Genlist(frame, homogeneous=True) 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) frame.content = self.file_list frame.show() # rect hack to force a min size on the genlist r = evas.Rectangle(table.evas, size_hint_min=(250, 250), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) table.pack(r, 0, 1, 3, 1) # FileSelectorButton self.fsb = DestinationButton(app, self) table.pack(self.fsb, 0, 2, 3, 1) self.fsb.show() sep = Separator(table, horizontal=True, size_hint_weight=EXPAND_HORIZ) table.pack(sep, 0, 3, 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, 4, 1, 2) self.extract_btn.show() sep = Separator(table, horizontal=False) table.pack(sep, 1, 4, 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, 4, 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, 5, 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.show() def del_check_cb(self, check): self.app.delete_after_extract = check.state 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)) txt = '<align=left>%s</align>' % txt lb = Label(box, ellipsis=True, text=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 = SafeIcon(box, 'help-about', 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 _archive_selected_cb(self, path): if os.path.isfile(path): self.app.load_file(path) def update_fsb_label(self): if self.create_folder_chk.state is True: name = os.path.splitext(os.path.basename(self.app.file_name))[0] self.fsb.text = os.path.join(self.app.dest_folder, name) else: self.fsb.text = self.app.dest_folder or '' def show_error_msg(self, msg): pop = Popup(self, text=msg) pop.part_text_set('title,text', _('Error')) btn = Button(self, text=_('Continue')) btn.callback_clicked_add(lambda b: pop.delete()) pop.part_content_set('button1', btn) btn = Button(self, text=_('Exit')) btn.callback_clicked_add(lambda b: self.app.exit()) pop.part_content_set('button2', btn) pop.show() def tree_populate(self, file_list=None, parent=None): if file_list is not None: self.file_list.clear() self._file_list = file_list if parent is None: prefix = None # items must match this prefix to be listed fscount = 0 # folder must have this number of slashes dscount = 1 # files must have this number of slashes else: prefix = parent.data[:-1] fscount = prefix.count('/') + 1 dscount = fscount + 1 files = [] for path in self._file_list: if prefix and not path.startswith(prefix): continue if path.endswith('/'): if path.count('/') == dscount: self.file_list.item_append(self.fold_itc, path, parent, flags=ELM_GENLIST_ITEM_TREE) else: if path.count('/') == fscount: files.append(path) for path in files: self.file_list.item_append(self.file_itc, path, parent) def _gl_fold_text_get(self, obj, part, item_data): return item_data[:-1].split('/')[-1] def _gl_fold_icon_get(self, obj, part, item_data): return SafeIcon(obj, 'folder') def _gl_file_text_get(self, obj, part, item_data): return item_data.split('/')[-1] def _gl_expand_req_cb(self, gl, item): item.expanded = True def _gl_expanded_cb(self, gl, item): self.tree_populate(None, item) def _gl_contract_req_cb(self, gl, item): item.expanded = False def _gl_contracted_cb(self, gl, item): item.subitems_clear() def extract_btn_cb(self, btn): self.prog_popup = None self.app.dest_folder = self.fsb.text self.app.extract_archive() def build_prog_popup(self): pp = Popup(self) pp.part_text_set('title,text', _('Extracting files, please wait...')) pp.show() vbox = Box(self) pp.part_content_set('default', vbox) vbox.show() lb = Label(self, ellipsis=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(lb) lb.show() pb = Progressbar(pp, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_end(pb) pb.show() bt = Button(pp, text=_('Cancel')) bt.callback_clicked_add(lambda b: self.app.abort_operation()) pp.part_content_set('button1', bt) self.prog_pbar = pb self.prog_label = lb self.prog_popup = pp def extract_progress(self, progress, cur_name): if self.prog_popup is None: self.build_prog_popup() self.prog_pbar.value = progress self.prog_label.text = cur_name def extract_finished(self): if self.prog_popup: self.prog_popup.delete() self.prog_popup = None def _open_fm_and_exit_cb(self, bt): utils.xdg_open(self.app.dest_folder) self.app.exit() def _open_term_and_exit_cb(self, bt): utils.open_in_terminal(self.app.dest_folder) self.app.exit() def ask_what_to_do_next(self): pop = Popup(self) pop.part_text_set('title,text', _('Extract completed')) box = Box(pop) pop.content = box box.show() lb = Label(pop, text=_('What to do next?'), size_hint_align=FILL_HORIZ) box.pack_end(lb) lb.show() btn = Button(pop, text=_('Open Filemanager'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_fm_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Open Terminal'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(self._open_term_and_exit_cb) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Close this popup'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: pop.delete()) box.pack_end(btn) btn.show() btn = Button(pop, text=_('Exit'), size_hint_align=FILL_HORIZ) btn.callback_clicked_add(lambda b: self.app.exit()) box.pack_end(btn) btn.show() pop.show()
def focus4_clicked(obj, item=None): win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320)) win.focus_highlight_enabled = True win.focus_highlight_animate = True fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH); win.resize_object_add(fr) fr.show() # First Example - Using Focus Highlight bx = Box(fr) fr.content = bx bx.show() tg = Check(bx, text="Focus Highlight Enabled (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_animate_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Enabled (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_animate_cb, win) bx.pack_end(tg) tg.show() sp = Separator(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(sp) sp.show() # Second Example - Using Custom Chain lb = Label(bx, text="Custom Chain: Please use tab key to check", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() bx2 = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() bt1 = Button(bx2, text="Button 1", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt1) bt1.show() bt2 = Button(bx2, text="Button 2", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt2) bt2.show() bt3 = Button(bx2, text="Button 3", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt3) bt3.show() bt4 = Button(bx2, text="Button 4", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt4) bt4.show() bx2.focus_custom_chain = [bt2, bt1, bt4, bt3] tg = Check(bx, text="Custom Chain", state=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_custom_chain_cb, bx) bx.pack_end(tg) tg.show() win.show()
class FontSelector(Box): def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.cancelCallback = None self.actionCallback = None self.__first_run = True self.use_theme = False self.override_theme_font_size = True self.override_font_size = 14 self.theme_data = None self.default_font = 'Sans' self.default_font_style = 'Regular' self.default_font_size = 14 self.selected_font = self.default_font self.selected_font_style = self.default_font_style self.selected_font_size = self.default_font_size self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) self.preview_text = 'abcdefghijk ABCDEFGHIJK' # Font size min and max self.fs_min = 8 self.fs_max = 72 lb = Label(self, text="<br><hilight><i>Select Font</i></hilight>", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) lb.show() self.pack_end(lb) sp = Separator(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sp.show() self.pack_end(sp) # A horizontal box to hold our font list and font styles fontBox = Box(self, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fontBox.show() self.pack_end(fontBox) # A vertical box to hold label and list of font families vBoxFL = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vBoxFL.show() fontBox.pack_end(vBoxFL) # A vertical box to hold label and list of font styles vBoxFS = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vBoxFS.show() fontBox.pack_end(vBoxFS) # Generate our needed font data #now =time.time() fonts = [] fonts_raw = self.evas.font_available_list() # populate with default font families # see elm_font_available_hash_add Function in EFL f_families = ['Sans', 'Serif', 'Monospace'] f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic'] fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles] self.fonts_hash = {} for font in fonts_raw: a = font_properties_get(font) # if font name contains a '-' a.name will replace with '\\-' # This needs removed to properly display the name fn = a.name.replace('\\', '') fonts.append(fn) if fn in self.fonts_hash: self.fonts_hash.setdefault(fn, []).append(a.styles[0]) else: self.fonts_hash[fn] = [a.styles[0]] # Deal with some problematic special cases for a, s in self.fonts_hash.items(): #print(a,s) if s: if len(s) == 1: s[0] = s[0].rstrip() if s[0] == u'regular': s[0] = u'Regular' if s[0] == u'Medium Italic': self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif s[0] == u'Italic': if a != u'Romande ADF Script Std': self.fonts_hash.setdefault(a, []).append(u'Regular') self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') else: self.fonts_hash.setdefault(a, []).append(u'Italic') self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) == 2: if any(u'Oblique' in w for w in s): if a not in { u'Baskervald ADF Std Heavy', u'Latin Modern Roman Demi' }: self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault( a, []).append(u'Bold Oblique') elif any(u'Italic' in w for w in s): self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') else: self.fonts_hash.setdefault(a, []).append(u'Italic') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) == 3 and set(s) == { u'Bold', u'Oblique', u'Medium' }: # case GWMonospace self.fonts_hash.setdefault(a, []).append(u'Bold Oblique') elif len(s) == 3 and set(s) == { u'Italic', u'Regular', u'Bold' }: # Case Eden Mills self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) < 4: print("may need fixed Font style for %s: %s" % (a, s)) #print(self.fonts_hash) # for some strange reason many fonts are displayed multiple times. The following lines remove # all duplicates and then sort them alphabetically. # FIXME: Is this still true fonts = list(set(fonts)) fonts.sort(cmp=locale.strcoll) # Elm List for holding font options self.font_list = List(self, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_LIMIT) #self.font_list.callback_selected_add(self.__font_demo_name_set) for font in fonts: self.font_list.item_append(font.replace('\\', '')) if font == self.selected_font: font_it = self.font_list.last_item_get() #print (time.time()- now) self.font_list.go() self.font_list.show() font_family_label = Label(self) font_family_label.text = "<br><b>Font:</b>" font_family_label.show() vBoxFL.pack_end(font_family_label) vBoxFL.pack_end(self.font_list) # Elm List for hold font styles self.font_style = List(self, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_LIMIT) #self.font_style.callback_selected_add(self.__font_demo_style_set) self.__reset_font_style_list(font_it.text_get()) self.font_style.go() self.font_style.show() font_style_label = Label(self) font_style_label.text = "<br><b>Style:</b>" font_style_label.show() vBoxFS.pack_end(font_style_label) vBoxFS.pack_end(self.font_style) # A table to hold font size Spinner and set theme default Check tb = Table(self, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.pack_end(tb) tb.show() # spinner to choose the font size self.font_sizer = Spinner(self) self.font_sizer.min_max_set(self.fs_min, self.fs_max) self.font_sizer.value_set(self.selected_font_size) #self.font_sizer.callback_changed_add(self.__font_demo_size_set) self.font_sizer.show() # Label for Spinner font_sizer_label = Label(self) font_sizer_label.text = "Font Size: " font_sizer_label.show() size_box = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) size_box.horizontal_set(True) size_box.pack_end(font_sizer_label) size_box.pack_end(self.font_sizer) size_box.show() tb.pack(size_box, 33, 0, 34, 34) self.use_theme_ck = Check(self, text="Theme Default ", size_hint_weight=EXPAND_HORIZ, size_hint_align=(1, 0.5)) self.use_theme_ck.callback_changed_add(self.__use_theme_checked) self.use_theme_ck.show() tb.pack(self.use_theme_ck, 67, 0, 33, 34) # Entry to hold sample text self.font_demo = Entry(self, single_line=True, editable=False, context_menu_disabled=True, text=self.preview_text, scrollable=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.font_demo.show() demo_box = Frame(self, size_hint_align=FILL_BOTH, text="Preview:", content=self.font_demo) demo_box.show() # Fixme: move this shit font_it.selected_set(True) font_it.show() # Ensure focus is on Font List self.font_list.focus_set(True) self.pack_end(demo_box) # cancel and OK buttons ok_button = Button(self) ok_button.text = "OK" ok_button.callback_pressed_add(self.__ok_button_pressed) ok_button.show() cancel_button = Button(self) cancel_button.text = "Cancel" cancel_button.callback_pressed_add(self.__cancel_button_pressed) cancel_button.show() # box for buttons button_box = Box(self) button_box.horizontal_set(True) button_box.show() button_box.pack_end(cancel_button) button_box.pack_end(ok_button) self.pack_end(button_box) def callback_activated_add(self, cb): self.actionCallback = cb def callback_cancel_add(self, cb): self.cancelCallback = cb def set_preview_text(self, text): self.preview_text = text self.font_demo.entry_set(text) def __cancel_button_pressed(self, btn): self.use_theme = self.show.use_theme_init #print("cancel", self.use_theme) self.selected_font = self.default_font self.selected_font_style = self.default_font_style self.selected_font_size = self.default_font_size self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) if self.cancelCallback: self.cancelCallback(self) def __ok_button_pressed(self, btn): # Set selections # if use_theme is set any of these could be potentially unset try: self.selected_font = self.font_list.selected_item_get().text_get() self.selected_font_style = self.font_style.selected_item_get( ).text_get() self.selected_font_size = self.font_sizer.value_get() self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) except AttributeError: self.selected_font = self.default_font if self.default_font_style in self.fonts_hash[self.selected_font]: self.selected_font_style = self.default_font_style else: #print("OK attribute error", self.selected_font, self.default_font_style) self.selected_font_style = self.fonts_hash.items[ self.selected_font][0] self.selected_font_size = self.default_font_size self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) self.use_theme = self.use_theme_ck.state_get() if self.actionCallback: self.actionCallback(self) def __use_theme_checked(self, ck): self.use_theme = ck.state_get() #print ( '__use_theme_checked') if self.use_theme: if not self.theme_data: self._set_theme_data() self.set_font(*self.theme_data) while self.font_demo.text_style_user_peek(): self.font_demo.text_style_user_pop() if self.theme_data[1] == None: try: self.font_style.selected_item_get().selected = False except AttributeError: pass if self.override_theme_font_size: self.font_demo.text_style_user_push( "DEFAULT='font_size={0}'".format(self.override_font_size)) self.font_sizer.value_set(self.override_font_size) # Ensure these are unchanged ck.state = self.use_theme = True else: # ensure style is selected self.selected_font = self.default_font self.selected_font_style = self.default_font_style self.selected_font_size = self.default_font_size self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) self.set_font(self.default_font, self.default_font_style, self.default_font_size) # Ensure these are unchanged ck.state = self.use_theme = False def _set_theme_data(self): tb_style = self.font_demo.textblock.style_get() font = tb_style.split('text_class=entry_text')[1].split( 'font=')[1].split("'em=")[0] # font may or may not have style associated with it if ':style=' in font: font, style = font.split(':style=') else: style = None # If font name or styyle has spaces in it # textblock.style_get() inserts '\' before space # then the python string split function adds another space # To set the style with a font name that has spaces spaces need to be removed font = font.replace('\\ ', ' ') if style: style = style.replace('\\ ', ' ') size = tb_style.split('text_class=entry_text')[1].split( 'font_size=')[1].split(' ')[0] self.theme_data = [font, style, float(size)] def set_font(self, font, style=None, size=None): found_font = found_style = False #print(self.set_font.__name__, font, style, size, self.use_theme) for font_it in self.font_list.items: if '\\' in font: # Special characters in font names cause problems # need to remove the escape characters before comparison font = font.replace('\\', '') if font == font_it.text: found = True self.selected_font = font_it.text font_it.selected = True font_it.show() break if size and self.fs_min <= size <= self.fs_max: self.selected_font_size = size self.font_sizer.value_set(size) if found_font: self.__reset_font_style_list(font) if style in self.fonts_hash[font_it.text]: for style_it in self.font_style.items: if style == style_it.text: self.selected_font_style = style_it.text style_it.selected = True style_it.show() found_style = True break if not found_style: self.__font_style_set(self.selected_font) # Ensure focus is on Font List self.font_list.focus_set(True) def __font_demo_name_set(self, f_list, font): if self.use_theme: self.use_theme = self.use_theme_ck.state = False self.__reset_font_style_list(font.text_get()) self.__font_style_set(font.text_get()) # Ensure focus is on Font List self.font_list.focus_set(True) def __font_demo_style_set(self, s_list, style): if self.use_theme: self.use_theme = self.use_theme_ck.state = False self.__font_style_set(self.font_list.selected_item_get().text_get()) def __font_demo_size_set(self, sizer): if self.use_theme: self.use_theme = self.use_theme_ck.state = False self.__font_style_set(self.font_list.selected_item_get().text_get()) def __font_style_set(self, font_name): #print (" __font_style_set", font_name) while self.font_demo.text_style_user_peek(): self.font_demo.text_style_user_pop() if self.font_style.selected_item_get(): font_style = self.font_style.selected_item_get().text_get() else: font_style = self.font_style.first_item_get().text_get() font_size = self.font_sizer.value_get() style = self.get_text_style(font_name, font_style, font_size) self.font_demo.text_style_user_push(style) self.font_style_str = style def __reset_font_style_list(self, font_name): self.font_style.clear() self.__normalize_font_style_list(font_name) for style in self.fonts_hash[font_name]: self.font_style.item_append(style) if font_name == self.default_font and style == self.selected_font_style: self.font_style.last_item_get().selected_set(True) if font_name != self.default_font: self.font_style.first_item_get().selected_set(True) #print(self.font_style.first_item_get()) #self.font_style.first_item_get().selected_set(True) self.font_style.first_item_get().show() def get_text_style(self, font_name, font_style_str, font_size): if "'" in font_name: # Special characters in font name issue font_name = font_name.replace("'", "\\'") if font_style_str: style = "DEFAULT='font_size={0} font={1}:style={2}'".format( font_size, font_name.replace(' ', '\ '), font_style_str.replace(' ', '\ ')) else: style = "DEFAULT='font_size={0} font={1}'".format( font_size, font_name.replace(' ', '\ ')) return style def __normalize_font_style_list(self, font_name): styles_list = self.fonts_hash[font_name] if 'Regular' in styles_list and styles_list[0] != 'Regular': styles_list.remove('Regular') styles_list.insert(0, 'Regular') def show(self): #print("SHOW Selected ", self.use_theme, self.selected_font, self.selected_font_style) #print("SHOW default ", self.use_theme, self.default_font, self.default_font_style) if self.__first_run: # only set the callbacks once # needed when called from another window repeatedly #print("__first_run__") self.font_list.callback_selected_add(self.__font_demo_name_set) self.font_style.callback_selected_add(self.__font_demo_style_set) self.font_sizer.callback_changed_add(self.__font_demo_size_set) self.__first_run = False self.show.__func__.use_theme_init = self.use_theme self.use_theme_ck.state = self.use_theme if self.use_theme: self.__use_theme_checked(self.use_theme_ck) #print("selected", self.font_list.selected_item_get().text_get()) if not self.use_theme: self.set_font(self.selected_font, self.selected_font_style, self.selected_font_size) super(FontSelector, self).show()
def focus4_clicked(obj, item=None): win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320)) win.focus_highlight_enabled = True win.focus_highlight_animate = True fr = Frame(win, style="pad_large", size_hint_weight=EXPAND_BOTH) win.resize_object_add(fr) fr.show() # First Example - Using Focus Highlight bx = Box(fr) fr.content = bx bx.show() tg = Check(bx, text="Focus Highlight Enabled (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Config)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_highlight_animate_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Enabled (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_enabled_cb, win) bx.pack_end(tg) tg.show() tg = Check(bx, text="Focus Highlight Animate (Win)", state=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_win_highlight_animate_cb, win) bx.pack_end(tg) tg.show() sp = Separator(win, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(sp) sp.show() # Second Example - Using Custom Chain lb = Label(bx, text="Custom Chain: Please use tab key to check", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() bx2 = Box(bx, horizontal=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() bt1 = Button(bx2, text="Button 1", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt1) bt1.show() bt2 = Button(bx2, text="Button 2", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt2) bt2.show() bt3 = Button(bx2, text="Button 3", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt3) bt3.show() bt4 = Button(bx2, text="Button 4", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(bt4) bt4.show() bx2.focus_custom_chain = [bt2, bt1, bt4, bt3] tg = Check(bx, text="Custom Chain", state=False, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) tg.callback_changed_add(_custom_chain_cb, bx) bx.pack_end(tg) tg.show() win.show()