def add_buttons(buttons: List[str], editor: Editor) -> List[str]: if config['soften'] == 'enabled': soften_button = editor.addButton( icon=ICON_SOFTEN_PATH, cmd="soften_text", func=lambda editor: soften(editor), tip=SOFTEN_TOOLTIP+' '+config['soften-shortcut'], keys=config['soften-shortcut'] ) buttons.append(soften_button) if config['contrast'] == 'enabled': contrast_button = editor.addButton( icon=ICON_CONTRAST_PATH, cmd="contrast_text", func=lambda editor: contrast(editor), tip=CONTRAST_TOOLTIP+' '+config['contrast-shortcut'], keys=config['contrast-shortcut'] ) buttons.append(contrast_button) if config['emphasize'] == 'enabled': emphasize_button = editor.addButton( icon=ICON_EMPHASIZE_PATH, cmd="emphasize_text", func=lambda editor: emphasize(editor), tip=EMPHASIZE_TOOLTIP+' '+config['emphasize-shortcut'], keys=config['emphasize-shortcut'] ) buttons.append(emphasize_button) return buttons
def on_setup_buttons(buttons: List[str], editor: Editor) -> List[str]: """ Add Addon button and Addon combobox to card editor. :param buttons: HTML codes of the editor buttons (e.g. for bold, italic, ...) :param editor: card editor object :return: updated list of buttons """ # add HTML button button = editor.addButton(ICON_PATH, "IPA", paste_ipa) buttons.append(button) # create list of language options previous_lang = get_default_lang(mw) options = [f"""<option>{previous_lang}</option>""" ] # first entry is the last selection options += [ f"""<option>{language}</option>""" for language in sorted(consts.LANGUAGES_MAP.keys(), key=str.lower) if language != previous_lang ] # add HTML combobox combo = select_elm.format("".join(options)) buttons.append(combo) return buttons
def add_editor_button(cls, buttons: List[str], editor: Editor) -> None: b = editor.addButton( icon=os.path.join(ADDON_PATH, "icons", "edit.svg"), cmd="rename_media_files", func=cls.show_rename_dialog, tip="Rename media files referenced by note.", ) buttons.append(b)
def on_editor_did_init_buttons(buttons: List[str], editor: Editor): global config # pylint: disable=global-statement btn = editor.addButton( icon=os.path.join(addon_dir, "icon.svg"), cmd="armajor", func=open_dialog_in_editor, tip="مولد نظام المذكرات الصوتي للعربية", keys=config.get("shortcut", "Ctrl+Shift+K"), ) buttons.append(btn)
def add_buttons(buttons, editor: Editor): this_path = os.path.dirname(__file__) icon_path = os.path.abspath(os.path.join(this_path, 'resources', 'ruby.svg')) button = editor.addButton( # icon='qrc:///icons/anki.png', icon=icon_path, cmd='smr_rubify', func=rubify, tip="""Add pinyin ruby to selection""", # label='Ruby', ) buttons.append(button)
def on_setup_buttons(buttons: List[str], editor: Editor) -> List[str]: button = editor.addButton(ICON_PATH, "myad", paste_definitions) buttons.append(button) previous_dic = get_default_dictionary(mw) options = [f"""<option>{previous_dic}</option>""" ] # first entry is the last selection options += [ f"""<option>{dic}</option>""" for dic in dictionaries if dic != previous_dic ] combo = select_elm.format("".join(options)) buttons.append(combo) return buttons
def add_preview_button(leftbuttons: List[str], editor: Editor) -> None: preview_shortcut = "Ctrl+Shift+P" leftbuttons.insert( 0, editor.addButton( None, "preview", lambda _editor: self.onTogglePreview(), tr.browsing_preview_selected_card( val=shortcut(preview_shortcut), ), tr.actions_preview(), id="previewButton", keys=preview_shortcut, disables=False, rightside=False, toggleable=True, ), )