How to use the aqt.mw.connect function in aqt

To help you get started, we’ve selected a few aqt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ospalh / anki-addons / zoom.py View on Github external
try:
        mw.addon_view_menu
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(
            mw.form.menuTools.menuAction(), mw.addon_view_menu)
    mw.zoom_submenu = QMenu(_(u"&Zoom"), mw)
    mw.addon_view_menu.addMenu(mw.zoom_submenu)
    zoom_in_action = QAction(_('Zoom &In'), mw)
    zoom_in_action.setShortcut(QKeySequence("Ctrl++"))
    mw.zoom_submenu.addAction(zoom_in_action)
    mw.connect(zoom_in_action, SIGNAL("triggered()"), zoom_in)
    zoom_out_action = QAction(_('Zoom &Out'), mw)
    zoom_out_action.setShortcut(QKeySequence("Ctrl+-"))
    mw.zoom_submenu.addAction(zoom_out_action)
    mw.connect(zoom_out_action, SIGNAL("triggered()"), zoom_out)
    mw.zoom_submenu.addSeparator()
    reset_zoom_action = QAction(_('&Reset'), mw)
    reset_zoom_action.setShortcut(QKeySequence("Ctrl+0"))
    mw.zoom_submenu.addAction(reset_zoom_action)
    mw.connect(reset_zoom_action, SIGNAL("triggered()"), reset_zoom)
github ospalh / anki-addons / Normalize.py View on Github external
try:
    from anki.hooks import addHook
    from anki.lang import _
    from aqt import mw
    from aqt.utils import askUser
    from PyQt4.QtCore import QCoreApplication, SIGNAL
    from PyQt4.QtGui import QAction, QProgressDialog
except ImportError:
    _ = dummy
else:
    with_anki = True
    nom_a = QAction(mw)
    mw.form.menuTools.addAction(nom_a)
    nom_a.setText(_(u"Normalize media file names"))
    mw.connect(nom_a, SIGNAL("triggered()"),
               lambda: normalize_files(dir_=mw.col.media.dir()))



if __name__ == '__main__':
    try:
        normalize_files(dir_=sys.argv[1], form=sys.argv[2])
    except IndexError:
        try:
            normalize_files(sys.argv[1])
        except IndexError:
            normalize_files()
github krassowski / Anki-TouchScreen / TouchScreen.py View on Github external
ts_menu_color = QAction(_('Set &pen color'), mw)
    ts_menu_width = QAction(_('Set &pen width'), mw)
    ts_menu_about = QAction(_('&About...'), mw)

    ts_toggle_seq = QKeySequence("Ctrl+r")
    ts_menu_switch.setShortcut(ts_toggle_seq)

    mw.ts_menu.addAction(ts_menu_switch)
    mw.ts_menu.addAction(ts_menu_color)
    mw.ts_menu.addAction(ts_menu_width)
    mw.ts_menu.addSeparator()
    mw.ts_menu.addAction(ts_menu_about)

    s = SIGNAL("triggered()")
    mw.connect(ts_menu_switch, s, ts_switch)
    mw.connect(ts_menu_color, s, ts_change_color)
    mw.connect(ts_menu_width, s, ts_change_width)
    mw.connect(ts_menu_about, s, ts_about)
github ospalh / anki-addons / nachschlagen.py View on Github external
kle = QAction(mw)
        kle.setText("Kanji bei Kanji-Lexikon")
        # kle.setShortcut("Ctrl+4")
        mn.addAction(kle)
        mw.connect(kle, SIGNAL("triggered()"), on_lookup_kl_expression)
        kls = QAction(mw)
        kls.setText("Kanjiauswahl bei Kanji-Lexikon")
        mn.addAction(kls)
        mw.connect(kls, SIGNAL("triggered()"), on_lookup_kl_selection)
    # Show these always.
    fae = QAction(mw)
    fae.setText("Ausdruck bei Forvo")
    # fae.setShortcut("Ctrl+4")
    mn.addAction(fae)
    mw.connect(fae, SIGNAL("triggered()"), on_lookup_forvo_expression)
    fas = QAction(mw)
    fas.setText("Auswahl bei Forvo")
    mn.addAction(fas)
    mw.connect(fas, SIGNAL("triggered()"), on_lookup_forvo_selection)
github ospalh / anki-addons / Local CSS and DIY night mode.py View on Github external
if extra_classes_list:
        mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
        mw.form.menuEdit.addSeparator()
        mw.form.menuEdit.addMenu(mw.extra_class_submenu)
        action_group = QActionGroup(mw, exclusive=True)
        no_class_action = action_group.addAction(
            QAction('(none/standard)', mw, checkable=True))
        no_class_action.setChecked(True)
        mw.extra_class_submenu.addAction(no_class_action)
        mw.connect(no_class_action, SIGNAL("triggered()"),
                   lambda: set_extra_class(None))
        for ecd in extra_classes_list:
            nn_class_action = action_group.addAction(
                QAction(ecd['display'], mw, checkable=True))
            mw.extra_class_submenu.addAction(nn_class_action)
            mw.connect(nn_class_action, SIGNAL("triggered()"),
                       lambda ec=ecd['class']: set_extra_class(ec))
github ospalh / anki-addons / more_shortcuts.py View on Github external
"""
    Use “6” and “i” to replay audio.

    Use the “6” key to replay audio, useful for reviewing with the
    right hand on the numeric key pad, and the “i” key, useful when
    reviewing with the left hand on a Dvorak keyboard.
    """
    key = unicode(evt.text())
    if key == "6" or key == 'i':
        self.replayAudio()


Reviewer._keyHandler = wrap(Reviewer._keyHandler, replay_6)
mw.connect(mw.other_deck, SIGNAL("activated()"),
           lambda: mw.moveToState("deckBrowser"))
mw.connect(mw.other_browse, SIGNAL("activated()"), lambda: mw.onBrowse())
github krassowski / Anki-Night-Mode / Night_Mode.py View on Github external
def connect(menu_entry, function):
            mw.connect(menu_entry, s, function)
github tmbb / SyntaxHighlight / code_highlight_addon / code_highlight_addon.py View on Github external
# 1st row:
        grid.addWidget(linenos_label, 0, 0)
        grid.addWidget(linenos_checkbox, 0, 1)
        # there are no more rows yet :)
        
        
        self.setLayout(grid) 
        
        self.setWindowTitle('Syntax Highlighting (options)')    
        self.show()


mw.SyntaxHighlighting_Options = SyntaxHighlighting_Options(mw)

options_action = QAction("Syntax Highlighting (options)", mw)
mw.connect(options_action,
           SIGNAL("triggered()"),
           mw.SyntaxHighlighting_Options.setupUi)
mw.form.menuTools.addAction(options_action)
###############################################################

###############################################################
QSplitter.add_plugin_button_ = add_plugin_button_
QSplitter.add_code_langs_combobox = add_code_langs_combobox

def init_highlighter(ed, *args, **kwargs):
    #  If the addon is being run for the first time, add the preferences
    # to the global configuration
    if not 'syntax_highlighting_conf' in mw.col.conf:
        ed.mw.col.conf['syntax_highlighting_conf'] = default_conf
    
    #  Get the last selected language (or the default language if the user