-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (52 loc) · 1.98 KB
/
main.py
File metadata and controls
58 lines (52 loc) · 1.98 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
"""
Provenance Program Entry Point
- Launches the PyQt5 GUI for image upload, annotation, cataloging, and analytics.
- All data is stored in provenance.db (SQLite).
"""
import sys
import subprocess
from PyQt5.QtWidgets import QApplication, QMessageBox
REQUIRED_PACKAGES = [
'PyQt5',
'pyqtgraph',
# Add other dependencies as needed
]
def ensure_dependencies():
missing = []
for pkg in REQUIRED_PACKAGES:
try:
__import__(pkg if pkg != 'PyQt5' else 'PyQt5.QtWidgets')
except ImportError:
missing.append(pkg)
if missing:
app = QApplication(sys.argv)
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setWindowTitle('Missing Dependencies')
msg.setText(f"The following packages are required but not installed: {', '.join(missing)}\n\nInstall them now?")
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
if msg.exec_() == QMessageBox.Yes:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', *missing])
QMessageBox.information(None, 'Dependencies Installed', 'Dependencies installed. Please restart the application.')
sys.exit(0)
else:
sys.exit(1)
ensure_dependencies()
from gui.app import ProvenanceApp
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--reset-settings', action='store_true', help='Reset QSettings for this app')
args = parser.parse_args()
if args.reset_settings:
from PyQt5.QtCore import QSettings
QSettings("JUREKA", "ProvenanceToyShop").clear()
print("[INFO] QSettings cleared. Relaunch without --reset-settings.")
sys.exit(0)
print("[DEBUG] About to create ProvenanceApp...")
app = ProvenanceApp(sys.argv)
print("[DEBUG] Created ProvenanceApp.")
print("[DEBUG] About to call setup_ui()...")
app.setup_ui()
print("[DEBUG] About to call app.exec_()...")
sys.exit(app.exec_())