I’ve asked this many times: in the card browser, under deck “lv1,” you see cards from “lv1,” “/lv1/foldera,” and “/lv1/folderb.” To focus on “foldera,” you must switch to the main window, scroll, and click through. Am I missing an easier way?
I use my own “Switch Main Window Deck” (SMWD) addon (shared before): select a card in “foldera,” hit menu > SMWD, and it’s set. Adding notes (right away now) or browsing “foldera” (need to add this to the addon) becomes simple. Why isn’t this workflow standard?
I’ve raised this before and don’t want to seem like I’m pushing something. I just wonder if there’s a better solution I’ve overlooked. Thanks!
Why not use a search query instead? If the deck is lv1/foldera, search for “deck:lv1::foldera” and you’ll see the cards only in lv1/foldera (or notes, depending upon the toggle).
If you’re adamant on not using an existing feature, I can’t help you there. The search bar is there for exactly that purpose. You can filter by tags after writing this search query. I do have over 100 decks as you say, and this is exactly how I filter for cards/notes.
I still don’t see what you’re trying to do that’s not solved with the search query.
i further modified my “Switch Main Window Deck” addon, then now in browser,
when you highlight a card, then Rt click 's context menu or top menu bar’s command will elicite a popup window, now you can set the Main Window’s Deck to this card’s deck, or delete some text so become this deck’s parent/sibling decks.; c3.7t added that if no such existing deck, it will ask you to CREATE.
after MainWindow’s deck is changed, one can click on “browse” to go into that deck or study.
It could be cultural difference, i found this much better.
ps I used to use free demo of cursor, last month it only provide service to paid user so i paid it… once.
it’s going to be expire so i tried it out again, not to waste the quota. this modification is performed by cursor+c3.7t+agent mode.
Are you trying to get to the current deck from some other deck currently shown in Browse? Like you selected a deck, opened Browse and then selected a second deck and now you want to go to that deck in the Browse window. This can be achieved with “deck:current”
Are you trying to get to some particular deck from the deck currently shown in Browse? This can be achieved with “deck:(your deck name here, full path)”
Like @Anon_0000 pointed out, the same feature is available in the sidebar. You can also collapse the sidebar decks the same way you would on the main window and you can search within the sidebar itself (beats having to use the main search box for selecting a deck)
in MainWindow you are in deckA, you click browse,
so you are now in browser, you are in deckA,
you click in the sidebar and go to deckB.
however, the MainWindow is kept on deckA.
if you add a new card NOW or do many things, they apply to deckA, not deckB.
that’s the weird issue.
my addon v1 let me Switch MainWindow’s Deck to the current deck in browser
v1+ let me go to some parent decks or create new.
could go siblings if you can type into.
Have you considered making this add-on public? If not, I think I’ll create an add-on with this functionality (I might take a bit of time to do this, depending upon my motivation to get this done, so keep that in mind). Instead of adding the action in the Tools menu, I think it would be better to add it as an option in the context menu when you right-click on a card or a deck (context menu is the menu that shows up on right-clicking something). If it is in notes view, I would rather not have that option available, as I have several cards which are in different decks.
I must say, earlier I wasn’t able to understand exactly what you want. Now, I see the functionality of what you suggested.
this is my code for SMWD (switch main window deck), which do so and also for switching decks in the card browser. but it’s not smooth as sometimes in some situations, one still have to close the browser and re-open the browser to switch. – see the code.
import textwrap
from aqt import mw
from aqt.utils import showInfo, tooltip, getText, askUser
from aqt.qt import *
def change_deck(browser):
selected_cards = browser.selected_cards()
if not selected_cards:
tooltip("No cards selected!")
return
card_id = selected_cards[0]
card = mw.col.getCard(card_id)
deck_id = card.did
deck_name = mw.col.decks.get(deck_id)['name'] # Get the name of the deck
# Show dialog to allow editing the deck path
new_deck_name, ok = getText("Edit deck path:", title="Switch to Deck", default=deck_name)
if not ok or not new_deck_name:
return
# Check if the deck exists
deck = mw.col.decks.byName(new_deck_name)
if not deck:
create = askUser(f"Deck '{new_deck_name}' doesn't exist. Create it?")
if not create:
return
# Create the deck
deck_id = mw.col.decks.id(new_deck_name)
else:
deck_id = deck['id']
# Change the current deck in the main window
mw.col.decks.select(deck_id)
mw.reset() # Reset the main window to reflect changes
# Wrap the deck name to 40 characters per line
deck_name_wrapped = textwrap.fill(new_deck_name, 40)
# Show the deck name in a message box instead of a tooltip
showInfo(f"Deck changed to:\n{deck_name_wrapped}")
def setup_menus(browser):
# Create a new menu item, "Switch Deck"
action = QAction("Switch to Card's Deck", browser)
# Connect the menu item to our function
action.triggered.connect(lambda: change_deck(browser))
# Add the new menu item to the "Edit" menu
browser.form.menuEdit.addAction(action)
def on_context_menu(browser, menu):
selected_cards = browser.selected_cards()
if not selected_cards:
return
action = QAction("Switch to Card's Deck", browser)
action.triggered.connect(lambda: change_deck(browser))
menu.addAction(action)
# Add a menu item to the main window toolbar in "MyMenu"
def create_menu_action():
# Check if MyMenu exists under Tools, if not create it
tools_menu = mw.form.menuTools
my_menu = None
# Look for existing MyMenu in Tools
for action in tools_menu.actions():
if action.text() == "MyMenu":
my_menu = action.menu()
break
# Create MyMenu if it doesn't exist
if my_menu is None:
my_menu = QMenu("MyMenu", mw)
tools_menu.addMenu(my_menu)
# Add our action to MyMenu
action = QAction("Switch to Card's Deck", mw)
action.triggered.connect(lambda: switch_from_main())
my_menu.addAction(action)
# Function to handle switch deck from main window
def switch_from_main():
# Get current deck as we don't try to access the browser directly
current_deck_id = mw.col.decks.selected()
current_deck_name = mw.col.decks.name(current_deck_id)
# Show dialog to allow editing the deck path
new_deck_name, ok = getText("Edit deck path:", title="Switch to Deck", default=current_deck_name)
if not ok or not new_deck_name:
return
# Check if the deck exists
deck = mw.col.decks.byName(new_deck_name)
if not deck:
create = askUser(f"Deck '{new_deck_name}' doesn't exist. Create it?")
if not create:
return
# Create the deck
deck_id = mw.col.decks.id(new_deck_name)
else:
deck_id = deck['id']
# Change the current deck in the main window
mw.col.decks.select(deck_id)
mw.reset() # Reset the main window to reflect changes
# Wrap the deck name to 40 characters per line
deck_name_wrapped = textwrap.fill(new_deck_name, 40)
# Show the deck name in a message box instead of a tooltip
showInfo(f"Deck changed to:\n{deck_name_wrapped}")
# Add the setup function to the browser setup hooks
from anki.hooks import addHook
addHook("browser.setupMenus", setup_menus)
addHook("browser.onContextMenu", on_context_menu)
# Add our menu to the main window
addHook("profileLoaded", create_menu_action)
the above is init.py
here is meta.json:
{“disabled”: false, “mod”: 0, “conflicts”: , “max_point_version”: 0, “min_point_version”: 0, “branch_index”: 0, “update_enabled”: true}
i am a vibe coder, i dont know how it work.
i will be more free to discuss it in june, thx.
at that time i can ask the LLMs to help