diff options
Diffstat (limited to 'src/frontEnd')
-rw-r--r-- | src/frontEnd/Application.py | 108 | ||||
-rw-r--r-- | src/frontEnd/DockArea.py | 65 | ||||
-rw-r--r-- | src/frontEnd/ProjectExplorer.py | 59 | ||||
-rw-r--r-- | src/frontEnd/Workspace.py | 34 |
4 files changed, 133 insertions, 133 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index cb7a7527..d373e695 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -11,9 +11,9 @@ # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in -# ORGANIZATION: eSim team at FOSSEE, IIT Bombay. +# ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Friday 24 July 2020 +# REVISION: Saturday 25 July 2020 # ========================================================================= import os @@ -25,7 +25,7 @@ else: import pathmagic # noqa:F401 init_path = '../../' -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from configuration.Appconfig import Appconfig from projManagement.openProject import OpenProjectInfo from projManagement.newProject import NewProjectInfo @@ -35,14 +35,14 @@ from projManagement import Worker from frontEnd import ProjectExplorer from frontEnd import Workspace from frontEnd import DockArea -from PyQt4.Qt import QSize +from PyQt5.Qt import QSize import shutil import time import sys # Its our main window of application. -class Application(QtGui.QMainWindow): +class Application(QtWidgets.QMainWindow): """This class initializes all objects used in this file.""" global project_name @@ -50,7 +50,7 @@ class Application(QtGui.QMainWindow): """Initialize main Application window.""" # Calling __init__ of super class - QtGui.QMainWindow.__init__(self, *args) + QtWidgets.QMainWindow.__init__(self, *args) # Flag for mode of operation. Default is set to offline mode. self.online_flag = False @@ -73,7 +73,7 @@ class Application(QtGui.QMainWindow): self.showMaximized() self.setWindowIcon(QtGui.QIcon(init_path + 'images/logo.png')) - self.systemTrayIcon = QtGui.QSystemTrayIcon(self) + self.systemTrayIcon = QtWidgets.QSystemTrayIcon(self) self.systemTrayIcon.setIcon(QtGui.QIcon(init_path + 'images/logo.png')) self.systemTrayIcon.setVisible(True) @@ -89,28 +89,28 @@ class Application(QtGui.QMainWindow): Converter, OM Optimisation) """ # Top Tool bar - self.newproj = QtGui.QAction( + self.newproj = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/newProject.png'), '<b>New Project</b>', self ) self.newproj.setShortcut('Ctrl+N') self.newproj.triggered.connect(self.new_project) - self.openproj = QtGui.QAction( + self.openproj = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/openProject.png'), '<b>Open Project</b>', self ) self.openproj.setShortcut('Ctrl+O') self.openproj.triggered.connect(self.open_project) - self.closeproj = QtGui.QAction( + self.closeproj = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/closeProject.png'), '<b>Close Project</b>', self ) self.closeproj.setShortcut('Ctrl+X') self.closeproj.triggered.connect(self.close_project) - self.wrkspce = QtGui.QAction( + self.wrkspce = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/workspace.ico'), '<b>Change Workspace</b>', self ) @@ -120,17 +120,17 @@ class Application(QtGui.QMainWindow): self.switchmode = None self.validate_mode() if self.online_flag is True: - self.switchmode = QtGui.QAction(QtGui.QIcon( + self.switchmode = QtWidgets.QAction(QtGui.QIcon( init_path + 'images/online.png'), '<b>Go Offline</b>', self ) elif self.online_flag is False: - self.switchmode = QtGui.QAction(QtGui.QIcon( + self.switchmode = QtWidgets.QAction(QtGui.QIcon( init_path + 'images/offline.png'), '<b>Go Online</b>', self ) elif self.online_flag is None: - self.switchmode = QtGui.QAction(QtGui.QIcon( + self.switchmode = QtWidgets.QAction(QtGui.QIcon( init_path + 'images/disable.png'), '<b>Mode switching has been disabled. ' + 'Default mode set to offline</b>', self @@ -139,7 +139,7 @@ class Application(QtGui.QMainWindow): self.switchmode.setShortcut('Ctrl+G') self.switchmode.triggered.connect(self.change_mode) - self.helpfile = QtGui.QAction( + self.helpfile = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/helpProject.png'), '<b>Help</b>', self ) @@ -156,12 +156,12 @@ class Application(QtGui.QMainWindow): # This part is setting fossee logo to the right # corner in the application window. - self.spacer = QtGui.QWidget() + self.spacer = QtWidgets.QWidget() self.spacer.setSizePolicy( - QtGui.QSizePolicy.Expanding, - QtGui.QSizePolicy.Expanding) + QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Expanding) self.topToolbar.addWidget(self.spacer) - self.logo = QtGui.QLabel() + self.logo = QtWidgets.QLabel() self.logopic = QtGui.QPixmap( os.path.join( os.path.abspath(''), init_path + 'images', 'fosseeLogo.png' @@ -173,55 +173,55 @@ class Application(QtGui.QMainWindow): self.topToolbar.addWidget(self.logo) # Left Tool bar Action Widget - self.kicad = QtGui.QAction( + self.kicad = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/kicad.png'), '<b>Open Schematic</b>', self ) self.kicad.triggered.connect(self.obj_kicad.openSchematic) - self.conversion = QtGui.QAction( + self.conversion = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/ki-ng.png'), '<b>Convert Kicad to Ngspice</b>', self ) self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice) - self.ngspice = QtGui.QAction( + self.ngspice = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/ngspice.png'), '<b>Simulation</b>', self ) self.ngspice.triggered.connect(self.open_ngspice) - self.model = QtGui.QAction( + self.model = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/model.png'), '<b>Model Editor</b>', self ) self.model.triggered.connect(self.open_modelEditor) - self.subcircuit = QtGui.QAction( + self.subcircuit = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/subckt.png'), '<b>Subcircuit</b>', self ) self.subcircuit.triggered.connect(self.open_subcircuit) - self.nghdl = QtGui.QAction( + self.nghdl = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/nghdl.png'), '<b>Nghdl</b>', self ) self.nghdl.triggered.connect(self.open_nghdl) - self.omedit = QtGui.QAction( + self.omedit = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/omedit.png'), '<b>Modelica Converter</b>', self ) self.omedit.triggered.connect(self.open_OMedit) - self.omoptim = QtGui.QAction( + self.omoptim = QtWidgets.QAction( QtGui.QIcon(init_path + 'images/omoptim.png'), '<b>OM Optimisation</b>', self ) self.omoptim.triggered.connect(self.open_OMoptim) # Adding Action Widget to tool bar - self.lefttoolbar = QtGui.QToolBar('Left ToolBar') + self.lefttoolbar = QtWidgets.QToolBar('Left ToolBar') self.addToolBar(QtCore.Qt.LeftToolBarArea, self.lefttoolbar) self.lefttoolbar.addAction(self.kicad) self.lefttoolbar.addAction(self.conversion) @@ -254,12 +254,12 @@ class Application(QtGui.QMainWindow): ''' exit_msg = "Are you sure you want to exit the program?" exit_msg += " All unsaved data will be lost." - reply = QtGui.QMessageBox.question( - self, 'Message', exit_msg, QtGui.QMessageBox.Yes, - QtGui.QMessageBox.No + reply = QtWidgets.QMessageBox.question( + self, 'Message', exit_msg, QtWidgets.QMessageBox.Yes, + QtWidgets.QMessageBox.No ) - if reply == QtGui.QMessageBox.Yes: + if reply == QtWidgets.QMessageBox.Yes: for proc in self.obj_appconfig.procThread_list: try: proc.terminate() @@ -283,12 +283,12 @@ class Application(QtGui.QMainWindow): event.accept() self.systemTrayIcon.showMessage('Exit', 'eSim is Closed.') - elif reply == QtGui.QMessageBox.No: + elif reply == QtWidgets.QMessageBox.No: event.ignore() def new_project(self): """This function call New Project Info class.""" - text, ok = QtGui.QInputDialog.getText( + text, ok = QtWidgets.QInputDialog.getText( self, 'New Project Info', 'Enter Project Name:' ) if ok: @@ -492,7 +492,7 @@ class Application(QtGui.QMainWindow): ) self.switchmode.setEnabled(False) else: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setWindowTitle("Error Message") self.msg.setModal(True) self.msg.showMessage( @@ -544,7 +544,7 @@ class Application(QtGui.QMainWindow): try: self.obj_Mainview.obj_dockarea.plottingEditor() except Exception as e: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( @@ -556,7 +556,7 @@ class Application(QtGui.QMainWindow): self.obj_appconfig.print_error('Exception Message : ' + str(e)) else: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( @@ -597,7 +597,7 @@ class Application(QtGui.QMainWindow): self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() else: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle('NGHDL Error') self.msg.showMessage('Error while opening NGHDL. ' + @@ -651,7 +651,7 @@ class Application(QtGui.QMainWindow): self.obj_workThread2 = Worker.WorkerThread(self.cmd2) self.obj_workThread2.start() else: - self.msg = QtGui.QMessageBox() + self.msg = QtWidgets.QMessageBox() self.msgContent = "There was an error while opening OMEdit.<br/>\ Please make sure OpenModelica is installed in your\ @@ -671,7 +671,7 @@ class Application(QtGui.QMainWindow): self.msg.exec_() except Exception as e: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle( "Ngspice to Modelica conversion error") @@ -685,7 +685,7 @@ class Application(QtGui.QMainWindow): self.obj_Mainview.obj_dockarea.modelicaEditor(self.projDir) else: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle("Missing Ngspice netlist") self.msg.showMessage( @@ -694,7 +694,7 @@ class Application(QtGui.QMainWindow): ) self.msg.exec_() else: - self.msg = QtGui.QErrorMessage() + self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( @@ -721,7 +721,7 @@ class Application(QtGui.QMainWindow): self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() else: - self.msg = QtGui.QMessageBox() + self.msg = QtWidgets.QMessageBox() self.msgContent = ( "There was an error while opening OMOptim.<br/>" "Please make sure OpenModelica is installed in your" @@ -742,7 +742,7 @@ class Application(QtGui.QMainWindow): # This class initialize the Main View of Application -class MainView(QtGui.QWidget): +class MainView(QtWidgets.QWidget): """ This class defines whole view and style of main page: @@ -756,20 +756,20 @@ class MainView(QtGui.QWidget): def __init__(self, *args): # call init method of superclass - QtGui.QWidget.__init__(self, *args) + QtWidgets.QWidget.__init__(self, *args) self.obj_appconfig = Appconfig() - self.leftSplit = QtGui.QSplitter() - self.middleSplit = QtGui.QSplitter() + self.leftSplit = QtWidgets.QSplitter() + self.middleSplit = QtWidgets.QSplitter() - self.mainLayout = QtGui.QVBoxLayout() + self.mainLayout = QtWidgets.QVBoxLayout() # Intermediate Widget - self.middleContainer = QtGui.QWidget() - self.middleContainerLayout = QtGui.QVBoxLayout() + self.middleContainer = QtWidgets.QWidget() + self.middleContainerLayout = QtWidgets.QVBoxLayout() # Area to be included in MainView - self.noteArea = QtGui.QTextEdit() + self.noteArea = QtWidgets.QTextEdit() self.noteArea.setReadOnly(True) self.obj_appconfig.noteArea['Note'] = self.noteArea self.obj_appconfig.noteArea['Note'].append( @@ -812,13 +812,15 @@ def main(args): by this function. """ print("Starting eSim......") - app = QtGui.QApplication(args) + app = QtWidgets.QApplication(args) appView = Application() appView.hide() splash_pix = QtGui.QPixmap(init_path + 'images/splash_screen_esim.png') - splash = QtGui.QSplashScreen(appView, splash_pix, QtCore.Qt.WindowStaysOnTopHint) + splash = QtWidgets.QSplashScreen( + appView, splash_pix, QtCore.Qt.WindowStaysOnTopHint + ) splash.setMask(splash_pix.mask()) splash.setDisabled(True) splash.show() diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index b8ebfac4..b96c468a 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets from ngspiceSimulation.pythonPlotting import plotWindow from ngspiceSimulation.NgspiceWidget import NgspiceWidget from configuration.Appconfig import Appconfig @@ -15,7 +15,7 @@ count = 1 dock = {} -class DockArea(QtGui.QMainWindow): +class DockArea(QtWidgets.QMainWindow): """ This class contains function for designing UI of all the editors in dock area part: @@ -31,13 +31,13 @@ class DockArea(QtGui.QMainWindow): def __init__(self): """This act as constructor for class DockArea.""" - QtGui.QMainWindow.__init__(self) + QtWidgets.QMainWindow.__init__(self) self.obj_appconfig = Appconfig() for dockName in dockList: - dock[dockName] = QtGui.QDockWidget(dockName) - self.welcomeWidget = QtGui.QWidget() - self.welcomeLayout = QtGui.QVBoxLayout() + dock[dockName] = QtWidgets.QDockWidget(dockName) + self.welcomeWidget = QtWidgets.QWidget() + self.welcomeLayout = QtWidgets.QVBoxLayout() self.welcomeLayout.addWidget(Welcome()) # Call browser # Adding to main Layout @@ -57,14 +57,15 @@ class DockArea(QtGui.QMainWindow): """This function create widget for Library Editor""" global count - self.testWidget = QtGui.QWidget() - self.testArea = QtGui.QTextEdit() - self.testLayout = QtGui.QVBoxLayout() + self.testWidget = QtWidgets.QWidget() + self.testArea = QtWidgets.QTextEdit() + self.testLayout = QtWidgets.QVBoxLayout() self.testLayout.addWidget(self.testArea) # Adding to main Layout self.testWidget.setLayout(self.testLayout) - dock['Tips-' + str(count)] = QtGui.QDockWidget('Tips-' + str(count)) + dock['Tips-' + str(count)] = \ + QtWidgets.QDockWidget('Tips-' + str(count)) dock['Tips-' + str(count)].setWidget(self.testWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Tips-' + str(count)]) @@ -90,15 +91,15 @@ class DockArea(QtGui.QMainWindow): # self.project = os.path.join(self.projDir, self.projName) global count - self.plottingWidget = QtGui.QWidget() + self.plottingWidget = QtWidgets.QWidget() - self.plottingLayout = QtGui.QVBoxLayout() + self.plottingLayout = QtWidgets.QVBoxLayout() self.plottingLayout.addWidget(plotWindow(self.projDir, self.projName)) # Adding to main Layout self.plottingWidget.setLayout(self.plottingLayout) dock['Plotting-' + str(count) - ] = QtGui.QDockWidget('Plotting-' + str(count)) + ] = QtWidgets.QDockWidget('Plotting-' + str(count)) dock['Plotting-' + str(count)].setWidget(self.plottingWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Plotting-' + str(count)]) @@ -123,9 +124,9 @@ class DockArea(QtGui.QMainWindow): self.projDir, self.projName + ".cir.out") global count - self.ngspiceWidget = QtGui.QWidget() + self.ngspiceWidget = QtWidgets.QWidget() - self.ngspiceLayout = QtGui.QVBoxLayout() + self.ngspiceLayout = QtWidgets.QVBoxLayout() self.ngspiceLayout.addWidget( NgspiceWidget(self.ngspiceNetlist, self.projDir) ) @@ -133,7 +134,7 @@ class DockArea(QtGui.QMainWindow): # Adding to main Layout self.ngspiceWidget.setLayout(self.ngspiceLayout) dock['NgSpice-' + str(count) - ] = QtGui.QDockWidget('NgSpice-' + str(count)) + ] = QtWidgets.QDockWidget('NgSpice-' + str(count)) dock['NgSpice-' + str(count)].setWidget(self.ngspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['NgSpice-' + str(count)]) @@ -160,16 +161,16 @@ class DockArea(QtGui.QMainWindow): """This function defines UI for model editor.""" print("in model editor") global count - self.modelwidget = QtGui.QWidget() + self.modelwidget = QtWidgets.QWidget() - self.modellayout = QtGui.QVBoxLayout() + self.modellayout = QtWidgets.QVBoxLayout() self.modellayout.addWidget(ModelEditorclass()) # Adding to main Layout self.modelwidget.setLayout(self.modellayout) dock['Model Editor-' + - str(count)] = QtGui.QDockWidget('Model Editor-' + str(count)) + str(count)] = QtWidgets.QDockWidget('Model Editor-' + str(count)) dock['Model Editor-' + str(count)].setWidget(self.modelwidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Model Editor-' + str(count)]) @@ -193,13 +194,13 @@ class DockArea(QtGui.QMainWindow): This function is creating Editor UI for Kicad to Ngspice conversion. """ global count - self.kicadToNgspiceWidget = QtGui.QWidget() - self.kicadToNgspiceLayout = QtGui.QVBoxLayout() + self.kicadToNgspiceWidget = QtWidgets.QWidget() + self.kicadToNgspiceLayout = QtWidgets.QVBoxLayout() self.kicadToNgspiceLayout.addWidget(MainWindow(clarg1, clarg2)) self.kicadToNgspiceWidget.setLayout(self.kicadToNgspiceLayout) - dock['kicadToNgspice-' + - str(count)] = QtGui.QDockWidget('kicadToNgspice-' + str(count)) + dock['kicadToNgspice-' + str(count)] = \ + QtWidgets.QDockWidget('kicadToNgspice-' + str(count)) dock['kicadToNgspice-' + str(count)].setWidget(self.kicadToNgspiceWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, @@ -228,13 +229,13 @@ class DockArea(QtGui.QMainWindow): def subcircuiteditor(self): """This function creates a widget for different subcircuit options.""" global count - self.subcktWidget = QtGui.QWidget() - self.subcktLayout = QtGui.QVBoxLayout() + self.subcktWidget = QtWidgets.QWidget() + self.subcktLayout = QtWidgets.QVBoxLayout() self.subcktLayout.addWidget(Subcircuit(self)) self.subcktWidget.setLayout(self.subcktLayout) dock['Subcircuit-' + - str(count)] = QtGui.QDockWidget('Subcircuit-' + str(count)) + str(count)] = QtWidgets.QDockWidget('Subcircuit-' + str(count)) dock['Subcircuit-' + str(count)].setWidget(self.subcktWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Subcircuit-' + str(count)]) @@ -256,13 +257,13 @@ class DockArea(QtGui.QMainWindow): def usermanual(self): """This function creates a widget for user manual.""" global count - self.usermanualWidget = QtGui.QWidget() - self.usermanualLayout = QtGui.QVBoxLayout() + self.usermanualWidget = QtWidgets.QWidget() + self.usermanualLayout = QtWidgets.QVBoxLayout() self.usermanualLayout.addWidget(UserManual()) self.usermanualWidget.setLayout(self.usermanualLayout) dock['User Manual-' + - str(count)] = QtGui.QDockWidget('User Manual-' + str(count)) + str(count)] = QtWidgets.QDockWidget('User Manual-' + str(count)) dock['User Manual-' + str(count)].setWidget(self.usermanualWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['User Manual-' + str(count)]) @@ -284,13 +285,13 @@ class DockArea(QtGui.QMainWindow): def modelicaEditor(self, projDir): """This function sets up the UI for ngspice to modelica conversion.""" global count - self.modelicaWidget = QtGui.QWidget() - self.modelicaLayout = QtGui.QVBoxLayout() + self.modelicaWidget = QtWidgets.QWidget() + self.modelicaLayout = QtWidgets.QVBoxLayout() self.modelicaLayout.addWidget(OpenModelicaEditor(projDir)) self.modelicaWidget.setLayout(self.modelicaLayout) dock['Modelica-' + str(count) - ] = QtGui.QDockWidget('Modelica-' + str(count)) + ] = QtWidgets.QDockWidget('Modelica-' + str(count)) dock['Modelica-' + str(count)].setWidget(self.modelicaWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Modelica-' + str(count)]) diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index d327427c..456276c8 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets import os import json from configuration.Appconfig import Appconfig @@ -6,7 +6,7 @@ from projManagement.Validation import Validation # This is main class for Project Explorer Area. -class ProjectExplorer(QtGui.QWidget): +class ProjectExplorer(QtWidgets.QWidget): """ This class contains function: @@ -23,12 +23,12 @@ class ProjectExplorer(QtGui.QWidget): - Working as a constructor for class ProjectExplorer. - view of project explorer area. """ - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.obj_appconfig = Appconfig() self.obj_validation = Validation() - self.treewidget = QtGui.QTreeWidget() - self.window = QtGui.QVBoxLayout() - header = QtGui.QTreeWidgetItem(["Projects", "path"]) + self.treewidget = QtWidgets.QTreeWidget() + self.window = QtWidgets.QVBoxLayout() + header = QtWidgets.QTreeWidgetItem(["Projects", "path"]) self.treewidget.setHeaderItem(header) self.treewidget.setColumnHidden(1, True) @@ -61,11 +61,11 @@ class ProjectExplorer(QtGui.QWidget): os.path.join(parents) if os.path.exists(parents): pathlist = parents.split(os.sep) - parentnode = QtGui.QTreeWidgetItem( + parentnode = QtWidgets.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents] ) for files in children: - QtGui.QTreeWidgetItem( + QtWidgets.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)] ) self.window.addWidget(self.treewidget) @@ -79,11 +79,11 @@ class ProjectExplorer(QtGui.QWidget): def addTreeNode(self, parents, children): os.path.join(parents) pathlist = parents.split(os.sep) - parentnode = QtGui.QTreeWidgetItem( + parentnode = QtWidgets.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents] ) for files in children: - QtGui.QTreeWidgetItem( + QtWidgets.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)] ) @@ -105,7 +105,7 @@ class ProjectExplorer(QtGui.QWidget): index = index.parent() level += 1 - menu = QtGui.QMenu() + menu = QtWidgets.QMenu() if level == 0: renameProject = menu.addAction(self.tr("Rename Project")) renameProject.triggered.connect(self.renameProject) @@ -128,30 +128,27 @@ class ProjectExplorer(QtGui.QWidget): self.obj_appconfig.print_info( 'The current project is ' + self.filePath) - self.textwindow = QtGui.QWidget() + self.textwindow = QtWidgets.QWidget() self.textwindow.setMinimumSize(600, 500) self.textwindow.setGeometry(QtCore.QRect(400, 150, 400, 400)) self.textwindow.setWindowTitle(filename) - self.text = QtGui.QTextEdit() - self.save = QtGui.QPushButton('Save and Exit') + self.text = QtWidgets.QTextEdit() + self.save = QtWidgets.QPushButton('Save and Exit') self.save.setDisabled(True) - self.windowgrid = QtGui.QGridLayout() + self.windowgrid = QtWidgets.QGridLayout() if (os.path.isfile(str(self.filePath))): self.fopen = open(str(self.filePath), 'r') lines = self.fopen.read() self.text.setText(lines) - QtCore.QObject.connect( - self.text, QtCore.SIGNAL("textChanged()"), self.enable_save - ) + self.text.textChanged.connect(self.enable_save) - vbox_main = QtGui.QVBoxLayout(self.textwindow) + vbox_main = QtWidgets.QVBoxLayout(self.textwindow) vbox_main.addWidget(self.text) vbox_main.addWidget(self.save) self.save.clicked.connect(self.save_data) - # self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit) self.textwindow.show() else: @@ -225,7 +222,7 @@ class ProjectExplorer(QtGui.QWidget): for items in self.treewidget.selectedItems(): items.removeChild(items.child(0)) for files in filelistnew: - QtGui.QTreeWidgetItem( + QtWidgets.QTreeWidgetItem( parentnode, [files, os.path.join(filePath, files)] ) @@ -237,7 +234,7 @@ class ProjectExplorer(QtGui.QWidget): else: print("Selected project not found") print("==================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage('Selected project does not exist.') @@ -262,9 +259,9 @@ class ProjectExplorer(QtGui.QWidget): self.indexItem.sibling(self.indexItem.row(), 1).data() ) - newBaseFileName, ok = QtGui.QInputDialog.getText( + newBaseFileName, ok = QtWidgets.QInputDialog.getText( self, 'Rename Project', 'Project Name:', - QtGui.QLineEdit.Normal, self.baseFileName + QtWidgets.QLineEdit.Normal, self.baseFileName ) if ok and newBaseFileName: @@ -273,7 +270,7 @@ class ProjectExplorer(QtGui.QWidget): if not newBaseFileName.strip(): print("Project name cannot be empty") print("==================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage('The project name cannot be empty') @@ -282,7 +279,7 @@ class ProjectExplorer(QtGui.QWidget): elif self.baseFileName == newBaseFileName: print("Project name has to be different") print("==================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage('The project name has to be different') @@ -312,7 +309,7 @@ class ProjectExplorer(QtGui.QWidget): print("Project Path :", projectPath) print("Project Files :", projectFiles) print("==================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage('Selected project does not exist.') @@ -331,7 +328,7 @@ class ProjectExplorer(QtGui.QWidget): try: os.rename(projectPath, updatedProjectPath) except BaseException as e: - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage(str(e)) @@ -370,7 +367,7 @@ class ProjectExplorer(QtGui.QWidget): # Revert project folder name os.rename(updatedProjectPath, projectPath) print("==================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage(str(e)) @@ -396,7 +393,7 @@ class ProjectExplorer(QtGui.QWidget): elif reply == "CHECKEXIST": print("Project name already exists.") print("==========================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage( @@ -409,7 +406,7 @@ class ProjectExplorer(QtGui.QWidget): elif reply == "CHECKNAME": print("Name can not contain space between them") print("===========================") - msg = QtGui.QErrorMessage(self) + msg = QtWidgets.QErrorMessage(self) msg.setModal(True) msg.setWindowTitle("Error Message") msg.showMessage( diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 85dafdf3..58f56ce5 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -11,19 +11,19 @@ # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in -# ORGANIZATION: eSim team at FOSSEE, IIT Bombay. +# ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Wednesday 05 February 2015 -# REVISION: Friday 24 July 2020 +# REVISION: Saturday 25 July 2020 # ========================================================================= -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from configuration.Appconfig import Appconfig import time import os import json -class Workspace(QtGui.QWidget): +class Workspace(QtWidgets.QWidget): """ This class creates UI for WorkSpace selection window. @@ -43,30 +43,30 @@ class Workspace(QtGui.QWidget): def initWorkspace(self): - self.mainwindow = QtGui.QVBoxLayout() - self.split = QtGui.QSplitter() + self.mainwindow = QtWidgets.QVBoxLayout() + self.split = QtWidgets.QSplitter() self.split.setOrientation(QtCore.Qt.Vertical) - self.grid = QtGui.QGridLayout() - self.note = QtGui.QTextEdit(self) + self.grid = QtWidgets.QGridLayout() + self.note = QtWidgets.QTextEdit(self) self.note.append(self.obj_appconfig.workspace_text) self.note.setReadOnly(True) - - self.workspace_label = QtGui.QLabel(self) + + self.workspace_label = QtWidgets.QLabel(self) self.workspace_label.setText("Workspace:") - self.workspace_loc = QtGui.QLineEdit(self) + self.workspace_loc = QtWidgets.QLineEdit(self) self.workspace_loc.setText(self.obj_appconfig.home) # Buttons - self.browsebtn = QtGui.QPushButton('Browse') + self.browsebtn = QtWidgets.QPushButton('Browse') self.browsebtn.clicked.connect(self.browseLocation) - self.okbtn = QtGui.QPushButton('OK') + self.okbtn = QtWidgets.QPushButton('OK') self.okbtn.clicked.connect(self.createWorkspace) - self.cancelbtn = QtGui.QPushButton('Cancel') + self.cancelbtn = QtWidgets.QPushButton('Cancel') self.cancelbtn.clicked.connect(self.defaultWorkspace) # Checkbox - self.chkbox = QtGui.QCheckBox('Set Default', self) + self.chkbox = QtWidgets.QCheckBox('Set Default', self) self.chkbox.setCheckState(int(self.obj_appconfig.workspace_check)) # Layout @@ -113,7 +113,7 @@ class Workspace(QtGui.QWidget): def close(self, *args, **kwargs): self.window_open_close = 1 self.close_var = 1 - return QtGui.QWidget.close(self, *args, **kwargs) + return QtWidgets.QWidget.close(self, *args, **kwargs) def returnWhetherClickedOrNot(self, appView): global var_appView @@ -172,7 +172,7 @@ class Workspace(QtGui.QWidget): def browseLocation(self): print("Function : Browse Location") - self.workspace_directory = QtGui.QFileDialog.getExistingDirectory( + self.workspace_directory = QtWidgets.QFileDialog.getExistingDirectory( self, "Browse Location", os.path.expanduser("~") ) self.workspace_loc.setText(self.workspace_directory) |