Skip to content

Commit 8122437

Browse files
author
Agnibho Mondal
committed
Upgrade to PyQt5
1 parent 717bb15 commit 8122437

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

extras.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import subprocess
2525
import os
26-
from PyQt4 import QtGui, QtCore
26+
from PyQt5 import QtWidgets, QtCore
2727
from const import *
2828

2929
def x_settings():
@@ -42,7 +42,7 @@ def x_lib():
4242

4343
def x_save(w, symp, diff):
4444
''' Save data to a file '''
45-
fname=QtGui.QFileDialog.getSaveFileName(w, "Save File", "~", "HTML files('*.html')")
45+
fname=QtWidgets.QFileDialog.getSaveFileName(w, "Save File", "~", "HTML files('*.html')")
4646
if(not fname.endswith(".html")):
4747
fname=fname+".html"
4848
with open(fname, "w") as f:
@@ -70,7 +70,7 @@ def x_logfile():
7070
subprocess.Popen(["xdg-open", LOG_FILE])
7171

7272

73-
class SettingsDialog(QtGui.QDialog):
73+
class SettingsDialog(QtWidgets.QDialog):
7474
'''
7575
Provides a dialog box to configure application settings with a
7676
graphical user interface.
@@ -85,39 +85,39 @@ def __init__(self, conf):
8585

8686
def initUI(self):
8787
''' Initiate the user interface '''
88-
self.lpLabel=QtGui.QLabel("Libary Path:")
89-
self.lpEdit=QtGui.QLineEdit(self.conf.get("library_path"))
90-
self.lpBrowse=QtGui.QPushButton("Browse")
88+
self.lpLabel=QtWidgets.QLabel("Libary Path:")
89+
self.lpEdit=QtWidgets.QLineEdit(self.conf.get("library_path"))
90+
self.lpBrowse=QtWidgets.QPushButton("Browse")
9191
self.lpBrowse.clicked.connect(self.lpUpdate)
92-
self.cpLabel=QtGui.QLabel("Custom Path:")
93-
self.cpEdit=QtGui.QLineEdit(self.conf.get("custom_path"))
94-
self.cpBrowse=QtGui.QPushButton("Browse")
92+
self.cpLabel=QtWidgets.QLabel("Custom Path:")
93+
self.cpEdit=QtWidgets.QLineEdit(self.conf.get("custom_path"))
94+
self.cpBrowse=QtWidgets.QPushButton("Browse")
9595
self.cpBrowse.clicked.connect(self.cpUpdate)
96-
self.mpLabel=QtGui.QLabel("Module Path:")
97-
self.mpEdit=QtGui.QLineEdit(self.conf.get("module_path"))
98-
self.mpBrowse=QtGui.QPushButton("Browse")
96+
self.mpLabel=QtWidgets.QLabel("Module Path:")
97+
self.mpEdit=QtWidgets.QLineEdit(self.conf.get("module_path"))
98+
self.mpBrowse=QtWidgets.QPushButton("Browse")
9999
self.mpBrowse.clicked.connect(self.mpUpdate)
100-
self.splash=QtGui.QCheckBox("Show Splash Screen")
100+
self.splash=QtWidgets.QCheckBox("Show Splash Screen")
101101
if(self.conf.get("splash_screen")=="yes"):
102102
self.splash.setChecked(True)
103-
self.clean=QtGui.QCheckBox("Clean Log on Exit")
103+
self.clean=QtWidgets.QCheckBox("Clean Log on Exit")
104104
if(self.conf.get("clean_log")=="yes"):
105105
self.clean.setChecked(True)
106-
self.status=QtGui.QCheckBox("Show Status Message")
106+
self.status=QtWidgets.QCheckBox("Show Status Message")
107107
if(self.conf.get("status_message")=="on"):
108108
self.status.setChecked(True)
109-
self.ok=QtGui.QPushButton("Ok")
109+
self.ok=QtWidgets.QPushButton("Ok")
110110
self.ok.clicked.connect(self.save)
111-
self.cancel=QtGui.QPushButton("Cancel")
111+
self.cancel=QtWidgets.QPushButton("Cancel")
112112
self.cancel.clicked.connect(self.close)
113-
self.default=QtGui.QPushButton("Default")
113+
self.default=QtWidgets.QPushButton("Default")
114114
self.default.clicked.connect(self.reset)
115115

116-
ctrl=QtGui.QHBoxLayout()
116+
ctrl=QtWidgets.QHBoxLayout()
117117
ctrl.addWidget(self.ok)
118118
ctrl.addWidget(self.cancel)
119119
ctrl.addWidget(self.default)
120-
layout=QtGui.QGridLayout(self)
120+
layout=QtWidgets.QGridLayout(self)
121121
layout.addWidget(self.lpLabel, 0, 0)
122122
layout.addWidget(self.lpEdit, 0, 1)
123123
layout.addWidget(self.lpBrowse, 0, 2)
@@ -148,7 +148,7 @@ def mpUpdate(self):
148148

149149
def getFolder(self):
150150
''' Returns the selected directory '''
151-
dn=QtGui.QFileDialog.getExistingDirectory()
151+
dn=QtWidgets.QFileDialog.getExistingDirectory()
152152
if(dn.startswith(QtCore.QDir.currentPath())):
153153
dn="."+dn[len(QtCore.QDir.currentPath()):]+"/"
154154
else:
@@ -172,7 +172,7 @@ def save(self):
172172
self.conf.set("status_message", "on")
173173
else:
174174
self.conf.set("status_message", "off")
175-
QtGui.QMessageBox.information(self, "Restart required", "Some settings takes effect only after restarting DDStorm")
175+
QtWidgets.QMessageBox.information(self, "Restart required", "Some settings takes effect only after restarting DDStorm")
176176
self.close()
177177
self.conf.write()
178178

gui.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import time
2828
import subprocess
2929

30-
from PyQt4 import QtGui, QtCore
30+
from PyQt5 import QtWidgets, QtGui, QtCore
3131

3232
from panes import Symptoms, Differentials
3333
from ddstorm import DDStorm
@@ -37,7 +37,7 @@
3737

3838
conf=False
3939

40-
class Content(QtGui.QWidget):
40+
class Content(QtWidgets.QWidget):
4141
'''
4242
Provides the main content widget. Contains the sysmptoms and
4343
the diagnosis panes. Also creates the DDStorm object and performs
@@ -56,7 +56,7 @@ def __init__(self):
5656

5757
# Show warning if any error happened during data compilation
5858
if(not self.dd.compiler.is_clean()):
59-
ret=QtGui.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
59+
ret=QtWidgets.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
6060
if(ret==1):
6161
x_logfile()
6262

@@ -67,29 +67,29 @@ def initUI(self):
6767

6868
global conf
6969

70-
grid=QtGui.QGridLayout()
70+
grid=QtWidgets.QGridLayout()
7171
self.setLayout(grid)
7272

7373
self.symp=Symptoms(self.dd.symptoms())
74-
self.symp.setFrameShape(QtGui.QFrame.StyledPanel)
74+
self.symp.setFrameShape(QtWidgets.QFrame.StyledPanel)
7575
self.symp.changed.connect(self.update)
7676

7777
self.diff=Differentials()
78-
self.diff.setFrameShape(QtGui.QFrame.StyledPanel)
78+
self.diff.setFrameShape(QtWidgets.QFrame.StyledPanel)
7979

8080
grid.addWidget(self.symp, 0, 0)
8181
grid.addWidget(self.diff, 0, 1)
8282
grid.setColumnStretch(0, 1)
8383
grid.setColumnStretch(1, 1)
84-
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
84+
QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("Cleanlooks"))
8585

8686
def update(self, data):
8787
''' Update the inteface with refreshed information '''
8888
self.diff.update(self.dd.dd(data))
8989
self.change.emit()
9090

9191

92-
class Window(QtGui.QMainWindow):
92+
class Window(QtWidgets.QMainWindow):
9393
'''
9494
Provides main application window. Acts as a container for the
9595
content widget. Also contains the menubar and the status bar.
@@ -115,7 +115,7 @@ def initUI(self):
115115
menuEdit=menu.addMenu("&Edit")
116116
menuEdit.addAction("&Add").triggered.connect(self.con.symp.addItem)
117117
menuEdit.addAction("&Browse Symptoms").triggered.connect(self.con.symp.browseSymptoms)
118-
rmAction=QtGui.QAction("&Remove", self)
118+
rmAction=QtWidgets.QAction("&Remove", self)
119119
rmAction.setShortcut("Delete")
120120
rmAction.triggered.connect(self.con.symp.remove)
121121
menuEdit.addAction(rmAction)
@@ -153,12 +153,12 @@ def settings(self):
153153

154154
def about(self):
155155
''' Show information about this application '''
156-
QtGui.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
156+
QtWidgets.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
157157

158158

159159
def main():
160160
''' Start the main application interface '''
161-
app=QtGui.QApplication(sys.argv)
161+
app=QtWidgets.QApplication(sys.argv)
162162

163163
# Initiate the global configuration
164164
global conf
@@ -174,7 +174,7 @@ def main():
174174
else:
175175
ss=False
176176
if(ss):
177-
splash=QtGui.QSplashScreen(QtGui.QPixmap("icons/splash.png"))
177+
splash=QtWidgets.QSplashScreen(QtWidgets.QPixmap("icons/splash.png"))
178178
splash.show()
179179
time.sleep(0.1)
180180
app.processEvents()

panes.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
2323
'''
2424

25-
from PyQt4 import QtGui, QtCore
25+
from PyQt5 import QtWidgets, QtCore
2626

27-
class Symptoms(QtGui.QFrame):
27+
class Symptoms(QtWidgets.QFrame):
2828
''' Provides the widget for symptoms input '''
2929

3030
# List to hold the symptoms
@@ -49,43 +49,43 @@ def __init__(self, auto):
4949

5050
def initUI(self):
5151
''' Initiate the user interface '''
52-
self.label=QtGui.QLabel("Symptoms")
52+
self.label=QtWidgets.QLabel("Symptoms")
5353
self.label.setStyleSheet("font-size:18px")
5454

55-
self.listWidget=QtGui.QListWidget(self)
55+
self.listWidget=QtWidgets.QListWidget(self)
5656
self.listWidget.setStyleSheet("font-size:14px")
5757
self.listWidget.setSelectionMode(4)
5858

59-
self.rm=QtGui.QPushButton("Remove")
59+
self.rm=QtWidgets.QPushButton("Remove")
6060
self.rm.clicked.connect(self.remove)
6161

62-
self.cl=QtGui.QPushButton("Clear All")
62+
self.cl=QtWidgets.QPushButton("Clear All")
6363
self.cl.clicked.connect(self.removeAll)
6464

65-
self.browse=QtGui.QPushButton("Browse Symptoms")
65+
self.browse=QtWidgets.QPushButton("Browse Symptoms")
6666
self.browse.clicked.connect(self.browseSymptoms)
6767

68-
self.add=QtGui.QPushButton("Add")
68+
self.add=QtWidgets.QPushButton("Add")
6969
self.add.clicked.connect(self.addItem)
7070

71-
self.new=QtGui.QLineEdit(self)
71+
self.new=QtWidgets.QLineEdit(self)
7272
self.new.returnPressed.connect(self.addItem)
73-
self.completer=QtGui.QCompleter(self.auto)
73+
self.completer=QtWidgets.QCompleter(self.auto)
7474
self.completer.setCaseSensitivity(0)
7575
self.completer.setCompletionMode(2)
7676
self.new.setCompleter(self.completer)
7777

7878
self.browser=SymptomBrowser(self.auto)
7979
self.browser.added.connect(self.addItem)
8080

81-
hboxt=QtGui.QHBoxLayout()
81+
hboxt=QtWidgets.QHBoxLayout()
8282
hboxt.addWidget(self.new)
8383
hboxt.addWidget(self.add)
84-
hboxb=QtGui.QHBoxLayout()
84+
hboxb=QtWidgets.QHBoxLayout()
8585
hboxb.addWidget(self.rm)
8686
hboxb.addWidget(self.cl)
8787
hboxb.addWidget(self.browse)
88-
vbox=QtGui.QVBoxLayout()
88+
vbox=QtWidgets.QVBoxLayout()
8989
vbox.addWidget(self.label)
9090
vbox.addLayout(hboxt)
9191
vbox.addWidget(self.listWidget)
@@ -98,14 +98,14 @@ def addItem(self, text=""):
9898
text=self.new.text()
9999
if(len(text)>0):
100100
if(text in self.sympList):
101-
QtGui.QMessageBox.information(self, "Duplicate Symptom", "'"+text+"' has already been added to the symptom list.")
101+
QtWidgets.QMessageBox.information(self, "Duplicate Symptom", "'"+text+"' has already been added to the symptom list.")
102102
elif(text in self.auto):
103-
QtGui.QListWidgetItem(text, self.listWidget)
103+
QtWidgets.QListWidgetItem(text, self.listWidget)
104104
self.sympList.append(text)
105105
self.new.clear()
106106
self.changed.emit(list(self.sympList))
107107
else:
108-
QtGui.QMessageBox.warning(self, "Symptom Unvailable", "'"+text+"' is not available in the current Library.")
108+
QtWidgets.QMessageBox.warning(self, "Symptom Unvailable", "'"+text+"' is not available in the current Library.")
109109

110110
def remove(self, all=False):
111111
''' Remove selected symptoms '''
@@ -130,7 +130,7 @@ def getList(self):
130130
return self.sympList
131131

132132

133-
class SymptomBrowser(QtGui.QDialog):
133+
class SymptomBrowser(QtWidgets.QDialog):
134134
'''
135135
Provides a dialog with a list of symptoms for alternative user
136136
input.
@@ -146,12 +146,12 @@ def __init__(self, items):
146146

147147
def initUI(self):
148148
''' Initiate the dialog interface '''
149-
self.search=QtGui.QLineEdit()
149+
self.search=QtWidgets.QLineEdit()
150150
self.search.textChanged.connect(self.refresh)
151-
self.listItems=QtGui.QListWidget()
151+
self.listItems=QtWidgets.QListWidget()
152152
self.listItems.activated.connect(self.sendUp)
153153

154-
layout=QtGui.QVBoxLayout(self)
154+
layout=QtWidgets.QVBoxLayout(self)
155155
layout.addWidget(self.search)
156156
layout.addWidget(self.listItems)
157157

@@ -174,7 +174,7 @@ def sendUp(self):
174174
self.close()
175175

176176

177-
class Differentials(QtGui.QFrame):
177+
class Differentials(QtWidgets.QFrame):
178178
''' Provides the widget for differential diagnosis output '''
179179
data=[]
180180

@@ -185,12 +185,12 @@ def __init__(self):
185185

186186
def initUI(self):
187187
''' Initiate the user interface '''
188-
self.label=QtGui.QLabel("Differential Diagnosis")
188+
self.label=QtWidgets.QLabel("Differential Diagnosis")
189189
self.label.setStyleSheet("font-size:18px")
190-
self.listWidget=QtGui.QListWidget(self)
190+
self.listWidget=QtWidgets.QListWidget(self)
191191
self.listWidget.setStyleSheet("font-size:14px")
192192
self.listWidget.setSelectionMode(0)
193-
box=QtGui.QVBoxLayout()
193+
box=QtWidgets.QVBoxLayout()
194194
box.addWidget(self.label)
195195
box.addWidget(self.listWidget)
196196
self.setLayout(box)
@@ -207,7 +207,7 @@ def update(self, data):
207207
self.listWidget.clear()
208208
if(self.data):
209209
for d in self.data:
210-
QtGui.QListWidgetItem(d, self.listWidget)
210+
QtWidgets.QListWidgetItem(d, self.listWidget)
211211

212212
def getList(self):
213213
''' Return a list of current differential diagnosis '''

0 commit comments

Comments
 (0)