zacharied / anki-content-injector

Anki add-on to "overlay" HTML/CSS/JS content on cards at review-time
3 stars 2 forks source link

Error when trying to edit a card #4

Closed coder20980 closed 4 years ago

coder20980 commented 4 years ago

I just installed this add-on and when I go to edit a card, I get an error. If I disable the add-on, the error goes away. Here's the info from the error message:

When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site. Debug info: Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1 Platform: Windows 10 Flags: frz=True ao=True sv=1 Add-ons, last update check: 2020-09-01 13:04:22

Caught exception: Traceback (most recent call last): File "aqt\webview.py", line 493, in handler File "aqt\editor.py", line 481, in File "aqt\editor.py", line 364, in _onCardLayout File "aqt\clayout.py", line 66, in init File "<C:\Program Files\Anki\decorator.pyc:decorator-gen-6>", line 2, in setupMainArea File "anki\hooks.py", line 638, in decorator_wrapper File "anki\hooks.py", line 635, in repl File "C:\Users[DELETED]\AppData\Roaming\Anki2\addons21\166455199__init__.py", line 79, in myClayoutMainArea editor.pform.verticalLayout_3.addWidget(checkbox) AttributeError: 'Ui_Form' object has no attribute 'verticalLayout_3'

khonkhortisan commented 4 years ago

Remove _3 to get the window to load. (Toggling the checkbox then throws the error below) Replace editor.redraw() with editor.redraw_everything() to get rid of the second error. (unloads css but not js)

backwards compatibility:

        try:
            editor.redraw()
        except:
            editor.redraw_everything()
        ⋮
        try:
            editor.pform.verticalLayout_3.addWidget(checkbox)
        except:
            editor.pform.verticalLayout.addWidget(checkbox)

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2020-08-31 20:39:51

Caught exception:
Traceback (most recent call last):
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\166455199\__init__.py", line 126, in <lambda>
    checkbox.stateChanged.connect(lambda: self.onEnabledPreviewChecked(checkbox, editor))
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\166455199\__init__.py", line 52, in onEnabledPreviewChecked
    editor.redraw()
AttributeError: 'CardLayout' object has no attribute 'redraw'