本文整理汇总了Python中aqt.mw.state方法的典型用法代码示例。如果您正苦于以下问题:Python mw.state方法的具体用法?Python mw.state怎么用?Python mw.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aqt.mw
的用法示例。
在下文中一共展示了mw.state方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def refresh(self, reload=False):
"""
Refresh display by re-enabling night or normal mode,
regenerate customizable css strings.
"""
state = self.config.state_on.value
if not self.profile_loaded:
alert(ERROR_NO_PROFILE)
return
try:
if state:
if reload:
self.off()
self.on()
else:
self.off()
except Exception:
alert(ERROR_SWITCH % traceback.format_exc())
return
# Reload current screen.
if mw.state == 'review':
mw.moveToState('overview')
mw.moveToState('review')
if mw.state == 'deckBrowser':
mw.deckBrowser.refresh()
if mw.state == 'overview':
mw.overview.refresh()
# Redraw toolbar (should be always visible).
mw.toolbar.draw()
self.update_menu()
return True
示例2: getCollapse
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def getCollapse(self):
# We reload the deck. The collapsed state may have changed.
self.deck = mw.col.decks.get(self.did)
prefix = "+" if self.deck['collapsed'] else "-"
# deck link
if self.children:
return collapse_children_html(self.did, self.deck["name"], prefix)
else:
return collapse_no_child
示例3: onRefreshTimer
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def onRefreshTimer():
if mw.state == "deckBrowser":
mw.deckBrowser._renderPage() # was refresh, but we're disabling that
示例4: viewingIrText
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def viewingIrText():
return (
isIrCard(mw.reviewer.card)
and (mw.reviewer.state == 'question')
and (mw.state == 'review')
)
示例5: zoomIn
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def zoomIn(self):
if viewingIrText():
cid = str(mw.reviewer.card.id)
if cid not in self.settings['zoom']:
self.settings['zoom'][cid] = 1
self.settings['zoom'][cid] += self.settings['zoomStep']
mw.web.setZoomFactor(self.settings['zoom'][cid])
elif mw.state == 'review':
self.zoomFactor += self.settings['zoomStep']
mw.web.setZoomFactor(self.zoomFactor)
else:
self.settings['generalZoom'] += self.settings['zoomStep']
mw.web.setZoomFactor(self.settings['generalZoom'])
示例6: zoomOut
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def zoomOut(self):
if viewingIrText():
cid = str(mw.reviewer.card.id)
if cid not in self.settings['zoom']:
self.settings['zoom'][cid] = 1
self.settings['zoom'][cid] -= self.settings['zoomStep']
mw.web.setZoomFactor(self.settings['zoom'][cid])
elif mw.state == 'review':
self.zoomFactor -= self.settings['zoomStep']
mw.web.setZoomFactor(self.zoomFactor)
else:
self.settings['generalZoom'] -= self.settings['zoomStep']
mw.web.setZoomFactor(self.settings['generalZoom'])
示例7: resetZoom
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def resetZoom(self, state, *args):
if not hasattr(self, 'settings'):
return
if state in ['deckBrowser', 'overview']:
mw.web.setZoomFactor(self.settings['generalZoom'])
elif state == 'review' and not isIrCard(mw.reviewer.card):
self.setZoom(self.zoomFactor)
示例8: quickSwitchDeck
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def quickSwitchDeck(drc):
# get info on current decks
oldid = mw.col.decks.current()["id"]
dl = mw.col.sched.deckDueList()
cnt = mw.col.decks.count()
# find index of current deck in duelist
for i, deck in enumerate(dl):
if deck[1] == oldid:
idx = i
break
i = idx + drc
newid = oldid
# iterate through decks and skip based on configuration
while (i != idx):
if i == cnt:
# reached end of list
i = 0
did = dl[i][1]
crds = dl[i][2] + dl[i][3] + dl[i][4]
i += drc
if deck_switcher_skip_filtered and mw.col.decks.isDyn(did):
continue
if crds > 0 or not deck_switcher_skip_empty:
newid = did
break
# set new did
mw.col.decks.select(newid)
# uncollapse parent decks if applicable
parents = mw.col.decks.parents(newid)
for parent in parents:
if parent["collapsed"]:
mw.col.decks.collapse(parent["id"])
# refresh view
if mw.state == "deckBrowser":
mw.deckBrowser.refresh()
else:
mw.onOverview()
# Set up menu entries and hotkeys
示例9: insert_reviewer_more_action
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def insert_reviewer_more_action(self, m):
#self is Reviewer
if mw.state != "review":
return
a = m.addAction('Browse Creation of This Card')
a.setShortcut(QKeySequence("c"))
a.triggered.connect(lambda _, s=mw.reviewer: browse_this_card(s))
a = m.addAction('Browse Creation of Last Card')
a.triggered.connect(lambda _, s=mw.reviewer: browse_last_card(s))
示例10: searchTerm
# 需要导入模块: from aqt import mw [as 别名]
# 或者: from aqt.mw import state [as 别名]
def searchTerm(self):
text = selectedText(self)
if text:
text = re.sub(r'\[[^\]]+?\]', '', text)
text = text.strip()
if not mw.miaDictionary or not mw.miaDictionary.isVisible():
dictionaryInit(text)
mw.miaDictionary.ensureVisible()
mw.miaDictionary.initSearch(text)
if self.title == 'main webview':
if mw.state == 'review':
mw.miaDictionary.dict.setReviewer(mw.reviewer)
elif self.title == 'editor':
target = getTarget(type(self.parentEditor.parentWindow).__name__)
mw.miaDictionary.dict.setCurrentEditor(self.parentEditor, target)