]>
Softwares of Agnibho - ddstorm.git/blob - gui.py
4 This module provides the main graphical user interface for DDStorm
7 Copyright (c) 2015 Agnibho Mondal
10 This file is part of DDStorm.
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.
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.
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/>.
30 from PyQt5
import QtWidgets
, QtGui
, QtCore
32 from panes
import Symptoms
, Differentials
33 from ddstorm
import DDStorm
40 class Content(QtWidgets
.QWidget
):
42 Provides the main content widget. Contains the sysmptoms and
43 the diagnosis panes. Also creates the DDStorm object and performs
47 # Signal to detect when
48 change
=QtCore
.pyqtSignal()
51 ''' Initiate the content widget '''
52 super(Content
, self
).__init
__()
54 # Create DDStorm object with the global configuration
55 self
.dd
=DDStorm(True, conf
)
57 # Show warning if any error happened during data compilation
58 if(not self
.dd
.compiler
.is_clean()):
59 ret
=QtWidgets
.QMessageBox
.warning(self
, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
66 ''' Create the user interface of the widget '''
70 grid
=QtWidgets
.QGridLayout()
73 self
.symp
=Symptoms(self
.dd
.symptoms())
74 self
.symp
.setFrameShape(QtWidgets
.QFrame
.StyledPanel
)
75 self
.symp
.changed
.connect(self
.update
)
77 self
.diff
=Differentials()
78 self
.diff
.setFrameShape(QtWidgets
.QFrame
.StyledPanel
)
80 grid
.addWidget(self
.symp
, 0, 0)
81 grid
.addWidget(self
.diff
, 0, 1)
82 grid
.setColumnStretch(0, 1)
83 grid
.setColumnStretch(1, 1)
84 QtWidgets
.QApplication
.setStyle(QtWidgets
.QStyleFactory
.create("Cleanlooks"))
86 def update(self
, data
):
87 ''' Update the inteface with refreshed information '''
88 self
.diff
.update(self
.dd
.dd(data
))
92 class Window(QtWidgets
.QMainWindow
):
94 Provides main application window. Acts as a container for the
95 content widget. Also contains the menubar and the status bar.
99 ''' Initiate the main window '''
100 super(Window
, self
).__init
__()
104 ''' Create the user interface '''
107 self
.sett
=SettingsDialog(conf
)
108 if(conf
.get("status_message")=="on"):
109 self
.con
.change
.connect(self
.showStatus
)
112 menuFile
=menu
.addMenu("&File")
113 menuFile
.addAction("&Save").triggered
.connect(self
.savefile
)
114 menuFile
.addAction("E&xit").triggered
.connect(self
.close
)
115 menuEdit
=menu
.addMenu("&Edit")
116 menuEdit
.addAction("&Add").triggered
.connect(self
.con
.symp
.addItem
)
117 menuEdit
.addAction("&Browse Symptoms").triggered
.connect(self
.con
.symp
.browseSymptoms
)
118 rmAction
=QtWidgets
.QAction("&Remove", self
)
119 rmAction
.setShortcut("Delete")
120 rmAction
.triggered
.connect(self
.con
.symp
.remove
)
121 menuEdit
.addAction(rmAction
)
122 menuEdit
.addAction("&Clear All").triggered
.connect(self
.con
.symp
.removeAll
)
123 menuTool
=menu
.addMenu("&Tools")
124 menuTool
.addAction("&Library").triggered
.connect(x_lib
)
125 menuTool
.addAction("&Settings").triggered
.connect(self
.settings
)
126 menuTool
.addAction("&View Log").triggered
.connect(x_logfile
)
127 menuHelp
=menu
.addMenu("&Help")
128 menuHelp
.addAction("&Help").triggered
.connect(x_help
)
129 menuHelp
.addAction("&About").triggered
.connect(self
.about
)
131 self
.setCentralWidget(self
.con
)
132 self
.status
=self
.statusBar()
133 self
.setGeometry(200, 200, 600, 400)
134 self
.setWindowTitle("D/D Storm")
135 self
.setWindowIcon(QtGui
.QIcon("icons/icon.png"))
137 self
.con
.symp
.new
.setFocus()
139 def showStatus(self
):
140 ''' Show status message '''
141 if(self
.con
.symp
.getList() and self
.con
.diff
.getList()):
142 self
.status
.showMessage(str(len(self
.con
.diff
.getList()))+" differential diagnosis for "+str(len(self
.con
.symp
.getList()))+" symptom(s).")
144 self
.status
.showMessage("")
147 ''' Save data to a file '''
148 x_save(self
, self
.con
.symp
.getList(), self
.con
.diff
.getList())
151 ''' Open the settings dialog '''
155 ''' Show information about this application '''
156 QtWidgets
.QMessageBox
.about(self
, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
160 ''' Start the main application interface '''
161 app
=QtWidgets
.QApplication(sys
.argv
)
163 # Initiate the global configuration
168 if(conf
.get("clean_log")=="yes"):
169 open(LOG_FILE
, "w").close()
172 if(conf
.get("splash_screen")=="yes"):
177 splash
=QtWidgets
.QSplashScreen(QtWidgets
.QPixmap("icons/splash.png"))
181 splash
.showMessage("Loading...")
189 sys
.exit(app
.exec_())
191 if(__name__
=="__main__"):