This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
well-being-diary.py
67 lines (59 loc) · 2.77 KB
/
well-being-diary.py
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
59
60
61
62
63
64
65
66
67
import sqlite3
import sys
import os
import logging
import argparse
import configparser
import PyQt5.Qt
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
import wbd.wbd_global
import wbd.gui.main_window
if __name__ == "__main__":
wbd.wbd_global.db_file_exists_at_application_startup_bl = os.path.isfile(wbd.wbd_global.get_database_filename())
# Application setup..
# ..command line arguments
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument("--testing", "-t", help="Testing - data saved in memory only", action="store_true")
# -for info about "store_true" please search here: https://docs.python.org/3/howto/argparse.html
args = argument_parser.parse_args()
wbd.wbd_global.testing_bool = False
if args.testing:
wbd.wbd_global.testing_bool = True
# ..configuration file
config = configparser.ConfigParser()
config.read("settings.ini")
wbd.wbd_global.background_image_path = config["general"]["background-image-path"]
wbd.wbd_global.diary_text_size_ft = float(config["general"]["diary-text-size"])
# === Creating the main window ===
app = QtWidgets.QApplication(sys.argv)
print("app pid = " + str(app.applicationPid()))
# -"QWidget: Must construct a QApplication before a QWidget"
main_window = wbd.gui.main_window.MainWindow()
# System tray
tray_icon = QtWidgets.QSystemTrayIcon(QtGui.QIcon("icon.png"), app)
tray_menu = QtWidgets.QMenu()
tray_restore_action = QtWidgets.QAction("Restore")
# noinspection PyUnresolvedReferences
tray_restore_action.triggered.connect(main_window.show)
tray_menu.addAction(tray_restore_action)
tray_quit_action = QtWidgets.QAction("Quit")
# noinspection PyUnresolvedReferences
tray_quit_action.triggered.connect(sys.exit)
tray_menu.addAction(tray_quit_action)
tray_icon.setContextMenu(tray_menu)
tray_icon.show()
# Application information
logging.info("===== Starting " + wbd.wbd_global.BWB_APPLICATION_NAME_STR + " - "
+ wbd.wbd_global.BWB_APPLICATION_VERSION_STR + " =====")
logging.info("Python version: " + str(sys.version))
logging.info("SQLite version: " + str(sqlite3.sqlite_version))
logging.info("PySQLite (Python module) version: " + str(sqlite3.version))
logging.info("Qt version: " + str(QtCore.qVersion()))
logging.info("PyQt (Python module) version: " + str(PyQt5.Qt.PYQT_VERSION_STR))
logging.info(wbd.wbd_global.BWB_APPLICATION_NAME_STR + " Application version: " + str(wbd.wbd_global.BWB_APPLICATION_VERSION_STR))
db_conn = wbd.model.DbHelperM.get_db_connection()
logging.info(wbd.wbd_global.BWB_APPLICATION_NAME_STR + " Database schema version: " + str(wbd.model.get_schema_version(db_conn)))
logging.info("=====")
sys.exit(app.exec_())