Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (44 loc) · 1.49 KB
/
Copy pathmain.py
File metadata and controls
58 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
main.py
-------
Entry point. Wires together: QApplication -> ThemeManager -> PdfRenderer
(GUI thread) -> PdfBridge -> DownloadWorker (background QThread) -> MainWindow.
Run with:
python main.py
"""
from __future__ import annotations
import logging
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication
from config import config, ORG_NAME, APP_NAME, APP_DISPLAY_NAME, icon_path
from pdf_builder import PdfRenderer, PdfBridge
from downloader import DownloadWorker
from ui.theme import ThemeManager
from ui.main_window import MainWindow
def main():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
QApplication.setOrganizationName(ORG_NAME)
QApplication.setApplicationName(APP_NAME)
QApplication.setApplicationDisplayName(APP_DISPLAY_NAME)
if hasattr(Qt, "AA_DontCreateNativeWidgetSiblings"):
QApplication.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings, True)
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(icon_path()))
theme = ThemeManager(app)
theme.set_mode(config.theme_mode)
# PdfRenderer wraps QtWebEngine and MUST live on the GUI thread.
renderer = PdfRenderer()
bridge = PdfBridge(renderer)
worker = DownloadWorker(bridge)
window = MainWindow(worker, theme)
window.show()
exit_code = app.exec()
sys.exit(exit_code)
if __name__ == "__main__":
main()