# Addon "expand collapse deck" updated with LLMs and tested working for 23.10/2.1.x, finally

**URL:** <https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553>\
**Category:** Add-ons\
**Created:** [December 24, 2024, 5:22pm UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553 "2024-12-24T17:22:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [December 24, 2024, 5:22pm UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/1 "2024-12-24T17:22:38Z")

</div>

I first asked it from nothing,  
and the LLMs didn’t work.

then i dnld the addon and ask LLMs to update it. worked.

but from old addon’s page, someone say not always working, i cant sure.

sigh, claude 3.5 sonnet not yet able to replace human.

~~failed, indeep.sigh~~

finally working, for 2.1. x

```auto
from aqt import mw
from aqt.utils import showInfo
from aqt.qt import *

def toggleDecksCollapsed(collapsed):
    """Toggles all decks to be either expanded or collapsed"""
    # get all the decks and set them collapsed/expanded
    decks = mw.col.decks.all_names_and_ids()
    for deck in decks:
        conf = mw.col.decks.get(deck.id)
        conf['collapsed'] = collapsed
        mw.col.decks.save(conf)
        
    # Refresh the browser to show the changes
    mw.deckBrowser.refresh()
        
def expandAllDecks():
    toggleDecksCollapsed(False)
    showInfo("All decks expanded")
    
def collapseAllDecks():
    toggleDecksCollapsed(True)
    showInfo("All decks collapsed")

# Create menu items using modern Qt syntax
expandAction = QAction("Expand All Decks", mw)
expandAction.triggered.connect(expandAllDecks)
mw.form.menuTools.addAction(expandAction)

collapseAction = QAction("Collapse All Decks", mw)
collapseAction.triggered.connect(collapseAllDecks)
mw.form.menuTools.addAction(collapseAction)

```

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [December 25, 2024, 5:04am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/4 "2024-12-25T05:04:44Z")

</div>

wow, i am using 23.10,  
i only now know that in the browser, the Rt click menu already contains the collapse function.

yet in the deck view, there is no such function by default,  
so this updated addon helps.

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [December 25, 2024, 5:25am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/5 "2024-12-25T05:25:37Z")

</div>

the collapse/collapse children that build in the anki seems dont “collapse every level” but only several.

i use LLMs to wrote a 2nd one for the browser.  
post if someone interested.

---

<div class="post-metadata">

**Author:** ![Shigeyuki](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/shigeyuki/32/23878_2.png) [@Shigeyuki](https://forums.ankiweb.net/u/Shigeyuki)\
**Post date:** [December 25, 2024, 7:29am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/6 "2024-12-25T07:29:03Z")

</div>

Wow, very nice! 👍  
Why don’t you upload your add-on to AnkiWeb and release it?

Some ideas:

[1] showInfo requires the user to press the “OK” button, so I think it would be better to remove it in the same way as the original add-on or use tooltip instead:

```python
from aqt.utils import tooltip

def expandAllDecks():
    toggleDecksCollapsed(False)
    tooltip("All decks expanded")

```

[2] Maybe putting the actions in one menu would make them easier to manage:

```python
addonMenu = QMenu("Expand and Collapse Decks", mw)
mw.form.menuTools.addMenu(addonMenu)

expandAction = QAction("Expand All Decks", mw)
expandAction.triggered.connect(expandAllDecks)
addonMenu.addAction(expandAction)

collapseAction = QAction("Collapse All Decks", mw)
collapseAction.triggered.connect(collapseAllDecks)
addonMenu.addAction(collapseAction)

```

[3] This add-on is for the deck options, so it might be good to access it from the deck options (gear icon). This code will add the addon menu to the options:

```python
from aqt import gui_hooks

def addDeckBrowserOption(menu:QMenu, deck_id):
    menu.addMenu(myAddonMenu)

gui_hooks.deck_browser_will_show_options_menu.append(addDeckBrowserOption)

```

Edit: It may be useful to customize this to expand or cooapse all the child decks of the selected deck only, like the browser.

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [December 25, 2024, 9:41am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/7 "2024-12-25T09:41:04Z")

</div>

post here, i need only 5mins.

upload? then edit a new page? put on github and make a readme?  
no thank you. may be others could share the work load.

thanks

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [December 25, 2024, 9:49am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/8 "2024-12-25T09:49:15Z")

</div>

may be someone could pick them up,  
i myself only need the “collapse all” function so i can click into the one i want.  
i got some OCD obsessive compulsive disorder so i will crazy if it’s collapsed somewhere and expanded somewhere.  
thanks

---

<div class="post-metadata">

**Author:** ![Shigeyuki](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/shigeyuki/32/23878_2.png) [@Shigeyuki](https://forums.ankiweb.net/u/Shigeyuki)\
**Post date:** [January 11, 2025, 6:05am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/9 "2025-01-11T06:05:22Z")

</div>

I customized it and uploaded it to Ankiweb.  
add-on: [📂Expand Collapse Deck (Customized by Shigeඞ)](https://ankiweb.net/shared/info/1920182966)

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [January 11, 2025, 6:30am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/10 "2025-01-11T06:30:07Z")

</div>

if LLMs cant write one from scratch but could help update old ones,  
that’s still relieved a whole lot of workload.

AI helps human, cant replace yet.

~~self censored~~  
~~you still need to stab a knife or pull a trigger of a gun to kill someone else.  
although somebodies enjoy using bare hands 😬~~

---

<div class="post-metadata">

**Author:** ![Shigeyuki](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/shigeyuki/32/23878_2.png) [@Shigeyuki](https://forums.ankiweb.net/u/Shigeyuki)\
**Post date:** [January 11, 2025, 7:12am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/11 "2025-01-11T07:12:38Z")

</div>

LLM is very useful for making simple tasks more efficient, so it may be interesting if there is a manual for developing Anki add-ons with LLM.

---

<div class="post-metadata">

**Author:** ![krstoevan](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@krstoevan](https://forums.ankiweb.net/u/krstoevan)\
**Post date:** [January 11, 2025, 7:34am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/12 "2025-01-11T07:34:04Z")

</div>

isn’t i saw you or ankiking asking for addon ideas?

much addons have been wrote for anki before the LLMs era,  
so be it.

ps: however i have used LLMs to wrote some very small addons that nobody think useful.

i wrote one that in the browser, you select a card and can change the “deck window”'s deck into that card’s deck.

i myself use it very very often but no one interested.

you could search my old post, again i posted right here but not spending several more times to polish it - if others wanna use, they can simply grab it.

of course i appreciate you and others work to polish the all the wonderful addons.

---

<div class="post-metadata">

**Author:** ![Shigeyuki](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/shigeyuki/32/23878_2.png) [@Shigeyuki](https://forums.ankiweb.net/u/Shigeyuki)\
**Post date:** [January 11, 2025, 7:55am UTC](https://forums.ankiweb.net/t/addon-expand-collapse-deck-updated-with-llms-and-tested-working-for-23-10-2-1-x-finally/53553/13 "2025-01-11T07:55:28Z")

</div>

Oh, you seem to be developing some interesting things. The priority of super memo by subdeck looks very good, I am already doing something similar to that in my decks. I will look into it later to see if I can make them add-ons.
