]>
Softwares of Agnibho - ddstorm.git/blob - _extras.py
d15e627c763d6587ef358b3bc0ec9d78aebe1222
3 # Copyright (c) 2015 Agnibho Mondal
6 # This file is part of DDStorm.
8 # DDStorm is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # DDStorm is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
22 from PyQt4
import QtGui
, QtCore
26 subprocess
.Popen(["xdg-open", CONF_FILE
])
29 if(os
.path
.isfile(CONF_FILE
)):
30 with
open(CONF_FILE
) as conf
:
32 if(line
.startswith("library_path=")):
33 library_path
=line
[13:-1]
34 if(os
.path
.isdir(library_path
)):
35 subprocess
.Popen(["xdg-open", library_path
])
37 def x_save(w
, symp
, diff
):
38 fname
=QtGui
.QFileDialog
.getSaveFileName(w
, "Save File", "~", "HTML files('*.html')")
39 if(not fname
.endswith(".html")):
41 with
open(fname
, "w") as f
:
42 print("<!DOCTYPE html><html><head><title>Differential Diagnosis</title></head>", file=f
)
43 print("<body><h1>Differential Diagnosis</h1>", file=f
)
44 print("<table style='width:100%'>", file=f
)
45 print("<tr><th>Symptoms</th><th>Diffrential Diagnosis</th></tr>", file=f
)
46 print("<tr><td style='vertical-align:text-top'><ol>", file=f
)
48 print("<li>"+s
+"</li>", file=f
)
49 print("</ol></td><td style='vertical-align:text-top'><ol>", file=f
)
51 print("<li>"+d
+"</li>", file=f
)
52 print("</ol></td></tr></table></body></html>", file=f
)
55 if(os
.path
.isfile(HELP_FILE
)):
56 subprocess
.Popen(["xdg-open", HELP_FILE
])
58 subprocess
.Popen(["xdg-open", "http://www.agnibho.com"])
61 subprocess
.Popen(["xdg-open", LOG_FILE
])
63 class SettingsDialog(QtGui
.QDialog
):
64 def __init__(self
, conf
):
65 super(SettingsDialog
, self
).__init
__()
66 self
.setWindowTitle("Settings")
70 self
.lpLabel
=QtGui
.QLabel("Libary Path:")
71 self
.lpEdit
=QtGui
.QLineEdit(self
.conf
.get("library_path"))
72 self
.lpBrowse
=QtGui
.QPushButton("Browse")
73 self
.lpBrowse
.clicked
.connect(self
.lpUpdate
)
74 self
.mpLabel
=QtGui
.QLabel("Module Path:")
75 self
.mpEdit
=QtGui
.QLineEdit(self
.conf
.get("module_path"))
76 self
.mpBrowse
=QtGui
.QPushButton("Browse")
77 self
.mpBrowse
.clicked
.connect(self
.mpUpdate
)
78 self
.splash
=QtGui
.QCheckBox("Show Splash Screen")
79 if(self
.conf
.get("splash_screen")=="yes"):
80 self
.splash
.setChecked(True)
81 self
.clean
=QtGui
.QCheckBox("Clean Log on Exit")
82 if(self
.conf
.get("clean_log")=="yes"):
83 self
.clean
.setChecked(True)
84 self
.status
=QtGui
.QCheckBox("Show Status Message")
85 if(self
.conf
.get("status_message")=="on"):
86 self
.status
.setChecked(True)
87 self
.ok
=QtGui
.QPushButton("Ok")
88 self
.ok
.clicked
.connect(self
.save
)
89 self
.cancel
=QtGui
.QPushButton("Cancel")
90 self
.cancel
.clicked
.connect(self
.close
)
91 self
.default
=QtGui
.QPushButton("Default")
92 self
.default
.clicked
.connect(self
.reset
)
94 ctrl
=QtGui
.QHBoxLayout()
95 ctrl
.addWidget(self
.ok
)
96 ctrl
.addWidget(self
.cancel
)
97 ctrl
.addWidget(self
.default
)
98 layout
=QtGui
.QGridLayout(self
)
99 layout
.addWidget(self
.lpLabel
, 0, 0)
100 layout
.addWidget(self
.lpEdit
, 0, 1)
101 layout
.addWidget(self
.lpBrowse
, 0, 2)
102 layout
.addWidget(self
.mpLabel
, 1, 0)
103 layout
.addWidget(self
.mpEdit
, 1, 1)
104 layout
.addWidget(self
.mpBrowse
, 1, 2)
105 layout
.addWidget(self
.splash
, 2, 0)
106 layout
.addWidget(self
.clean
, 3, 0)
107 layout
.addWidget(self
.status
, 4, 0)
108 layout
.addLayout(ctrl
, 5, 1)
110 self
.cancel
.setFocus()
113 self
.lpEdit
.setText(self
.getFolder())
115 self
.cpEdit
.setText(self
.getFolder())
117 self
.mpEdit
.setText(self
.getFolder())
120 dn
=QtGui
.QFileDialog
.getExistingDirectory()
121 if(dn
.startswith(QtCore
.QDir
.currentPath())):
122 dn
="."+dn
[len(QtCore
.QDir
.currentPath()):]+"/"
128 self
.conf
.set("library_path", self
.lpEdit
.text())
129 self
.conf
.set("class_path", self
.cpEdit
.text())
130 self
.conf
.set("module_path", self
.mpEdit
.text())
131 if(self
.splash
.isChecked()):
132 self
.conf
.set("splash_screen", "yes")
134 self
.conf
.set("splash_screen", "no")
135 if(self
.clean
.isChecked()):
136 self
.conf
.set("clean_log", "yes")
138 self
.conf
.set("clean_log", "no")
139 if(self
.status
.isChecked()):
140 self
.conf
.set("status_message", "on")
142 self
.conf
.set("status_message", "off")
143 QtGui
.QMessageBox
.information(self
, "Restart required", "Some settings takes effect only after restarting DDStorm")
149 self
.lpEdit
.setText(self
.conf
.get("library_path"))
150 self
.cpEdit
.setText(self
.conf
.get("class_path"))
151 self
.mpEdit
.setText(self
.conf
.get("module_path"))
152 if(self
.conf
.get("splash_screen")=="yes"):
153 self
.splash
.setChecked(True)
155 self
.splash
.setChecked(False)
156 if(self
.conf
.get("clean_log")=="yes"):
157 self
.clean
.setChecked(True)
159 self
.clean
.setChecked(False)
160 if(self
.conf
.get("status_message")=="on"):
161 self
.status
.setChecked(True)
163 self
.status
.setChecked(False)