-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.pyw
48 lines (41 loc) · 1.59 KB
/
main.pyw
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
# Standard library imports
import os
import sys
import time
from shutil import copyfile
# External library imports
import qdarkstyle
import pyqtgraph as pg
from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication
# Custom imports
from apps import barbellcvlog
from utils import database
# Need to scale to screen resolution - this handles 4k scaling
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
# Match pyqtgraph background to QDarkStyle background
pg.setConfigOption('background', '#19232D')
pg.setConfigOptions(antialias=True)
# ALL data is saved to the data directory for now - this needs to exist
if os.path.isdir('./data/') is False:
os.mkdir('./data/')
# Database is in top level of data directory
if os.path.isfile('./data/history.db') is False:
con = database.connect_db(os.path.abspath('./data/history.db'))
database.create_db_tables(con)
con.close()
# Create a backup so we can restore if needed
else:
copyfile(os.path.abspath('./data/history.db'), os.path.abspath('./data/history_backup.db'))
# Logs and videos are saved to subdirectories named with date stamps
if os.path.isdir(f"./data/{time.strftime('%y%m%d')}") is False:
os.mkdir(f"./data/{time.strftime('%y%m%d')}")
if __name__ == "__main__":
log_app = QApplication(sys.argv)
window = barbellcvlog.BarbellCVLogApp()
log_app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
window.show()
sys.exit(log_app.exec_())