Coder Social home page Coder Social logo

Qt6 anki problem about ankirandomfont HOT 16 CLOSED

austinhasten avatar austinhasten commented on June 26, 2024 1
Qt6 anki problem

from ankirandomfont.

Comments (16)

yaoberh avatar yaoberh commented on June 26, 2024

Changing QFontDatabase().families() to QFontDatabase::families() as per qt6 changes returns this error:

When loading '⁨Randomize Fonts⁩':
⁨Traceback (most recent call last):
  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 212
    allInstalledFonts = QFontDatabase::families()
                                     ^
SyntaxError: invalid syntax

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

It looks like it's no longer necessary to instantiate a QFontDatabase object as of Qt6:
https://doc.qt.io/archives/qt-6.0/qfontdatabase-obsolete.html

Try QFontDatabase.families()

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024

That seems to have solved that line, but now I'm getting an error in the next one:

When loading '⁨Randomize Fonts⁩':
⁨Traceback (most recent call last):
  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 213, in <module>
    defaultFont = QFontDatabase().systemFont(QFontDatabase.GeneralFont).family()
TypeError: QFontDatabase(QFontDatabase): not enough arguments

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

Looks like we'll also need to remove the parens on that same line. So:

QFontDatabase.systemFont(QFontDatabase.GeneralFont).family()

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024
  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 215, in <module>
    refreshConfig()
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 144, in refreshConfig
    for font in QFontDatabase.families(wsValue):
TypeError: families(writingSystem: QFontDatabase.WritingSystem = QFontDatabase.Any): argument 1 has unexpected type 'int'

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

Looks like WritingSystems used to be their own special class but now they're just python built-in enums. I don't have Anki Qt6 installed so I can't test myself, but I think we would need to update the line to be:

for font in QFontDatabase.WritingSystem[wsName];

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024

Getting this error now :(

  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 215, in <module>
    refreshConfig()
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 144, in refreshConfig
    for font in QFontDatabase.WritingSystem[wsName]:
TypeError: 'WritingSystem' object is not iterable

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

Oops, I think it might actually be

for font in QFontDatabase.families(QFontDatabase.WritingSystem[wsName]):

Thanks for testing this out and troubleshooting with me.

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024

Error's jumping to another area now haha

⁨Traceback (most recent call last):
  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 213, in <module>
    defaultFont = QFontDatabase.systemFont.family()
AttributeError: 'builtin_function_or_method' object has no attribute 'family'

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

I think we just need parens after systemFont on that line.

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024
  File "/home/yaoberh/pyenv/lib/python3.10/site-packages/aqt/addons.py", line 239, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/1603486068/__init__.py", line 213, in <module>
    defaultFont = QFontDatabase.systemFont().family
TypeError: systemFont(QFontDatabase.SystemFont): not enough arguments

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

I guess we need QFontDatabase.GeneralFont in the parenthesis after systemFont.

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024

Yep! Anki starts with no errors now. Although it still throws this error in preview and Cards:
image
Peek 2021-12-13 21-43

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

That one has me a little stumped so I'll grab Anki qt6 and do some testing of my own

from ankirandomfont.

AustinHasten avatar AustinHasten commented on June 26, 2024

init.zip

Not sure how this differs than what you have but this one is working for me.

from ankirandomfont.

yaoberh avatar yaoberh commented on June 26, 2024

Working! 👯

from ankirandomfont.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.