How to use the aqt.mw.form 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 / downloadtatoeba / download.py View on Github external
"download_audio",
        lambda self=self: editor_download_editing(self),
        tip=u"Download audio...", text=" ")
    dl_button.setIcon(
        QIcon(os.path.join(icons_dir, 'download_note_audio.png')))


# Either reuse an edit-media sub-menu created by another add-on
# (probably by Y.T., notably the external edit add-on that is in the
# works) or create that menu. When we already have that menu, add a
# separator, otherwise create that menu.
try:
    mw.edit_media_submenu.addSeparator()
except AttributeError:
    mw.edit_media_submenu = QMenu(u"&Media", mw)
    mw.form.menuEdit.addSeparator()
    mw.form.menuEdit.addMenu(mw.edit_media_submenu)


mw.note_download_action = QAction(mw)
mw.note_download_action.setText(u"Note audio")
mw.note_download_action.setIcon(QIcon(os.path.join(icons_dir,
                                                   'download_note_audio.png')))
mw.note_download_action.setToolTip(
    "Download audio for all audio fields of this note.")
mw.connect(mw.note_download_action, SIGNAL("triggered()"), download_for_note)

mw.side_download_action = QAction(mw)
mw.side_download_action.setText(u"Side audio")
mw.side_download_action.setIcon(
    QIcon(os.path.join(icons_dir, 'download_side_audio.png')))
mw.side_download_action.setToolTip(
github ospalh / anki-addons / downloadaudio / download.py View on Github external
dl_button = editor.addButton(dl_icon, 
        "download_audio",
        editor_download_editing, # FIXME: Call saveNow before this
        tip="Download audio…")
    toprightbuts.insert(-1, dl_button)
    return toprightbuts

# Either reuse an edit-media sub-menu created by another add-on
# (probably the mhwave (ex sweep) add-on by Y.T.) or create that
# menu. When we already have that menu, add a separator, otherwise
# create that menu.
try:
    mw.edit_media_submenu.addSeparator()
except AttributeError:
    mw.edit_media_submenu = QMenu("&Media", mw)
    mw.form.menuEdit.addSeparator()
    mw.form.menuEdit.addMenu(mw.edit_media_submenu)


mw.note_download_action = QAction(mw)
mw.note_download_action.setText("Note audio")
mw.note_download_action.setIcon(QIcon(os.path.join(icons_dir,
                                                   'download_note_audio.png')))
mw.note_download_action.setToolTip(
    "Download audio for all audio fields of this note.")
mw.note_download_action.setShortcut(DOWNLOAD_NOTE_SHORTCUT)
mw.note_download_action.triggered.connect(download_for_note)

mw.side_download_action = QAction(mw)
mw.side_download_action.setText("Side audio")
mw.side_download_action.setIcon(
    QIcon(os.path.join(icons_dir, 'download_side_audio.png')))
github brumar / anknotes / anknotes / menu.py View on Github external
def add_menu_items(menu_items, parent=None):
    if not parent: parent = mw.form.menubar
    for title, action in menu_items:
        if title == "SEPARATOR":
            parent.addSeparator()
        elif isinstance(action, list):
            menu = QMenu(_(title), parent)
            parent.insertMenu(mw.form.menuTools.menuAction(), menu)
            add_menu_items(action, menu)
        else:
            checkable = False
            if isinstance(action, dict):
                options = action
                action = options['action']
                if 'checkable' in options:
                    checkable = options['checkable']
            menu_action = QAction(_(title), mw, checkable=checkable)
            parent.addAction(menu_action)
github ospalh / anki-addons / Local CSS and DIY night mode.py View on Github external
def setup_menu():
    u"""
    Add a submenu to the edit menu.

    Add a submenu that lists the available extra classes to the edit
    menu.
    """
    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 tmbb / SyntaxHighlight / code_highlight_addon / code_highlight_addon.py View on Github external
# 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
    # has never chosen any)
    previous_lang = mw.col.conf['syntax_highlighting_conf']['lang']
    ed.codeHighlightLangAlias = LANGUAGES_MAP[previous_lang]
github ospalh / anki-addons / colorful_toolbars / __init__.py View on Github external
def add_to_menus():
    """
    Add a number of items to memus.

    Put the functions of the DASB old-style tool bar links into
    menus. Sync to the file menu, stats to the tools menu, the DASB,
    together with a study-withouts-overview item to a new go
    menu. Also add items to, d'uh, edit stuff to the edit menu.

    """
    # Add sync to the file memu. It was there in Anki 1.
    mw.form.menuCol.insertAction(mw.form.actionImport, sync_action)
    # Make a new top level menu and insert it.
    try:
        mw.addon_view_menu.addSeparator()
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(
            mw.form.menuTools.menuAction(), mw.addon_view_menu)
    mw.addon_view_menu.addAction(show_qt_toolbar_action)
    mw.addon_view_menu.addAction(show_text_toolbar_action)
    mw.addon_view_menu.addAction(show_more_toolbar_action)
    # And another one
    try:
        mw.addon_go_menu.addSeparator()
    except AttributeError:
        mw.addon_go_menu = QMenu(_(u"&Go"), mw)
        mw.form.menubar.insertMenu(