How to preview changes when developing addons?

Hello!

I’ve been developing my own AnkiAddon, and I’ve been having a lot of fun and the Anki devs have done a very good job but one thing that I’ve found a bit frustrating is the fact that every time I want to preview changes that my addon have made I need to restart Anki. Is there a better way of previewing my changes that doesn’t require me to restart Anki every single time? My slow laptop means that it would take a couple minutes every time, and sometimes I want to preview after just a handful of lines of code… :frowning: I’ve checked the documentation and can’t find anything about it.

2 Likes

There’s no known reliable solution for this. I found some libraries to do hot reloading like jurigged after some googling, but never tried any yet. Would be interesting to see if that works in Anki.

4 Likes

There’s also from importlib import reload, but you’d need to restructure your code so that any hook registrations, etc get done a second time.

3 Likes

Oh okay, I’ll give them a shot: thank you so much!

Let’s us know if using this import improved your work.

1 Like

There are 2 add-ons for reloading add-ons. But I haven’t tried them yet so I don’t know if they work properly. (my add-ons use a lot of gui_hooks so they probably won’t work.)

addon: Reload addon
addon: Addon Reloader (for addon developers) Fixed

In my case I simply restart Anki using an add-on I developed myself, but OP says that it takes a long time to start up so I think this won’t work.

addon: AnkiRestart V2 - Quick Anki Rebooter
addon: AnkiRestart (old ver)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.