How to use the aqt.mw.pm function in aqt

To help you get started, we’ve selected a few aqt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ospalh / anki-addons / downloadaudio / download.py View on Github external
from aqt.utils import tooltip
from anki.hooks import addHook

from .downloaders import downloaders
from .download_entry import DownloadEntry, Action
from .get_fields import get_note_fields, get_side_fields
from .language import language_code_from_card, language_code_from_editor
from .processors import processor
from .review_gui import review_entries
from .update_gui import update_data

DOWNLOAD_NOTE_SHORTCUT = "q"
DOWNLOAD_SIDE_SHORTCUT = "t"
DOWNLOAD_MANUAL_SHORTCUT = "Ctrl+t"

icons_dir = os.path.join(mw.pm.addonFolder(), 'downloadaudio', 'icons')
# Place were we keep our megaphone icon.


def do_download(note, field_data_list, language, hide_text=False):
    """
    Download audio data.

    Go through the list of words and list of sites and download each
    word from each site. Then call a function that asks the user what
    to do.
    """
    retrieved_entries = []
    for field_data in field_data_list:
        if field_data.empty:
            continue
        for dloader in downloaders:
github rsimmons / anki-cropro / cropro.py View on Github external
def getOtherProfileNames():
    profiles = mw.pm.profiles()
    profiles.remove(mw.pm.name)
    return profiles
github krassowski / Anki-TouchScreen / touchscreen / __init__.py View on Github external
def ts_load():
    """
    Load configuration from profile, set states of checkable menu objects
    and turn on night mode if it were enabled on previous session.
    """
    global ts_state_on, ts_color, ts_profile_loaded, ts_line_width, ts_opacity

    try:
        ts_state_on = mw.pm.profile['ts_state_on']
        ts_color = mw.pm.profile['ts_color']
        ts_line_width = mw.pm.profile['ts_line_width']
        ts_opacity = mw.pm.profile['ts_opacity']
    except KeyError:
        ts_state_on = False
        ts_color = "#f0f"
        ts_line_width = 4
        ts_opacity = 0.8
    ts_profile_loaded = True

    if ts_state_on:
        ts_on()

    assure_plugged_in()
github fanatic84 / KanjiKeywordOverlay / Kanji Overlay.py View on Github external
def load(self):
        
        log("Load Plugin")
        
        profileName = mw.pm.name
        pf = self.Profiles
        profileVar = pf["DEFAULT"] if not profileName in pf else pf[profileName]
        self.KanjiUseCustomDeck = profileVar["KanjiUseCustomDeck"]
        if self.KanjiUseCustomDeck:
            self.KanjiDeckName = profileVar["KanjiCustomDeckName"]
            self.KanjiExpression = profileVar["KanjiCustomExpression"]
            self.KanjiKeyword = profileVar["KanjiCustomKeyword"]
        self.KanjiDisplayWithFuriganaMod = profileVar["KanjiDisplayWithFuriganaMod"]
        
        self.kanjiCustomDictPath = kanjiCustomDictPath = os.path.join(mw.pm.profileFolder(), 'custom-kol.db')
        self.kanjiDefaultDictPath = kanjiDefaultDictPath = os.path.join(mw.pm.addonFolder(), 'kol', 'english-kol.db')
        self.cssFileInPlugin = os.path.join(mw.pm.addonFolder(), 'kol', 'default-kol.css')
        self.cssFileInProfile = os.path.join(mw.pm.profileFolder(), 'custom-kol.css')
        self.kanjiDict = None
        
        if self.KanjiUseCustomDeck:
github ospalh / anki-addons / downloadtatoeba / download.py View on Github external
strings that can be modified before the requests are sent.
"""

import os
from PyQt4.QtGui import QAction, QIcon, QMenu
from PyQt4.QtCore import SIGNAL

from aqt import mw
from aqt.utils import tooltip
from anki.hooks import addHook

from .get_fields import get_note_fields, get_side_fields
from .language import language_codes_from_card, language_codes_from_editor


icons_dir = os.path.join(mw.pm.addonFolder(), 'downloadaudio', 'icons')
"""Place were we keep our megaphone icon.."""

# A bit of set-up
for downloader in downloaders:
    # We have two audio "processors". One that is actually processing,
    # and one where we would have to move files around, but where we
    # can skip that step. Let the downloaders know which one we have.
    downloader.use_temp_files = processor.useful


def do_download(note, field_data, language, hide_text=False):
    """
    Download audio data.

    Go through the list of words and list of sites and download each
    word from each site. Then call a function that asks the user what
github fanatic84 / KanjiKeywordOverlay / kol / src / KolOverlay.py View on Github external
def __setupObjectData(self):
        self.kanjiDefaultDictPath = os.path.join(mw.pm.addonFolder(), "kol", "data", "english.db")
        self.kanjiCustomDictPath = os.path.join(mw.pm.profileFolder(), "kol", "user_files", "custom-kol.db")

        self.cssFileInPlugin = os.path.join(mw.pm.addonFolder(), "kol", "data", "styles.css")
        self.cssFileUserFiles = os.path.join(mw.pm.addonFolder(), "kol", "user_files", "styles.css")

        self.scriptsFileInPlugin = os.path.join(mw.pm.addonFolder(), "kol", "data", "scripts.js")
        self.scriptsFileUserFiles = os.path.join(mw.pm.addonFolder(), "kol", "user_files", "scripts.js")

        self.templateInPlugin = os.path.join(mw.pm.addonFolder(), "kol", "data", "template.hbs")
        self.templateUserFiles = os.path.join(mw.pm.addonFolder(), "kol", "user_files", "template.hbs")
github rsimmons / anki-cropro / cropro.py View on Github external
def getOtherProfileNames():
    profiles = mw.pm.profiles()
    profiles.remove(mw.pm.name)
    return profiles
github jre2 / JapaneseStudy / anki / plugins / morphman3 / morph / util.py View on Github external
def cfg( modelId, deckId, key ):
    assert cfgMod, 'Tried to use cfgMods before profile loaded'
    profile = mw.pm.name
    model = mw.col.models.get( modelId )[ 'name' ] if modelId else None
    deck = mw.col.decks.get( deckId )[ 'name' ] if deckId else None
    if key in cfgMod.deck_overrides.get( deck, [] ):
        return cfgMod.deck_overrides[ deck ][ key ]
    elif key in cfgMod.model_overrides.get( model, [] ):
        return cfgMod.model_overrides[ model ][ key ]
    elif key in cfgMod.profile_overrides.get( profile, [] ):
        return cfgMod.profile_overrides[ profile ][ key ]
    else:
        return cfgMod.default[ key ]
github rsimmons / anki-cropro / cropro.py View on Github external
def logDebug(o):
    if not ENABLE_DEBUG_LOG:
        return

    global logfile
    if not logfile:
        fn = os.path.join(mw.pm.base, 'cropro.log')
        logfile = open(fn, 'a')
    logfile.write(str(o) + '\n')
    logfile.flush()
github ayuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu / pangu.anki / pangu_anki / config.py View on Github external
import locale

from aqt import mw
from aqt.utils import showInfo

__all__ = ["get_auto_space_flag", "get_auto_space_name", "get_plugin_menu_name",
           "get_space_name", "get_auto_space_shortcut", "get_space_shortcut",
           "set_auto_space", "mw"]

config = mw.addonManager.getConfig(__name__)
lang = mw.pm.meta.get("defaultLang", "en")


def get_plugin_name():
    plugin_name = config["plugin_name"]
    return plugin_name


def get_plugin_menu():
    plugin_menu = config["plugin_menu"]
    return plugin_menu


def get_plugin_menu_name():
    plugin_menu = get_plugin_menu()
    plugin_menu_name = plugin_menu["name"]
    return plugin_menu_name