Checkpoint of Word refactor

This commit is contained in:
Christopher T. Johnson
2024-03-21 09:42:09 -04:00
parent efec40176f
commit d9fefb99dd
2 changed files with 500 additions and 63 deletions

48
deftest.py Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python3
import os
import sys
from PyQt6.QtCore import QResource
from PyQt6.QtGui import QFontDatabase
from PyQt6.QtSql import QSqlDatabase, QSqlQuery
from PyQt6.QtWidgets import QApplication
from lib import Definition, Word
from lib.sounds import SoundOff
from lib.utils import query_error
def main() -> int:
db = QSqlDatabase()
db = db.addDatabase("QSQLITE")
db.setDatabaseName("test.db")
if not db.open():
raise Exception(db.lastError())
app = QApplication(sys.argv)
#
# Setup resources
#
if not QResource.registerResource(
os.path.join(os.path.dirname(__file__), "ui/resources.rcc"), "/"
):
raise Exception("Unable to register resources.rcc")
QFontDatabase.addApplicationFont(
":/fonts/opendyslexic/OpenDyslexic-Regular.otf"
)
query = QSqlQuery()
if not query.exec(
"CREATE TABLE IF NOT EXISTS words "
"(word_id INTEGER PRIMARY KEY AUTOINCREMENT, word TEXT, definition TEXT)"
):
query_error(query)
word = Word("lady")
snd = SoundOff()
widget = Definition(word) # noqa: F841
widget.pronounce.connect(snd.playSound)
widget.show()
return app.exec()
if __name__ == "__main__":
sys.exit(main())