當前位置: 首頁>>代碼示例>>Python>>正文


Python mw.col方法代碼示例

本文整理匯總了Python中aqt.mw.col方法的典型用法代碼示例。如果您正苦於以下問題:Python mw.col方法的具體用法?Python mw.col怎麽用?Python mw.col使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aqt.mw的用法示例。


在下文中一共展示了mw.col方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setAllDeck

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def setAllDeck(self):
        t = self.deckList.currentText()
        self.deckList.clear()
        alldecks = mw.col.decks.allNames()
        try:
            alldecks.remove('Default')
        except:
            alldecks.remove('默認')
        finally:
            pass
        
        for deckname in alldecks:
            self.deckList.addItem(deckname)
        if t:
            self.deckList.setEditText(t)
        self.debug.appendPlainText('142: setAllDeck') 
開發者ID:megachweng,項目名稱:Anki-Youdao,代碼行數:18,代碼來源:Youdao-Anki.py

示例2: _createNote

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def _createNote(self, title, text, source, priority=None):
        if self.settings['importDeck']:
            deck = mw.col.decks.byName(self.settings['importDeck'])
            if not deck:
                showWarning(
                    'Destination deck no longer exists. '
                    'Please update your settings.'
                )
                return
            did = deck['id']
        else:
            did = mw.col.conf['curDeck']

        model = mw.col.models.byName(self.settings['modelName'])
        note = Note(mw.col, model)
        setField(note, self.settings['titleField'], title)
        setField(note, self.settings['textField'], text)
        setField(note, self.settings['sourceField'], source)
        if priority:
            setField(note, self.settings['prioField'], priority)
        note.model()['did'] = did
        mw.col.addNote(note)
        mw.deckBrowser.show()
        return mw.col.decks.get(did)['name'] 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:26,代碼來源:importer.py

示例3: _addPrioFields

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def _addPrioFields(self):
        model = mw.col.models.byName(self.settings['modelName'])
        if self.settings['prioField'] in getFieldNames(
            self.settings['modelName']
        ):
            return
        field = mw.col.models.newField(self.settings['prioField'])
        mw.col.models.addField(model, field)
        for (nid,) in mw.col.db.execute(
            'SELECT id FROM notes WHERE mid = ?', model['id']
        ):
            note = mw.col.getNote(nid)
            setField(
                note, self.settings['prioField'], self.settings['prioDefault']
            )
            note.flush()
        showInfo(
            'A <b><i>Priority</i></b> field has been added to your IR notes. '
            'Valid priority values are integers 1-10, where 10 represents '
            'the higest priority. By default, the field is set to 5. '
            'When randomizing cards, priorities are taken into account.'
        ) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:24,代碼來源:gui.py

示例4: _updateQuickKeysTab

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def _updateQuickKeysTab(self):
        keyCombo = self.quickKeysComboBox.currentText()
        if keyCombo:
            settings = self.settings['quickKeys'][keyCombo]
            setComboBoxItem(self.destDeckComboBox, settings['extractDeck'])
            setComboBoxItem(self.noteTypeComboBox, settings['modelName'])
            setComboBoxItem(self.textFieldComboBox, settings['textField'])
            setComboBoxItem(self.sourceFieldComboBox, settings['sourceField'])
            self.ctrlKeyCheckBox.setChecked(settings['ctrl'])
            self.altKeyCheckBox.setChecked(settings['alt'])
            self.shiftKeyCheckBox.setChecked(settings['shift'])
            setComboBoxItem(self.regularKeyComboBox, settings['regularKey'])
            self.quickKeyEditExtractCheckBox.setChecked(
                settings['editExtract']
            )
            self.quickKeyEditSourceCheckBox.setChecked(settings['editSource'])
            self.quickKeyPlainTextCheckBox.setChecked(settings['plainText'])
            self.tagsEditBox.setText(mw.col.tags.join(settings['tags']))
        else:
            self._clearQuickKeysTab() 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:22,代碼來源:gui.py

示例5: addCustomModel

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def addCustomModel(name, col):
    """create a new custom model for the imported deck"""
    mm = col.models
    existing = mm.byName("YoudaoWordBook")
    if existing:
        return existing
    m = mm.new("YoudaoWordBook")
    # add fields
    mm.addField(m, mm.newField("term"))
    mm.addField(m, mm.newField("definition"))
    mm.addField(m, mm.newField("uk_phonetic"))
    mm.addField(m, mm.newField("us_phonetic"))
    mm.addField(m, mm.newField("phrase0"))
    mm.addField(m, mm.newField("phrase1"))
    mm.addField(m, mm.newField("phrase2"))
    mm.addField(m, mm.newField("phraseExplain0"))
    mm.addField(m, mm.newField("phraseExplain1"))
    mm.addField(m, mm.newField("phraseExplain2"))

    # add cards
    t = mm.newTemplate("Normal")
    t['qfmt'] = Note.returnFront(3)
    t['afmt'] = Note.returnBack(3)
    mm.addTemplate(m, t)
    mm.add(m)
    return m 
開發者ID:megachweng,項目名稱:Anki-Youdao,代碼行數:28,代碼來源:Youdao-Anki.py

示例6: add_models

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def add_models():
    models.append(('Chinese (Advanced)', advanced.add_model))
    models.append(('Chinese (Basic)', basic.add_model))
    if not mw.col.models.byName('Chinese (Advanced)'):
        advanced.add_model(mw.col)
    if not mw.col.models.byName('Chinese (Basic)'):
        basic.add_model(mw.col) 
開發者ID:luoliyan,項目名稱:chinese-support-redux,代碼行數:9,代碼來源:main.py

示例7: bulk_fill_all

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def bulk_fill_all():
    prompt = (
        '<div>This will update <i>all</i> non-audio fields in the current deck.</div>'
        '<div>Please back up your Anki collection first!</div>'
        '<div><b>Continue?</b></div>'
    )

    if not askUser(prompt):
        return

    note_ids = Finder(mw.col).findNotes('deck:current')
    mw.progress.start(immediate=True, min=0, max=len(note_ids))
    n_updated = 0
    n_failed = 0  # FIXME
    exclude = config.get_fields(['sound', 'mandarinSound', 'cantoneseSound'])

    for i, nid in enumerate(note_ids):
        note = mw.col.getNote(nid)
        fields = [
            f
            for f in mw.col.models.fieldNames(note.model())
            if f not in exclude
        ]
        n_updated += update_fields(note, 'Hanzi', fields)
        msg = PROGRESS_TEMPLATE % {
            'hanzi': get_hanzi(dict(note)),
            'n_processed': i,
            'n_updated': n_updated,
            'n_failed': n_failed,
        }

        mw.progress.update(label=msg, value=i)
        note.flush()

    mw.progress.finish()
    showInfo(
        '<b>Bulk filling complete</b><br>'
        '<b>Processed:</b> {}<br>'.format(len(note_ids))
    ) 
開發者ID:luoliyan,項目名稱:chinese-support-redux,代碼行數:41,代碼來源:fill.py

示例8: schedVer

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def schedVer():
    if ANKI20:
        return 1
    if not mw.col:  # collection not loaded
        return None
    return mw.col.schedVer() 
開發者ID:glutanimate,項目名稱:review-heatmap,代碼行數:8,代碼來源:platform.py

示例9: pathMediaFiles

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def pathMediaFiles():
    return mw.col.media.dir() 
開發者ID:glutanimate,項目名稱:review-heatmap,代碼行數:4,代碼來源:platform.py

示例10: __init__

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def __init__(self, config, whole=False):
        # TODO: rethink "whole" support
        self.config = config
        self.whole = whole
        self.activity = ActivityReporter(mw.col, self.config, whole=whole) 
開發者ID:glutanimate,項目名稱:review-heatmap,代碼行數:7,代碼來源:heatmap.py

示例11: rerenderNote

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def rerenderNote(nid: int):
    res = mw.col.db.all("select distinct notes.id, flds, tags, did, mid from notes left join cards on notes.id = cards.nid where notes.id = %s" % nid)
    if res is not None and len(res) > 0:
        res = res[0]
        index = get_index()
        if index is not None and index.ui is not None:
            index.ui.updateSingle(res) 
開發者ID:fonol,項目名稱:anki-search-inside-add-card,代碼行數:9,代碼來源:command_parsing.py

示例12: _editExtract

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def _editExtract(self, note, did, settings):
        def onAdd():
            addCards.rejected.disconnect(self.undo)
            addCards.reject()

        addCards = AddCards(mw)
        addCards.rejected.connect(self.undo)
        addCards.addButton.clicked.connect(onAdd)
        addCards.editor.setNote(note, focusTo=0)
        deckName = mw.col.decks.get(did)['name']
        addCards.deckChooser.setDeckName(deckName)
        addCards.modelChooser.models.setText(settings['modelName'])
        return True 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:15,代碼來源:text.py

示例13: _getTitle

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def _getTitle(self, note, did, title, settings):
        title, accepted = getText(
            'Enter title', title='Extract Text', default=title
        )

        if accepted:
            setField(note, settings['titleField'], title)
            note.model()['did'] = did
            mw.col.addNote(note)

        return accepted 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:13,代碼來源:text.py

示例14: downloadForvoAudio

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def downloadForvoAudio( urls, howMany):
    tags = []
    for url in urls:
        if len(tags) == howMany:
            break
        try:
            req = Request(url[3] , headers={'User-Agent':  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'})
            file = urlopen(req).read()
            filename = str(time.time()) + '.mp3'
            open(join(mw.col.media.dir(), filename), 'wb').write(file)
            tags.append('[sound:' + filename + ']')
            success = True
        except: 
            success = True
        if success:
            continue
        else:
            try:
                req = Request(url[2] , headers={'User-Agent':  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'})
                file = urlopen(req).read()
                filename = str(time.time()) + '.mp3'
                open(join(mw.col.media.dir(), filename), 'wb').write(file)
                tags.append('[sound:' + filename + ']')
            except:
                continue
    return tags 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:28,代碼來源:main.py

示例15: addModel

# 需要導入模塊: from aqt import mw [as 別名]
# 或者: from aqt.mw import col [as 別名]
def addModel(col):
    """Add add-on note type to collection"""
    models = col.models
    model = models.new(OLC_MODEL)
    model['type'] = MODEL_CLOZE
    # Add fields:
    for i in OLC_FLDS_IDS:
        if i == "tx":
            for i in range(1, OLC_MAX+1):
                fld = models.newField(OLC_FLDS["tx"]+str(i))
                fld["size"] = 12
                models.addField(model, fld)
            continue
        fld = models.newField(OLC_FLDS[i])
        if i == "st":
            fld["sticky"] = True
        if i == "fl":
            fld["size"] = 12
        models.addField(model, fld)
    # Add template
    template = models.newTemplate(OLC_CARD)
    template['qfmt'] = card_front
    template['afmt'] = card_back
    model['css'] = card_css
    model['sortf'] = 1  # set sortfield to title
    models.addTemplate(model, template)
    models.add(model)
    return model 
開發者ID:glutanimate,項目名稱:cloze-overlapper,代碼行數:30,代碼來源:template.py


注:本文中的aqt.mw.col方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。