Beginnger in the whole Python/Anki thing. Learning more about coding for fun and I have set up a debugging environment with pycharm and an anki profile with the bazelfixes and it seems to start anki up fine. I went through the hooks and the toolbar hook worked but it is not exactly what I was going for because it adds unto the toolbar not the menu. I want to add a new dropdown into the actual main menu next to tools, help, etc. connect them to functions I have made. Kind of like this
I have looked at others and sometimes they work partially but its like a fragmented puzzle so I want to figure out the first basic step. How do I, within this code on pycharm append an extra dropdown item on the menu bar. Is there a hook I am missing (not the init toolbar one)? I have also looked at the aqt mw thing but I am kind of confused how it works so I am not sure if that is a better approach to read up on? The whole class>def variable> mw.append type of structure I have been seeing in others code is a little confusing for me. Any help or advice is greatly appreciated!
Also here is the bazelfixes code I have been using if it helps show what I have been doing.
try:
import bazelfixes
No special way. If you put just my example code in __init__.py and run it as an add-on it should work. The problem is likely caused by something else in your code. Why are you creating QApplication here? I believe this will cause problems as Anki already creates an application and it’s incorrect to create any additional ones.
I ran it by itself and got “Process finished with exit code -1073740791 (0xC0000409)”
Then I started it from the terminal and got the error "QWidget: Must construct a QApplication before a QWidget
"
Running the add-on from PyCharm won’t work. You need to copy/link the add-on’s folder to Anki’s add-ons’ folder and run Anki instead. Please see A Basic Add-on - Writing Anki Add-ons
I set it up this way and I think I see the cause now “on_action” is not defined I will try to add something else and see if it runs
Edit: I have it now! instead of on_action I put it under function and used self.undo like on the edit button and when I ran it see a extra menubar with the options available!
import aqt
from aqt import mw
from aqt.qt import *