-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
58 lines (49 loc) · 1.8 KB
/
app.py
File metadata and controls
58 lines (49 loc) · 1.8 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
# app.py
import sys
from PySide6.QtWidgets import QApplication, QMessageBox, QFileDialog
from core.db import init_db
from core.paths import APP_DIR
from core.style import apply_style
from main_window import MainWindow
import core.config_manager as config_manager
import core.paths as paths
# Fix for PyInstaller noconsole mode where stdout/stderr are None
class NullWriter:
def write(self, data): pass
def flush(self): pass
if sys.stdout is None: sys.stdout = NullWriter()
if sys.stderr is None: sys.stderr = NullWriter()
def main():
app = QApplication(sys.argv)
app.setApplicationName("RES – Stack Assembly Dashboard")
apply_style(app)
# 1. Check/Set Data Path
if not config_manager.get_data_path():
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setWindowTitle("Setup")
msg.setText("Please select a folder to store data (videos, database).")
msg.exec()
path = QFileDialog.getExistingDirectory(None, "Select Data Folder")
if path:
config_manager.set_data_path(path)
else:
# Default to AppData if cancelled
default_path = config_manager.get_app_data_dir() / "data"
reply = QMessageBox.question(None, "Default Path",
f"No path selected. Use default location?\n{default_path}",
QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.Yes:
config_manager.set_data_path(default_path)
else:
sys.exit(0)
# 2. Ensure directories
paths.get_videos_dir().mkdir(parents=True, exist_ok=True)
paths.get_snap_dir().mkdir(parents=True, exist_ok=True)
# 3. Init DB
init_db()
win = MainWindow()
win.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()