本文整理汇总了Python中aqt.mw.reset方法的典型用法代码示例。如果您正苦于以下问题:Python mw.reset方法的具体用法?Python mw.reset怎么用?Python mw.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aqt.mw
的用法示例。
在下文中一共展示了mw.reset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toggleHeatmap
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def toggleHeatmap():
"""Toggle heatmap display on demand"""
state = mw.state.lower()
hm_active = config["profile"]["display"].get(state, None)
if hm_active is None:
# unrecognized mw state
return False
config["profile"]["display"][state] = not hm_active
mw.reset()
示例2: deckStatsInit21
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def deckStatsInit21(self, mw):
self.form.web.onBridgeCmd = self._linkHandler
# refresh heatmap on options change:
addHook("reset", self.refresh)
示例3: deckStatsReject
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def deckStatsReject(self):
# clean up after ourselves:
remHook("reset", self.refresh)
######################################################################
# NEW HOOKS
######################################################################
示例4: undo
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def undo(self):
note = mw.reviewer.card.note()
if note.id not in self.history or not self.history[note.id]:
showInfo('No undo history for this note.')
return
note['Text'] = self.history[note.id].pop()
note.flush()
mw.reset()
tooltip('Undone')
示例5: refresh_media
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def refresh_media():
# clear QWebView cache
QWebSettings.clearMemoryCaches()
# write a dummy file to update collection.media modtime and force sync
media_dir = mw.col.media.dir()
fpath = os.path.join(media_dir, "syncdummy.txt")
if not os.path.isfile(fpath):
with open(fpath, "w") as f:
f.write("anki sync dummy")
os.remove(fpath)
# reset Anki
mw.reset()
tooltip("Media References Updated")
# Set up menus and hooks
示例6: performDeckOrgActions
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def performDeckOrgActions():
"""Parse org_tasks dictionary for tasks and perform them"""
returncodes = []
mw.checkpoint("Deck Organization Tasks")
for task in org_tasks:
action = task.get("action", "move")
try:
assert action in VALID_ACTIONS
except AssertionError:
print("Invalid task. Skipping")
returncodes.append("invalid")
continue
ret = moveCardsAction(task)
if ret:
returncodes.append(ret)
mw.reset()
msg = ["Deck organization tasks complete."]
if "invalid" in returncodes:
msg.append("Warning: Your task dictionary contained invalid"
" tasks that had to be skipped.")
if "dynamic" in returncodes:
msg.append("Warning: Some of your decks are filtered decks."
"<br>Moving cards into filtered decks is not supported")
if "nocids" in returncodes:
msg.append("Warning: Some of the origin decks did not contain"
"any transferable cards.<br>Actions were skipped in those"
" instances.")
info = "<br><br>".join(msg)
tooltip(info)
示例7: onClearFormatting
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def onClearFormatting(browser):
"""
Clears the formatting for every selected note.
Also creates a restore point, allowing a single undo operation.
Parameters
----------
browser : Browser
the anki browser from which the function is called
"""
nids = browser.selectedNotes()
if not nids:
tooltip(_("No cards selected."), period=2000)
return
mw.checkpoint("Batch-Remove Field Formatting")
mw.progress.start()
for nid in nids:
note = mw.col.getNote(nid)
note.fields = stripFormatting(note.fields)
note.flush()
mw.progress.finish()
mw.reset()
# Hooks
示例8: syncYoudao
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def syncYoudao(self, result, name):
deleted = result['deleted']
terms = result['terms']
cardID = []
if terms:
deck = mw.col.decks.get(mw.col.decks.id(name))
model = addCustomModel(name, mw.col)
# assign custom model to new deck
mw.col.decks.select(deck["id"])
mw.col.decks.get(deck)["mid"] = model["id"]
mw.col.decks.save(deck)
# assign new deck to custom model
mw.col.models.setCurrent(model)
mw.col.models.current()["did"] = deck["id"]
mw.col.models.save(model)
for term in terms:
note = mw.col.newNote()
note['term'] = term['term']
if term['definition']:
note['definition'] = term['definition']
else:
note['definition'] = 'No definition'
if 'uk_phonetic' in term.keys():
note['uk_phonetic'] = term['uk_phonetic']
if 'us_phonetic' in term.keys():
note['us_phonetic'] = term['us_phonetic']
# fill phrase field
if ('phrase' in term.keys()) and term['phrase']['phrase_terms']:
Nphrases = len(term['phrase']['phrase_terms'])
if ('phrase_terms' in term['phrase']) and ('phrase_explains' in term['phrase']):
for i in range((Nphrases < 3 and Nphrases or 3)):
note['phrase' + str(i)] = term['phrase']['phrase_terms'][i] + "\t"
note['phraseExplain' + str(i)] = term['phrase']['phrase_explains'][i]
else:
for i in range((Nphrases < 3 and Nphrases or 3)):
note['phrase' + str(i)] = term['phrase']['phrase_terms'][i]
mw.col.addNote(note)
mw.col.reset()
mw.reset()
# delete cards
if deleted:
for term in deleted:
cardID = mw.col.findCards("term:" + term)
deckID = mw.col.decks.id(name)
for cid in cardID:
nid = mw.col.db.scalar("select nid from cards where id = ? and did = ?", cid, deckID)
if nid is not None:
mw.col.db.execute("delete from cards where id =?", cid)
mw.col.db.execute("delete from notes where id =?", nid)
mw.col.fixIntegrity()
mw.col.reset()
mw.reset()
self.setAllDeck()
showInfo('\nAdded : ' + str(len(terms)) + '\n\nDeleted : ' + str(len(deleted)))
示例9: exportDefinitions
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import reset [as 别名]
def exportDefinitions(og, dest, addType, dictNs, howMany, notes, generateWidget, rawNames):
mw.checkpoint('Definition Export')
if not miAsk('Are you sure you want to export definitions for the "'+ og + '" field into the "' + dest +'" field?'):
return
progWid, bar = getProgressWidgetDefs()
progWid.closeEvent = closeBar
bar.setMinimum(0)
bar.setMaximum(len(notes))
val = 0;
config = mw.addonManager.getConfig(__name__)
fb = config['frontBracket']
bb = config['backBracket']
lang = mw.addonManager.getConfig(__name__)['ForvoLanguage']
mw.MIAExportingDefinitions = True
for nid in notes:
if not mw.MIAExportingDefinitions:
break
note = mw.col.getNote(nid)
fields = mw.col.models.fieldNames(note.model())
if og in fields and dest in fields:
term = re.sub(r'<[^>]+>', '', note[og])
term = re.sub(r'\[[^\]]+?\]', '', term)
if term == '':
continue
tresults = []
dCount = 0
for dictN in dictNs:
if dictN == 'Google Images':
tresults.append(exportGoogleImages( term, howMany))
elif dictN == 'Forvo':
tresults.append(exportForvoAudio( term, howMany, lang))
elif dictN != 'None':
dresults, dh, th = mw.miDictDB.getDefForMassExp(term, dictN, str(howMany), rawNames[dCount])
tresults.append(formatDefinitions(dresults, th, dh, fb, bb))
dCount+= 1
results = '<br><br>'.join([i for i in tresults if i != ''])
if addType == 'If Empty':
if note[dest] == '':
note[dest] = results
elif addType == 'Add':
if note[dest] == '':
note[dest] = results
else:
note[dest] += '<br><br>' + results
else:
note[dest] = results
note.flush()
val+=1;
bar.setValue(val)
mw.app.processEvents()
mw.progress.finish()
mw.reset()
generateWidget.hide()
generateWidget.deleteLater()