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


Python aqt.mw方法代碼示例

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


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

示例1: config_menu

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def config_menu():
    """
    Adds a menu item to the Tools menu in Anki's main window for
    launching the configuration dialog.
    """

    gui.Action(
        target=Bundle(
            constructor=gui.Configurator,
            args=(),
            kwargs=dict(addon=addon, sul_compiler=to.substitution_compiled,
                        alerts=aqt.utils.showWarning,
                        ask=aqt.utils.getText,
                        parent=aqt.mw),
        ),
        text="Awesome&TTS...",
        sequence=sequences['configurator'],
        parent=aqt.mw.form.menuTools,
    ) 
開發者ID:AwesomeTTS,項目名稱:awesometts-anki-addon,代碼行數:21,代碼來源:__init__.py

示例2: window_shortcuts

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def window_shortcuts():
    """Enables shortcuts to launch windows."""

    def on_sequence_change(new_config):
        """Update sequences on configuration changes."""
        for key, sequence in sequences.items():
            new_sequence = QKeySequence(new_config['launch_' + key] or None)
            sequence.swap(new_sequence)

        try:
            aqt.mw.form.menuTools.findChild(gui.Action). \
                setShortcut(sequences['configurator'])
        except AttributeError:  # we do not have a config menu
            pass

    on_sequence_change(config)  # set config menu if created before we ran
    config.bind(['launch_' + key for key in sequences.keys()],
                on_sequence_change) 
開發者ID:AwesomeTTS,項目名稱:awesometts-anki-addon,代碼行數:20,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def __init__(self, config, mw, parent=None, **kwargs):
        # Mediator methods defined in mapped_widgets might need access to
        # certain instance attributes. As super().__init__ calls these
        # mediator methods it is important that we set the attributes
        # beforehand:
        self.parent = parent or mw
        self.mw = mw
        super(RevHmOptions, self).__init__(
            self._mapped_widgets,
            config,
            form_module=qtform_options,
            parent=self.parent,
            **kwargs
        )
        # Instance methods that modify the initialized UI should either be
        # called from self._setupUI or from here

    # UI adjustments 
開發者ID:glutanimate,項目名稱:review-heatmap,代碼行數:20,代碼來源:options.py

示例4: miInfo

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def miInfo(text, parent=False, level = 'msg'):
    if level == 'wrn':
        title = "Japanese - Warning"
    elif level == 'not':
        title = "Japanese - Notice"
    elif level == 'err':
        title = "Japanese - Error"
    else:
        title = "Japanese"
    if parent is False:
        parent = aqt.mw.app.activeWindow() or aqt.mw
    icon = QIcon(join(addon_path, 'icons', 'mia.png'))
    mb = QMessageBox(parent)
    mb.setText(text)
    mb.setWindowIcon(icon)
    mb.setWindowTitle(title)
    b = mb.addButton(QMessageBox.Ok)
    b.setDefault(True)

    return mb.exec_() 
開發者ID:mass-immersion-approach,項目名稱:MIA-Japanese-Add-on,代碼行數:22,代碼來源:miutils.py

示例5: saveConfiguration

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def saveConfiguration(self):
        sc, wc = self.saveSentenceWordConfig()
        ffs, la = self.saveNumberConfigOptions()
        ac, gc = self.saveAudioGraphsConfig()
        colors = self.saveHANOK()
        addmia, bo, autocss, ds, goh, gohb, kc, poc = self.saveBinaryOptions()
        newConf = {"ActiveFields" : self.saveActiveFields(), "Individual:Kana;DictForm;Pitch;Audio;Graphs" : wc, "Group:Kana;DictForm;Pitch;Audio;Graphs": sc,
         "FuriganaFontSize" : ffs, "LookAhead" : la, "Profiles" : self.saveProfilesConfig(),
         "AudioFields" : ac, "PitchGraphFields" :  gc, "ColorsHANOK" : colors, "AddMIAJapaneseTemplate": addmia, "BufferedOutput" :  bo,
         "AutoCssJsGeneration" : autocss, "DisplayShapes" : ds, "GraphOnHover" : goh, "GraphOnHoverBack" : gohb, "KatakanaConversion" : kc, "PlayAudioOnClick" : poc,
         "HistoricalConversion" : self.saveHistoricalConversion()

         }
        if self.addMIANoteTypeOnApply:
            self.MIAModel.addModels() 
        self.mw.addonManager.writeConfig(__name__, newConf)
        self.CSSJSHandler.injectWrapperElements()
        self.hide() 
開發者ID:mass-immersion-approach,項目名稱:MIA-Japanese-Add-on,代碼行數:20,代碼來源:gui.py

示例6: setup_options_menu

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def setup_options_menu():
    # add options submenu to Tools menu
    action = QAction(app_icon, "WordQuery...", mw)
    action.triggered.connect(show_options)
    mw.form.menuTools.addAction(action)
    global have_setup
    have_setup = True


# def start_here():
#     # config.read()
#     if not have_setup:
#         setup_options_menu()
#         customize_addcards()
#         setup_browser_menu()
#         setup_context_menu()
#     # wquery.start_services()


# addHook("profileLoaded", start_here) 
開發者ID:finalion,項目名稱:WordQuery,代碼行數:22,代碼來源:prepare.py

示例7: getSortedByInterval

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def getSortedByInterval(decks, limit, pinned, sortOrder):
    if not "-1" in decks:
        deckQ = "(%s)" % ",".join(decks)
    else:
        deckQ = ""
    if deckQ:
        res = mw.col.db.all("select notes.id, flds, tags, did, cards.nid, notes.mid FROM cards left join notes on cards.nid = notes.id where did in %s and reps > 0 group by cards.nid order by ivl %s limit %s" % (
            deckQ, sortOrder, limit))
    else:
        res = mw.col.db.all("select notes.id, flds, tags, did, cards.nid, notes.mid FROM cards left join notes on cards.nid = notes.id where reps > 0 group by cards.nid order by ivl %s limit %s" % (
        sortOrder, limit))
    rList = []
    for r in res:
        if not str(r[0]) in pinned:
           #. rList.append((r[1], r[2], r[3], r[0], 1, r[5]))
           rList.append(IndexNote((r[0], r[1], r[2], r[3], r[1], -1, r[4], "")))
    return rList 
開發者ID:fonol,項目名稱:anki-search-inside-add-card,代碼行數:19,代碼來源:stats.py

示例8: __init__

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def __init__(self, mw, note):

        QDialog.__init__(self, None, Qt.Window)
        mw.setupDialogGC(self)

        self.mw         = mw
        self.form       = aqt.forms.editcurrent.Ui_Dialog()

        self.form.setupUi(self)
        self.form.buttonBox.button(QDialogButtonBox.Close).setShortcut(QKeySequence("Ctrl+Return"))
        self.editor     = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)

        self.setWindowTitle(_("Edit Note"))
        self.setMinimumHeight(400)
        self.setMinimumWidth(500)
        self.resize(500, 850)
        self.editor.setNote(note, focusTo=0)
        addHook("reset", self.onReset)
        self.mw.requireReset()
        self.show()
        self.mw.progress.timer(100, lambda: self.editor.web.setFocus(), False) 
開發者ID:fonol,項目名稱:anki-search-inside-add-card,代碼行數:23,代碼來源:editor.py

示例9: _generate_jquery_scripts

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def _generate_jquery_scripts():
    """
    This generates a js function for each deck's row based on did
    I am guessing that only one function is needed, but I couldn't figure out how to do it
    Somehow the render function needs to keep a reference to the outer context this.id
    I don't know js or jquery well enough to do that.
    If you know, please let me know.
    """
    tip_script = "    $(function(){"
    template = """
    $('tr#%(id)s a').miniTip({
        content: 'Loading...', offset: 1, delay: 500, maxW: '500px',
		render: function(tt) {
        $('#miniTip_c').html(py_deck_inf.deck_information_for(%(id)s) );}});
        """
    for did in mw.col.decks.allIds():
        tip_script += (template % dict(id=did))
    tip_script += """
        });
        """
    return tip_script 
開發者ID:glutanimate,項目名稱:anki-addons-misc,代碼行數:23,代碼來源:overview_deck_tooltip.py

示例10: build_html

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def build_html(self):

        self.add_row("Name:", self.deck["name"])
        self.add_row("Options", self.col.decks.confForDid(self.did)["name"])

        (card_count, note_count) = mw.col.db.first("""
select count(id), count(distinct nid) from cards
where did in %s """ % self.deck_limit)
        self.add_row("Total notes:", note_count)
        self.add_row("Total cards:", card_count)

        suspended_count = mw.col.db.scalar("""
select count(id)from cards
where queue = -1 and did in %s """ % self.deck_limit)
        self.add_row("Suspended:", suspended_count)
        self.add_row("Did:", self.did)
        self.add_row("Today:", self.todayStats())

        #todo
        """
        Due tomorrow,next etc
        If you studied every day:	6.1 minutes/day
Average answer time:	17.5s (3 cards/minute)
        """ 
開發者ID:glutanimate,項目名稱:anki-addons-misc,代碼行數:26,代碼來源:overview_deck_tooltip.py

示例11: show_models

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def show_models(self):
        '''
        show choose note type window
        '''
        edit = QPushButton(
            anki.lang._("Manage"), clicked=lambda: aqt.models.Models(mw, self))
        ret = StudyDeck(
            mw,
            names=lambda: sorted(mw.col.models.allNames()),
            accept=anki.lang._("Choose"),
            title=anki.lang._("Choose Note Type"),
            help="_notes",
            parent=self,
            buttons=[edit],
            cancel=True,
            geomKey="selectModel")
        if ret.name:
            model = mw.col.models.byName(ret.name)
            self.models_button.setText(
                u'%s [%s]' % (_('CHOOSE_NOTE_TYPES'), ret.name))
            return model 
開發者ID:sth2018,項目名稱:FastWordQuery,代碼行數:23,代碼來源:options.py

示例12: show_options

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def show_options(browser=None, model_id=-1, callback=None, *args, **kwargs):
    '''open options window'''
    parent = mw if browser is None else browser
    config.read()
    opt_dialog = OptionsDialog(parent, u'Options', model_id)
    opt_dialog.activateWindow()
    opt_dialog.raise_()
    result = opt_dialog.exec_()
    opt_dialog.destroy()
    if result == QDialog.Accepted:
        if isinstance(callback, types.FunctionType):
            callback(*args, **kwargs)
    elif result == 1001:
        show_fm_dialog(parent)
    elif result == 1002:
        show_dm_dialog(parent) 
開發者ID:sth2018,項目名稱:FastWordQuery,代碼行數:18,代碼來源:common.py

示例13: show_options

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def show_options(browser = None, model_id = -1, callback = None, *args, **kwargs):
    '''open options window'''
    parent = mw if browser is None else browser
    config.read()
    opt_dialog = OptionsDialog(parent, u'Options', model_id)
    opt_dialog.activateWindow()
    opt_dialog.raise_()
    result = opt_dialog.exec_()
    opt_dialog.destroy()
    if result == QDialog.Accepted:
        if isinstance(callback, types.FunctionType):
            callback(*args, **kwargs)
    elif result == 1001:
        show_fm_dialog(parent)
    elif result == 1002:
        show_dm_dialog(parent) 
開發者ID:sth2018,項目名稱:FastWordQuery,代碼行數:18,代碼來源:common.py

示例14: miInfo

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def miInfo(text, parent=False, level = 'msg', day = True):
    if level == 'wrn':
        title = "Dictionary Warning"
    elif level == 'not':
        title = "Dictionary Notice"
    elif level == 'err':
        title = "Dictionary Error"
    else:
        title = "Dictionary"
    if parent is False:
        parent = aqt.mw.app.activeWindow() or aqt.mw
    icon = QIcon(join(addon_path, 'icons', 'mia.png'))
    mb = QMessageBox(parent)
    if not day:
        mb.setStyleSheet(" QMessageBox {background-color: #272828;}")
    mb.setText(text)
    mb.setWindowIcon(icon)
    mb.setWindowTitle(title)
    b = mb.addButton(QMessageBox.Ok)
    b.setFixedSize(100, 30)
    b.setDefault(True)

    return mb.exec_() 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:25,代碼來源:miutils.py

示例15: renameFields

# 需要導入模塊: import aqt [as 別名]
# 或者: from aqt import mw [as 別名]
def renameFields(self):
        """Check for modified names and rename fields accordingly"""
        modified = False
        model = mw.col.models.byName(OLC_MODEL)
        flds = model['flds']
        for key, fnedit in self.fndict:
            if not fnedit.isModified():
                continue
            name = fnedit.text()
            oldname = config["synced"]['flds'][key]
            if name is None or not name.strip() or name == oldname:
                continue
            idx = mw.col.models.fieldNames(model).index(oldname)
            fld = flds[idx]
            if fld:
                # rename note type fields
                mw.col.models.renameField(model, fld, name)
                # update olcloze field-id <-> field-name assignment
                config["synced"]['flds'][key] = name
                modified = True
        return modified 
開發者ID:glutanimate,項目名稱:cloze-overlapper,代碼行數:23,代碼來源:options_global.py


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