Checkpoint of Word refactor
This commit is contained in:
48
deftest.py
Normal file
48
deftest.py
Normal 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())
|
||||
Reference in New Issue
Block a user