]> Softwares of Agnibho - ddstorm.git/commitdiff
Upgrade to PyQt5
authorAgnibho Mondal <mail@agnibho.com>
Wed, 23 Dec 2015 13:33:05 +0000 (19:03 +0530)
committerAgnibho Mondal <mail@agnibho.com>
Wed, 23 Dec 2015 13:33:05 +0000 (19:03 +0530)
extras.py
gui.py
panes.py

index 8021012a8e77e7b6bd6517593685ab55cfe839d1..c08735dea20689cf73182f9495b3471afaced5e3 100644 (file)
--- a/extras.py
+++ b/extras.py
@@ -23,7 +23,7 @@ along with DDStorm.  If not, see <http://www.gnu.org/licenses/>.
 
 import subprocess
 import os
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtCore
 from const import *
 
 def x_settings():
@@ -42,7 +42,7 @@ def x_lib():
 
 def x_save(w, symp, diff):
     ''' Save data to a file '''
-    fname=QtGui.QFileDialog.getSaveFileName(w, "Save File", "~", "HTML files('*.html')")
+    fname=QtWidgets.QFileDialog.getSaveFileName(w, "Save File", "~", "HTML files('*.html')")
     if(not fname.endswith(".html")):
         fname=fname+".html"
     with open(fname, "w") as f:
@@ -70,7 +70,7 @@ def x_logfile():
     subprocess.Popen(["xdg-open", LOG_FILE])
 
 
-class SettingsDialog(QtGui.QDialog):
+class SettingsDialog(QtWidgets.QDialog):
     '''
     Provides a dialog box to configure application settings with a
     graphical user interface.
@@ -85,39 +85,39 @@ class SettingsDialog(QtGui.QDialog):
 
     def initUI(self):
         ''' Initiate the user interface '''
-        self.lpLabel=QtGui.QLabel("Libary Path:")
-        self.lpEdit=QtGui.QLineEdit(self.conf.get("library_path"))
-        self.lpBrowse=QtGui.QPushButton("Browse")
+        self.lpLabel=QtWidgets.QLabel("Libary Path:")
+        self.lpEdit=QtWidgets.QLineEdit(self.conf.get("library_path"))
+        self.lpBrowse=QtWidgets.QPushButton("Browse")
         self.lpBrowse.clicked.connect(self.lpUpdate)
-        self.cpLabel=QtGui.QLabel("Custom Path:")
-        self.cpEdit=QtGui.QLineEdit(self.conf.get("custom_path"))
-        self.cpBrowse=QtGui.QPushButton("Browse")
+        self.cpLabel=QtWidgets.QLabel("Custom Path:")
+        self.cpEdit=QtWidgets.QLineEdit(self.conf.get("custom_path"))
+        self.cpBrowse=QtWidgets.QPushButton("Browse")
         self.cpBrowse.clicked.connect(self.cpUpdate)
-        self.mpLabel=QtGui.QLabel("Module Path:")
-        self.mpEdit=QtGui.QLineEdit(self.conf.get("module_path"))
-        self.mpBrowse=QtGui.QPushButton("Browse")
+        self.mpLabel=QtWidgets.QLabel("Module Path:")
+        self.mpEdit=QtWidgets.QLineEdit(self.conf.get("module_path"))
+        self.mpBrowse=QtWidgets.QPushButton("Browse")
         self.mpBrowse.clicked.connect(self.mpUpdate)
-        self.splash=QtGui.QCheckBox("Show Splash Screen")
+        self.splash=QtWidgets.QCheckBox("Show Splash Screen")
         if(self.conf.get("splash_screen")=="yes"):
             self.splash.setChecked(True)
-        self.clean=QtGui.QCheckBox("Clean Log on Exit")
+        self.clean=QtWidgets.QCheckBox("Clean Log on Exit")
         if(self.conf.get("clean_log")=="yes"):
             self.clean.setChecked(True)
-        self.status=QtGui.QCheckBox("Show Status Message")
+        self.status=QtWidgets.QCheckBox("Show Status Message")
         if(self.conf.get("status_message")=="on"):
             self.status.setChecked(True)
-        self.ok=QtGui.QPushButton("Ok")
+        self.ok=QtWidgets.QPushButton("Ok")
         self.ok.clicked.connect(self.save)
-        self.cancel=QtGui.QPushButton("Cancel")
+        self.cancel=QtWidgets.QPushButton("Cancel")
         self.cancel.clicked.connect(self.close)
-        self.default=QtGui.QPushButton("Default")
+        self.default=QtWidgets.QPushButton("Default")
         self.default.clicked.connect(self.reset)
 
-        ctrl=QtGui.QHBoxLayout()
+        ctrl=QtWidgets.QHBoxLayout()
         ctrl.addWidget(self.ok)
         ctrl.addWidget(self.cancel)
         ctrl.addWidget(self.default)
-        layout=QtGui.QGridLayout(self)
+        layout=QtWidgets.QGridLayout(self)
         layout.addWidget(self.lpLabel, 0, 0)
         layout.addWidget(self.lpEdit, 0, 1)
         layout.addWidget(self.lpBrowse, 0, 2)
@@ -148,7 +148,7 @@ class SettingsDialog(QtGui.QDialog):
 
     def getFolder(self):
         ''' Returns the selected directory '''
-        dn=QtGui.QFileDialog.getExistingDirectory()
+        dn=QtWidgets.QFileDialog.getExistingDirectory()
         if(dn.startswith(QtCore.QDir.currentPath())):
            dn="."+dn[len(QtCore.QDir.currentPath()):]+"/"
         else:
@@ -172,7 +172,7 @@ class SettingsDialog(QtGui.QDialog):
             self.conf.set("status_message", "on")
         else:
             self.conf.set("status_message", "off")
-        QtGui.QMessageBox.information(self, "Restart required", "Some settings takes effect only after restarting DDStorm")
+        QtWidgets.QMessageBox.information(self, "Restart required", "Some settings takes effect only after restarting DDStorm")
         self.close()
         self.conf.write()
 
diff --git a/gui.py b/gui.py
index 55320cb0e1670845e8c834431250b70201982f40..667385c24fbc20c41fd8512b58f8dd0e59be7910 100644 (file)
--- a/gui.py
+++ b/gui.py
@@ -27,7 +27,7 @@ import sys
 import time
 import subprocess
 
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtGui, QtCore
 
 from panes import Symptoms, Differentials
 from ddstorm import DDStorm
@@ -37,7 +37,7 @@ from const import *
 
 conf=False
 
-class Content(QtGui.QWidget):
+class Content(QtWidgets.QWidget):
     '''
     Provides the main content widget. Contains the sysmptoms and
     the diagnosis panes. Also creates the DDStorm object and performs
@@ -56,7 +56,7 @@ class Content(QtGui.QWidget):
 
         # Show warning if any error happened during data compilation 
         if(not self.dd.compiler.is_clean()):
-            ret=QtGui.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
+            ret=QtWidgets.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
             if(ret==1):
                 x_logfile()
         
@@ -67,21 +67,21 @@ class Content(QtGui.QWidget):
         
         global conf
 
-        grid=QtGui.QGridLayout()
+        grid=QtWidgets.QGridLayout()
         self.setLayout(grid)
 
         self.symp=Symptoms(self.dd.symptoms())
-        self.symp.setFrameShape(QtGui.QFrame.StyledPanel)
+        self.symp.setFrameShape(QtWidgets.QFrame.StyledPanel)
         self.symp.changed.connect(self.update)
 
         self.diff=Differentials()
-        self.diff.setFrameShape(QtGui.QFrame.StyledPanel)
+        self.diff.setFrameShape(QtWidgets.QFrame.StyledPanel)
 
         grid.addWidget(self.symp, 0, 0)
         grid.addWidget(self.diff, 0, 1)
         grid.setColumnStretch(0, 1)
         grid.setColumnStretch(1, 1)
-        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
+        QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("Cleanlooks"))
         
     def update(self, data):
         ''' Update the inteface with refreshed information '''
@@ -89,7 +89,7 @@ class Content(QtGui.QWidget):
         self.change.emit()
 
 
-class Window(QtGui.QMainWindow):
+class Window(QtWidgets.QMainWindow):
     '''
     Provides main application window. Acts as a container for the
     content widget. Also contains the menubar and the status bar.
@@ -115,7 +115,7 @@ class Window(QtGui.QMainWindow):
         menuEdit=menu.addMenu("&Edit")
         menuEdit.addAction("&Add").triggered.connect(self.con.symp.addItem)
         menuEdit.addAction("&Browse Symptoms").triggered.connect(self.con.symp.browseSymptoms)
-        rmAction=QtGui.QAction("&Remove", self)
+        rmAction=QtWidgets.QAction("&Remove", self)
         rmAction.setShortcut("Delete")
         rmAction.triggered.connect(self.con.symp.remove)
         menuEdit.addAction(rmAction)
@@ -153,12 +153,12 @@ class Window(QtGui.QMainWindow):
 
     def about(self):
         ''' Show information about this application '''
-        QtGui.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
+        QtWidgets.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
 
 
 def main():
     ''' Start the main application interface '''
-    app=QtGui.QApplication(sys.argv)
+    app=QtWidgets.QApplication(sys.argv)
 
     # Initiate the global configuration
     global conf
@@ -174,7 +174,7 @@ def main():
     else:
         ss=False
     if(ss):
-        splash=QtGui.QSplashScreen(QtGui.QPixmap("icons/splash.png"))
+        splash=QtWidgets.QSplashScreen(QtWidgets.QPixmap("icons/splash.png"))
         splash.show()
         time.sleep(0.1)
         app.processEvents()
index 79636a4b6891ef7ae0b7e1a31f0baef261cf5250..0beff79a87d02bc8d5d47c617ef2f69bd836cd5d 100644 (file)
--- a/panes.py
+++ b/panes.py
@@ -22,9 +22,9 @@ You should have received a copy of the GNU General Public License
 along with DDStorm.  If not, see <http://www.gnu.org/licenses/>.
 '''
 
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtCore
 
-class Symptoms(QtGui.QFrame):
+class Symptoms(QtWidgets.QFrame):
     ''' Provides the widget for symptoms input '''
 
     # List to hold the symptoms
@@ -49,28 +49,28 @@ class Symptoms(QtGui.QFrame):
 
     def initUI(self):
         ''' Initiate the user interface '''
-        self.label=QtGui.QLabel("Symptoms")
+        self.label=QtWidgets.QLabel("Symptoms")
         self.label.setStyleSheet("font-size:18px")
 
-        self.listWidget=QtGui.QListWidget(self)
+        self.listWidget=QtWidgets.QListWidget(self)
         self.listWidget.setStyleSheet("font-size:14px")
         self.listWidget.setSelectionMode(4)
 
-        self.rm=QtGui.QPushButton("Remove")
+        self.rm=QtWidgets.QPushButton("Remove")
         self.rm.clicked.connect(self.remove)
 
-        self.cl=QtGui.QPushButton("Clear All")
+        self.cl=QtWidgets.QPushButton("Clear All")
         self.cl.clicked.connect(self.removeAll)
 
-        self.browse=QtGui.QPushButton("Browse Symptoms")
+        self.browse=QtWidgets.QPushButton("Browse Symptoms")
         self.browse.clicked.connect(self.browseSymptoms)
 
-        self.add=QtGui.QPushButton("Add")
+        self.add=QtWidgets.QPushButton("Add")
         self.add.clicked.connect(self.addItem)
 
-        self.new=QtGui.QLineEdit(self)
+        self.new=QtWidgets.QLineEdit(self)
         self.new.returnPressed.connect(self.addItem)
-        self.completer=QtGui.QCompleter(self.auto)
+        self.completer=QtWidgets.QCompleter(self.auto)
         self.completer.setCaseSensitivity(0)
         self.completer.setCompletionMode(2)
         self.new.setCompleter(self.completer)
@@ -78,14 +78,14 @@ class Symptoms(QtGui.QFrame):
         self.browser=SymptomBrowser(self.auto)
         self.browser.added.connect(self.addItem)
 
-        hboxt=QtGui.QHBoxLayout()
+        hboxt=QtWidgets.QHBoxLayout()
         hboxt.addWidget(self.new)
         hboxt.addWidget(self.add)
-        hboxb=QtGui.QHBoxLayout()
+        hboxb=QtWidgets.QHBoxLayout()
         hboxb.addWidget(self.rm)
         hboxb.addWidget(self.cl)
         hboxb.addWidget(self.browse)
-        vbox=QtGui.QVBoxLayout()
+        vbox=QtWidgets.QVBoxLayout()
         vbox.addWidget(self.label)
         vbox.addLayout(hboxt)
         vbox.addWidget(self.listWidget)
@@ -98,14 +98,14 @@ class Symptoms(QtGui.QFrame):
             text=self.new.text()
         if(len(text)>0):
             if(text in self.sympList):
-                QtGui.QMessageBox.information(self, "Duplicate Symptom", "'"+text+"' has already been added to the symptom list.")
+                QtWidgets.QMessageBox.information(self, "Duplicate Symptom", "'"+text+"' has already been added to the symptom list.")
             elif(text in self.auto):
-                QtGui.QListWidgetItem(text, self.listWidget)
+                QtWidgets.QListWidgetItem(text, self.listWidget)
                 self.sympList.append(text)
                 self.new.clear()
                 self.changed.emit(list(self.sympList))
             else:
-                QtGui.QMessageBox.warning(self, "Symptom Unvailable", "'"+text+"' is not available in the current Library.")
+                QtWidgets.QMessageBox.warning(self, "Symptom Unvailable", "'"+text+"' is not available in the current Library.")
 
     def remove(self, all=False):
         ''' Remove selected symptoms '''
@@ -130,7 +130,7 @@ class Symptoms(QtGui.QFrame):
         return self.sympList
 
 
-class SymptomBrowser(QtGui.QDialog):
+class SymptomBrowser(QtWidgets.QDialog):
     '''
     Provides a dialog with a list of symptoms for alternative user
     input.
@@ -146,12 +146,12 @@ class SymptomBrowser(QtGui.QDialog):
 
     def initUI(self):
         ''' Initiate the dialog interface '''
-        self.search=QtGui.QLineEdit()
+        self.search=QtWidgets.QLineEdit()
         self.search.textChanged.connect(self.refresh)
-        self.listItems=QtGui.QListWidget()
+        self.listItems=QtWidgets.QListWidget()
         self.listItems.activated.connect(self.sendUp)
 
-        layout=QtGui.QVBoxLayout(self)
+        layout=QtWidgets.QVBoxLayout(self)
         layout.addWidget(self.search)
         layout.addWidget(self.listItems)
 
@@ -174,7 +174,7 @@ class SymptomBrowser(QtGui.QDialog):
         self.close()
 
 
-class Differentials(QtGui.QFrame):
+class Differentials(QtWidgets.QFrame):
     ''' Provides the widget for differential diagnosis output '''
     data=[]
     
@@ -185,12 +185,12 @@ class Differentials(QtGui.QFrame):
         
     def initUI(self):
         ''' Initiate the user interface '''
-        self.label=QtGui.QLabel("Differential Diagnosis")
+        self.label=QtWidgets.QLabel("Differential Diagnosis")
         self.label.setStyleSheet("font-size:18px")
-        self.listWidget=QtGui.QListWidget(self)
+        self.listWidget=QtWidgets.QListWidget(self)
         self.listWidget.setStyleSheet("font-size:14px")
         self.listWidget.setSelectionMode(0)
-        box=QtGui.QVBoxLayout()
+        box=QtWidgets.QVBoxLayout()
         box.addWidget(self.label)
         box.addWidget(self.listWidget)
         self.setLayout(box)
@@ -207,7 +207,7 @@ class Differentials(QtGui.QFrame):
         self.listWidget.clear()
         if(self.data):
             for d in self.data:
-                QtGui.QListWidgetItem(d, self.listWidget)
+                QtWidgets.QListWidgetItem(d, self.listWidget)
 
     def getList(self):
         ''' Return a list of current differential diagnosis '''