|
1 | 1 | #! /usr/bin/python3
|
2 | 2 |
|
3 |
| -# DDStorm |
4 |
| -# ------- |
5 |
| -# Copyright (c) 2015 Agnibho Mondal |
6 |
| -# All rights reserved |
| 3 | +''' |
| 4 | +Start the application |
| 5 | +''' |
| 6 | +''' |
| 7 | +Copyright (c) 2015 Agnibho Mondal |
| 8 | +All rights reserved |
7 | 9 |
|
8 |
| -# This file is part of DDStorm. |
| 10 | +This file is part of DDStorm. |
9 | 11 |
|
10 |
| -# DDStorm is free software: you can redistribute it and/or modify |
11 |
| -# it under the terms of the GNU General Public License as published by |
12 |
| -# the Free Software Foundation, either version 3 of the License, or |
13 |
| -# (at your option) any later version. |
| 12 | +DDStorm is free software: you can redistribute it and/or modify |
| 13 | +it under the terms of the GNU General Public License as published by |
| 14 | +the Free Software Foundation, either version 3 of the License, or |
| 15 | +(at your option) any later version. |
14 | 16 |
|
15 |
| -# DDStorm is distributed in the hope that it will be useful, |
16 |
| -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
| -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
| -# GNU General Public License for more details. |
| 17 | +DDStorm is distributed in the hope that it will be useful, |
| 18 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +GNU General Public License for more details. |
19 | 21 |
|
20 |
| -# You should have received a copy of the GNU General Public License |
21 |
| -# along with DDStorm. If not, see <http://www.gnu.org/licenses/>. |
| 22 | +You should have received a copy of the GNU General Public License |
| 23 | +along with DDStorm. If not, see <http://www.gnu.org/licenses/>. |
| 24 | +''' |
22 | 25 |
|
23 |
| -import sys, time, subprocess |
24 |
| -from PyQt4 import QtGui, QtCore |
25 |
| -from _symptoms import Symptoms |
26 |
| -from _differentials import Differentials |
27 |
| -from ddstorm import DDStorm |
28 |
| -from conf import Conf |
29 |
| -from _extras import * |
30 |
| -from const import * |
31 |
| - |
32 |
| -conf=False |
33 |
| - |
34 |
| -class Content(QtGui.QWidget): |
35 |
| - change=QtCore.pyqtSignal() |
36 |
| - def __init__(self): |
37 |
| - super(Content, self).__init__() |
38 |
| - self.dd=DDStorm(True,conf) |
39 |
| - if(not self.dd.compiler.clean): |
40 |
| - ret=QtGui.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log") |
41 |
| - if(ret==1): |
42 |
| - x_logfile() |
43 |
| - self.initUI() |
44 |
| - def initUI(self): |
45 |
| - global conf |
46 |
| - |
47 |
| - grid=QtGui.QGridLayout() |
48 |
| - self.setLayout(grid) |
49 |
| - |
50 |
| - self.symp=Symptoms(self.dd.symptoms()) |
51 |
| - self.symp.setFrameShape(QtGui.QFrame.StyledPanel) |
52 |
| - self.symp.changed.connect(self.update) |
53 |
| - |
54 |
| - self.diff=Differentials() |
55 |
| - self.diff.setFrameShape(QtGui.QFrame.StyledPanel) |
56 |
| - |
57 |
| - grid.addWidget(self.symp, 0, 0) |
58 |
| - grid.addWidget(self.diff, 0, 1) |
59 |
| - grid.setColumnStretch(0, 1) |
60 |
| - grid.setColumnStretch(1, 1) |
61 |
| - QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks")) |
62 |
| - def update(self, data): |
63 |
| - self.diff.update(self.dd.dd(data)) |
64 |
| - self.change.emit() |
65 |
| - |
66 |
| -class Window(QtGui.QMainWindow): |
67 |
| - def __init__(self): |
68 |
| - super(Window, self).__init__() |
69 |
| - self.initUI() |
70 |
| - def initUI(self): |
71 |
| - global conf |
72 |
| - self.con=Content() |
73 |
| - self.sett=SettingsDialog(conf) |
74 |
| - if(conf.get("status_message")=="on"): |
75 |
| - self.con.change.connect(self.showStatus) |
76 |
| - |
77 |
| - menu=self.menuBar() |
78 |
| - menuFile=menu.addMenu("&File") |
79 |
| - menuFile.addAction("&Save").triggered.connect(self.savefile) |
80 |
| - menuFile.addAction("E&xit").triggered.connect(self.close) |
81 |
| - menuEdit=menu.addMenu("&Edit") |
82 |
| - menuEdit.addAction("&Add").triggered.connect(self.con.symp.addItem) |
83 |
| - menuEdit.addAction("&Browse Symptoms").triggered.connect(self.con.symp.browseSymptoms) |
84 |
| - rmAction=QtGui.QAction("&Remove", self) |
85 |
| - rmAction.setShortcut("Delete") |
86 |
| - rmAction.triggered.connect(self.con.symp.remove) |
87 |
| - menuEdit.addAction(rmAction) |
88 |
| - menuEdit.addAction("&Clear All").triggered.connect(self.con.symp.removeAll) |
89 |
| - menuTool=menu.addMenu("&Tools") |
90 |
| - menuTool.addAction("&Library").triggered.connect(x_lib) |
91 |
| - menuTool.addAction("&Settings").triggered.connect(self.settings) |
92 |
| - menuTool.addAction("&View Log").triggered.connect(x_logfile) |
93 |
| - menuHelp=menu.addMenu("&Help") |
94 |
| - menuHelp.addAction("&Help").triggered.connect(x_help) |
95 |
| - menuHelp.addAction("&About").triggered.connect(self.about) |
96 |
| - |
97 |
| - self.setCentralWidget(self.con) |
98 |
| - self.status=self.statusBar() |
99 |
| - self.setGeometry(200, 200, 600, 400) |
100 |
| - self.setWindowTitle("D/D Storm") |
101 |
| - self.setWindowIcon(QtGui.QIcon("icons/icon.png")) |
102 |
| - self.showMaximized() |
103 |
| - self.con.symp.new.setFocus() |
104 |
| - def showStatus(self): |
105 |
| - if(self.con.symp.getList() and self.con.diff.getList()): |
106 |
| - self.status.showMessage(str(len(self.con.diff.getList()))+" differential diagnosis for "+str(len(self.con.symp.getList()))+" symptom(s).") |
107 |
| - else: |
108 |
| - self.status.showMessage("") |
109 |
| - def savefile(self): |
110 |
| - x_save(self, self.con.symp.getList(), self.con.diff.getList()) |
111 |
| - def settings(self): |
112 |
| - self.sett.exec_() |
113 |
| - def about(self): |
114 |
| - QtGui.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine") |
115 |
| - |
116 |
| -def main(): |
117 |
| - app=QtGui.QApplication(sys.argv) |
118 |
| - |
119 |
| - global conf |
120 |
| - conf=Conf() |
121 |
| - if(conf.get("clean_log")=="yes"): |
122 |
| - open(LOG_FILE, "w").close() |
123 |
| - if(conf.get("splash_screen")=="yes"): |
124 |
| - ss=True |
125 |
| - else: |
126 |
| - ss=False |
127 |
| - if(ss): |
128 |
| - splash=QtGui.QSplashScreen(QtGui.QPixmap("icons/splash.png")) |
129 |
| - splash.show() |
130 |
| - time.sleep(0.1) |
131 |
| - app.processEvents() |
132 |
| - splash.showMessage("Loading...") |
133 |
| - |
134 |
| - w=Window() |
135 |
| - if(ss): |
136 |
| - splash.finish(w) |
137 |
| - |
138 |
| - sys.exit(app.exec_()) |
| 26 | +import gui |
139 | 27 |
|
140 | 28 | if(__name__=="__main__"):
|
141 |
| - main() |
| 29 | + gui.main() |
0 commit comments