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


Python mw.state方法代碼示例

本文整理匯總了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 
開發者ID:krassowski,項目名稱:Anki-Night-Mode,代碼行數:37,代碼來源:night_mode.py

示例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 
開發者ID:Arthur-Milchior,項目名稱:anki-enhance-main-window,代碼行數:11,代碼來源:node.py

示例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 
開發者ID:Arthur-Milchior,項目名稱:anki-enhance-main-window,代碼行數:5,代碼來源:node.py

示例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')
    ) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:8,代碼來源:util.py

示例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']) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:17,代碼來源:view.py

示例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']) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:17,代碼來源:view.py

示例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) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:10,代碼來源:view.py

示例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 
開發者ID:glutanimate,項目名稱:anki-addons-misc,代碼行數:41,代碼來源:overview_deck_switcher.py

示例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)) 
開發者ID:glutanimate,項目名稱:anki-addons-misc,代碼行數:11,代碼來源:reviewer_browse_creation.py

示例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) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:17,代碼來源:main.py


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