-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapplication.py
52 lines (41 loc) · 1.35 KB
/
application.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
import sys
import logging
from PyQt5.QtWidgets import QApplication, QPlainTextEdit, QDockWidget
from PyQt5.QtCore import Qt
from controller import MainWindow
from models import DataModel
from settings import appMarkup
class Application(QApplication):
def __init__(self, *args):
super().__init__(*args)
self.controller = MainWindow(self)
# self.initLogging()
self.model = DataModel(self, "QPSQL")
# self.model.openConnection('hospital', 'abel')
self.markup = appMarkup
@property
def view(self):
return self.controller.centralWidget()
@property
def markup(self):
return self.view.markup
@markup.setter
def markup(self, value):
self.view.markup = value
def handleUpdate(self):
self.view.handleUpdate()
self.model.notifyWatchers()
def initLogging(self):
self.logger = QDockWidget('Logging console', self.controller)
self.logger.setAllowedAreas(Qt.BottomDockWidgetArea)
self.logger.setWidget(QPlainTextEdit())
self.controller.addDockWidget(Qt.BottomDockWidgetArea, self.logger)
# logging.basicConfig(filename='log.txt', level=logging.INFO)
logging.basicConfig(level=logging.INFO)
logging.info('Application started')
sys.excepthook = self.exception_handler
def log(self, text):
self.logger.widget().appendPlainText(text)
def exception_handler(self, type, value, tb=None):
self.log(str(value))
# logging.exception(str(value))