Unlucky-Life / ankimon

Ankimon is a Anki Addon to Gamify your learning experience
Other
35 stars 4 forks source link

Error on startup: unexpected type 'float' #129

Closed borgorworgor closed 1 month ago

borgorworgor commented 1 month ago

Hello, after downloading the resources, I received this error on restarting Anki:

Preparing to run...
Qt warning: QGuiApplication::setDesktopFileName: the specified desktop file name ends with .desktop. For compatibility reasons, the .desktop suffix will be removed. Please specify a desktop file name without .desktop suffix 
2024-05-30 18:13:06,646:INFO:aqt.mediasrv: Serving on http://127.0.0.1:34181
Qt warning: Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/bin/qtwebengine_dictionaries' 
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/aqt/addons.py", line 247, in loadAddons
    __import__(addon.dir_name)
  File "/home/user/.local/share/Anki2/addons21/1908235722/__init__.py", line 6687, in <module>
    starter_window.display_starter_pokemon()
  File "/home/user/.local/share/Anki2/addons21/1908235722/__init__.py", line 6099, in display_starter_pokemon
    starter_label = self.pokemon_display_starter(water_start, fire_start, grass_start)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/Anki2/addons21/1908235722/__init__.py", line 6231, in pokemon_display_starter
    custom_font = load_custom_font(28)
                  ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/Anki2/addons21/1908235722/__init__.py", line 4035, in load_custom_font
    custom_font.setPointSize(font_size)  # Adjust the font size as needed
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: setPointSize(self, a0: int): argument 1 has unexpected type 'float'

Qt warning: QPaintDevice: Cannot destroy paint device that is being painted 
Segmentation fault (core dumped)

I fixed this error in __init__.py by forcing reading the variable "font_size" as an integer on line 4035, however I am unsure if this could be a permanent fix.

4032    # Register the custom font with its file path
4033    QFontDatabase.addApplicationFont(str(font_path / font_file))
4034    custom_font = QFont(font_name)  # Use the font family name you specified in the font file
4035    custom_font.setPointSize(int(font_size))  # Adjust the font size as needed
4036
4037    return custom_font
Unlucky-Life commented 1 month ago

Hey thanks ! I think that should work :) !

ARelaxedScholar commented 1 month ago

Nice work, I had the same experience and came here to submit my fix. Looks like you beat me to it.

tategotoazarasi commented 1 month ago

Same problem

Unlucky-Life commented 1 month ago

@tategotoazarasi @ARelaxedScholar @borgorworgor I updated the addon file and uploaded here a new .ankiaddon file to install under: https://github.com/Unlucky-Life/ankimon/releases/tag/1.288