diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/frontEnd/Application.py | 94 | ||||
-rw-r--r-- | src/frontEnd/DockArea.py | 67 | ||||
-rw-r--r-- | src/frontEnd/ProjectExplorer.py | 48 | ||||
-rw-r--r-- | src/frontEnd/Workspace.py | 12 |
4 files changed, 137 insertions, 84 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index f69eed5c..19fe17ef 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -1,5 +1,4 @@ - -#========================================================================= +# ========================================================================= # # FILE: Application.py # @@ -15,14 +14,8 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 21 January 2015 # REVISION: --- -#========================================================================= -import os -import sys -# Setting PYTHONPATH -cwd = os.getcwd() -(setPath, fronEnd) = os.path.split(cwd) -sys.path.append(setPath) - +# ========================================================================= +import pathmagic # noqa from PyQt4 import QtGui, QtCore from configuration.Appconfig import Appconfig from projManagement.openProject import OpenProjectInfo @@ -35,6 +28,8 @@ from frontEnd import Workspace from frontEnd import DockArea import time from PyQt4.Qt import QSize +import sys +import os class Application(QtGui.QMainWindow): @@ -192,9 +187,11 @@ class Application(QtGui.QMainWindow): self.lefttoolbar.setIconSize(QSize(40, 40)) def closeEvent(self, event): - exit_msg = "Are you sure you want to exit the program ? All unsaved data will be lost." - reply = QtGui.QMessageBox.question(self, 'Message', - exit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) + exit_msg = "Are you sure you want to exit the program\ + ? All unsaved data will be lost." + reply = QtGui.QMessageBox.question( + self, 'Message', exit_msg, QtGui.QMessageBox.Yes, + QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: for proc in self.obj_appconfig.procThread_list: @@ -228,7 +225,8 @@ class Application(QtGui.QMainWindow): if current_project is None: pass else: - for pid in self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']]: + temp = self.obj_appconfig.current_project['ProjectName'] + for pid in self.obj_appconfig.proc_dict[temp]: try: os.kill(pid, 9) except BaseException: @@ -309,8 +307,8 @@ class Application(QtGui.QMainWindow): else: self.msg = QtGui.QErrorMessage() - self.msg.showMessage( - 'Please select the project first. You can either create new project or open existing project') + self.msg.showMessage('Please select the project first. You can either\ + create new project or open existing project') self.msg.setWindowTitle("Error Message") def open_subcircuit(self): @@ -329,10 +327,10 @@ class Application(QtGui.QMainWindow): else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage( - 'Error while opening nghdl. Please make sure nghdl is installed') - self.obj_appconfig.print_error( - 'Error while opening nghdl. Please make sure nghdl is installed') + self.msg.showMessage('Error while opening nghdl.\ + Please make sure nghdl is installed') + self.obj_appconfig.print_error('Error while opening nghdl.\ + Please make sure nghdl is installed') self.msg.setWindowTitle('nghdl Error Message') def open_modelEditor(self): @@ -342,7 +340,8 @@ class Application(QtGui.QMainWindow): def open_OMedit(self): """ - This function call ngspice to OM edit converter and then launch OM edit. + This function call ngspice to OM edit converter + and then launch OM edit. """ self.obj_appconfig.print_info('OM edit is called') self.projDir = self.obj_appconfig.current_project["ProjectName"] @@ -357,23 +356,33 @@ class Application(QtGui.QMainWindow): """ try: - #Creating a command for Ngspice to Modelica converter - self.cmd1 = "python ../ngspicetoModelica/NgspicetoModelica.py "+self.ngspiceNetlist + # Creating a command for Ngspice to Modelica converter + self.cmd1 = " + python ../ngspicetoModelica/NgspicetoModelica.py "\ + +self.ngspiceNetlist self.obj_workThread1 = Worker.WorkerThread(self.cmd1) self.obj_workThread1.start() if self.obj_validation.validateTool("OMEdit"): - #Creating command to run OMEdit + # Creating command to run OMEdit self.cmd2 = "OMEdit "+self.modelicaNetlist self.obj_workThread2 = Worker.WorkerThread(self.cmd2) self.obj_workThread2.start() else: self.msg = QtGui.QMessageBox() - self.msgContent = "There was an error while opening OMEdit.<br/>\ - Please make sure OpenModelica is installed in your system. <br/>\ - To install it on Linux : Go to <a href=https://www.openmodelica.org/download/download-linux>OpenModelica Linux</a> and install nigthly build release.<br/>\ - To install it on Windows : Go to <a href=https://www.openmodelica.org/download/download-windows>OpenModelica Windows</a> and install latest version.<br/>" + self.msgContent = "There was an error while + opening OMEdit.<br/>\ + Please make sure OpenModelica is installed in your\ + system. <br/>\ + To install it on Linux : Go to\ + <a href=https://www.openmodelica.org/download/\ + download-linux>OpenModelica Linux</a> and \ + install nigthly build release.<br/>\ + To install it on Windows : Go to\ + <a href=https://www.openmodelica.org/download/\ + download-windows>OpenModelica Windows</a>\ + and install latest version.<br/>" self.msg.setTextFormat(QtCore.Qt.RichText) self.msg.setText(self.msgContent) self.msg.setWindowTitle("Missing OpenModelica") @@ -382,8 +391,11 @@ class Application(QtGui.QMainWindow): except Exception as e: self.msg = QtGui.QErrorMessage() - self.msg.showMessage('Unable to convert NgSpice netlist to Modelica netlist :'+str(e)) - self.msg.setWindowTitle("Ngspice to Modelica conversion error") + self.msg.showMessage( + 'Unable to convert NgSpice netlist to\ + Modelica netlist :'+str(e)) + self.msg.setWindowTitle( + "Ngspice to Modelica conversion error") self.obj_appconfig.print_error(str(e)) """ @@ -392,12 +404,15 @@ class Application(QtGui.QMainWindow): else: self.msg = QtGui.QErrorMessage() self.msg.showMessage( - 'Current project does not contain any ngspice file. Please create ngspice file with extension .cir.out') + 'Current project does not contain any ngspice file.\ + Please create ngspice file with extension .cir.out') self.msg.setWindowTitle("Missing Ngspice netlist") else: self.msg = QtGui.QErrorMessage() self.msg.showMessage( - 'Please select the project first. You can either create new project or open existing project') + 'Please select the project first.\ + You can either create new project\ + or open existing project') self.msg.setWindowTitle("Error Message") def open_OMoptim(self): @@ -413,8 +428,12 @@ class Application(QtGui.QMainWindow): self.msg = QtGui.QMessageBox() self.msgContent = "There was an error while opening OMOptim.<br/>\ Please make sure OpenModelica is installed in your system. <br/>\ - To install it on Linux : Go to <a href=https://www.openmodelica.org/download/download-linux>OpenModelica Linux</a> and install nigthly build release.<br/>\ - To install it on Windows : Go to <a href=https://www.openmodelica.org/download/download-windows>OpenModelica Windows</a> and install latest version.<br/>" + To install it on Linux : Go to <a href=https://www.openmodelica\ + .org/download/download-linux>OpenModelica Linux</a> and \ + install nigthly build release.<br/>\ + To install it on Windows : Go to <a href=https://www.openmodelica.\ + org/download/download-windows>OpenModelica Windows</a> and \ + install latest version.<br/>" self.msg.setTextFormat(QtCore.Qt.RichText) self.msg.setText(self.msgContent) self.msg.setWindowTitle("Error Message") @@ -449,10 +468,10 @@ class MainView(QtGui.QWidget): ' eSim Started......') self.obj_appconfig.noteArea['Note'].append('Project Selected : None') self.obj_appconfig.noteArea['Note'].append('\n') - # CSS self.noteArea.setStyleSheet(" \ - QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; } \ + QWidget { border-radius: 15px; border: 1px \ + solid gray; padding: 5px; } \ ") self.obj_dockarea = DockArea.DockArea() @@ -497,8 +516,9 @@ def main(args): sys.exit(app.exec_()) - # Call main function + + if __name__ == '__main__': # Create and display the splash screen main(sys.argv) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index b60a6720..b44a87e6 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -32,7 +32,8 @@ class DockArea(QtGui.QMainWindow): dock[dockName].setWidget(self.welcomeWidget) # CSS dock[dockName].setStyleSheet(" \ - QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ ") self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock[dockName]) @@ -51,10 +52,11 @@ class DockArea(QtGui.QMainWindow): dock[dockName].setWidget(self.welcome) #CSS dock[dockName].setStyleSheet(" \ - QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ - ") - self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock[dockName]) - + QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ + ") + self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock[dockName]) + #self.tabifyDockWidget(dock['Notes'],dock['Blank']) self.show() ''' @@ -76,12 +78,14 @@ class DockArea(QtGui.QMainWindow): dock['Tips-' + str(count)].setWidget(self.testWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Tips-' + str(count)]) - self.tabifyDockWidget(dock['Welcome'], dock['Tips-' + str(count)]) + self.tabifyDockWidget( + dock['Welcome'], dock['Tips-' + str(count)]) """ #CSS dock['Tips-'+str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px;\ + width: 200px; height: 150px; } \ ") """ @@ -94,7 +98,8 @@ class DockArea(QtGui.QMainWindow): """ dock['Tips-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['Tips-' + str(count)]) count = count + 1 @@ -104,7 +109,8 @@ class DockArea(QtGui.QMainWindow): """ self.projDir = self.obj_appconfig.current_project["ProjectName"] self.projName = os.path.basename(self.projDir) - #self.project = os.path.join(self.projDir,self.projName) + # self.project = os.path.join(self.projDir,self.projName) + global count self.plottingWidget = QtGui.QWidget() @@ -123,14 +129,16 @@ class DockArea(QtGui.QMainWindow): """ #CSS dock['Plotting-'+str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px;\ + width: 200px; height: 150px; } \ ") """ dock['Plotting-' + str(count)].setVisible(True) dock['Plotting-' + str(count)].setFocus() dock['Plotting-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['Plotting-' + str(count)]) count = count + 1 @@ -164,13 +172,15 @@ class DockArea(QtGui.QMainWindow): # CSS dock['NgSpice-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 0px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray; padding: 0px;\ + width: 200px; height: 150px; } \ ") dock['NgSpice-' + str(count)].setVisible(True) dock['NgSpice-' + str(count)].setFocus() dock['NgSpice-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['NgSpice-' + str(count)]) count = count + 1 @@ -195,14 +205,16 @@ class DockArea(QtGui.QMainWindow): # CSS dock['Model Editor-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray; \ + padding: 5px; width: 200px; height: 150px; } \ ") dock['Model Editor-' + str(count)].setVisible(True) dock['Model Editor-' + str(count)].setFocus() dock['Model Editor-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['Model Editor-' + str(count)]) count = count + 1 @@ -224,14 +236,16 @@ class DockArea(QtGui.QMainWindow): # CSS dock['kicadToNgspice-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ ") dock['kicadToNgspice-' + str(count)].setVisible(True) dock['kicadToNgspice-' + str(count)].setFocus() dock['kicadToNgspice-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['kicadToNgspice-' + str(count)]) count = count + 1 def subcircuiteditor(self): @@ -255,14 +269,16 @@ class DockArea(QtGui.QMainWindow): # CSS dock['Subcircuit-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ ") dock['Subcircuit-' + str(count)].setVisible(True) dock['Subcircuit-' + str(count)].setFocus() dock['Subcircuit-' + str(count)].raise_() - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['Subcircuit-' + str(count)]) count = count + 1 @@ -287,7 +303,8 @@ class DockArea(QtGui.QMainWindow): # CSS dock['User Manual-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ ") dock['User Manual-' + str(count)].setVisible(True) @@ -320,14 +337,16 @@ class DockArea(QtGui.QMainWindow): # CSS dock['Modelica-' + str(count)].setStyleSheet(" \ - .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ + .QWidget { border-radius: 15px; border: 1px solid gray;\ + padding: 5px; width: 200px; height: 150px; } \ ") - - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']].append( + temp = self.obj_appconfig.current_project['ProjectName'] + self.obj_appconfig.dock_dict[temp].append( dock['Modelica-' + str(count)]) count = count + 1 def closeDock(self): - for dockwidget in self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']]: + temp = self.obj_appconfig.current_project['ProjectName'] + for dockwidget in self.obj_appconfig.dock_dict[temp]: dockwidget.close() diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 677d934a..d53ca8e6 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -16,14 +16,20 @@ class ProjectExplorer(QtGui.QWidget): # CSS self.treewidget.setStyleSheet(" \ - QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \ - QTreeView::branch:has-siblings:!adjoins-item { border-image: url(../../images/vline.png) 0; } \ - QTreeView::branch:has-siblings:adjoins-item { border-image: url(../../images/branch-more.png) 0; } \ - QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(../../images/branch-end.png) 0; } \ + QTreeView { border-radius: 15px; border: 1px solid gray; padding: \ + 5px; width: 200px; height: 150px; } \ + QTreeView::branch:has-siblings:!adjoins-item { border-image:\ + url(../../images/vline.png) 0; } \ + QTreeView::branch:has-siblings:adjoins-item { border-image:\ + url(../../images/branch-more.png) 0; } \ + QTreeView::branch:!has-children:!has-siblings:\ + adjoins-item { border-image: url(../../images/branch-end.png) 0; } \ QTreeView::branch:has-children:!has-siblings:closed, \ - QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(../../images/branch-closed.png); } \ + QTreeView::branch:closed:has-children:has-siblings { border-image:\ + none; image: url(../../images/branch-closed.png); } \ QTreeView::branch:open:has-children:!has-siblings, \ - QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \ + QTreeView::branch:open:has-children:has-siblings { border-image: \ + none; image: url(../../images/branch-open.png); } \ ") for parents, children in list( @@ -34,7 +40,7 @@ class ProjectExplorer(QtGui.QWidget): parentnode = QtGui.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents]) for files in children: - childnode = QtGui.QTreeWidgetItem( + childnode = QtGui.QTreeWidgetItem( # noqa parentnode, [files, os.path.join(parents, files)]) self.window.addWidget(self.treewidget) @@ -50,11 +56,13 @@ class ProjectExplorer(QtGui.QWidget): parentnode = QtGui.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents]) for files in children: - childnode = QtGui.QTreeWidgetItem( + childnode = QtGui.QTreeWidgetItem( # noqa parentnode, [files, os.path.join(parents, files)]) - self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = [ + self.obj_appconfig.proc_dict + [self.obj_appconfig.current_project['ProjectName']] = [ ] - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = [ + self.obj_appconfig.dock_dict + [self.obj_appconfig.current_project['ProjectName']] = [ ] def openMenu(self, position): @@ -99,7 +107,8 @@ class ProjectExplorer(QtGui.QWidget): self.save = QtGui.QPushButton('Save and Exit') self.save.setDisabled(True) self.windowgrid = QtGui.QGridLayout() - if (os.path.isfile(str(self.filePath))) == True: + # if (os.path.isfile(str(self.filePath))) == True: + if (os.path.isfile(str(self.filePath))): self.fopen = open(str(self.filePath), 'r') lines = self.fopen.read() self.text.setText(lines) @@ -113,16 +122,19 @@ class ProjectExplorer(QtGui.QWidget): 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.connect(exit,QtCore.SIGNAL('close()'), self.onQuit) self.textwindow.show() else: self.obj_appconfig.current_project["ProjectName"] = str( self.filePath) - self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = [ + self.obj_appconfig.proc_dict + [self.obj_appconfig.current_project['ProjectName']] = [ ] - if self.obj_appconfig.current_project['ProjectName'] not in self.obj_appconfig.dock_dict: - self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = [ + if self.obj_appconfig.current_project['ProjectName'] \ + not in self.obj_appconfig.dock_dict: + self.obj_appconfig.dock_dict + [self.obj_appconfig.current_project['ProjectName']] = [ ] def enable_save(self): @@ -136,7 +148,7 @@ class ProjectExplorer(QtGui.QWidget): def removeProject(self): self.indexItem = self.treewidget.currentIndex() - filename = str(self.indexItem.data()) + filename = str(self.indexItem.data()) # noqa self.filePath = str( self.indexItem.sibling( self.indexItem.row(), @@ -153,7 +165,7 @@ class ProjectExplorer(QtGui.QWidget): def refreshProject(self): self.indexItem = self.treewidget.currentIndex() - filename = str(self.indexItem.data()) + filename = str(self.indexItem.data()) # noqa self.filePath = str( self.indexItem.sibling( self.indexItem.row(), @@ -165,7 +177,7 @@ class ProjectExplorer(QtGui.QWidget): for items in self.treewidget.selectedItems(): items.removeChild(items.child(0)) for files in filelistnew: - childnode = QtGui.QTreeWidgetItem( + childnode = QtGui.QTreeWidgetItem( # noqa parentnode, [ files, os.path.join( self.filePath, files)]) diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index ddad7f5a..7bc74deb 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -1,4 +1,4 @@ -#========================================================================= +# ========================================================================= # # FILE: Workspace.py # @@ -14,7 +14,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 05 February 2015 # REVISION: --- -#========================================================================= +# ========================================================================= from PyQt4 import QtCore, QtGui from configuration.Appconfig import Appconfig import time @@ -34,7 +34,7 @@ class Workspace(QtGui.QWidget): self.initWorkspace() def initWorkspace(self): - #print "Calling workspace" + # print "Calling workspace" self.mainwindow = QtGui.QVBoxLayout() self.split = QtGui.QSplitter() @@ -100,10 +100,12 @@ class Workspace(QtGui.QWidget): self.obj_appconfig.print_info('Workspace : ' + self.create_workspace) # Checking if Workspace already exist or not if os.path.isdir(self.create_workspace): - self.obj_appconfig.default_workspace["workspace"] = self.create_workspace + self.obj_appconfig.default_workspace["workspace"] \ + = self.create_workspace else: os.mkdir(self.create_workspace) - self.obj_appconfig.default_workspace["workspace"] = self.create_workspace + self.obj_appconfig.default_workspace["workspace"] \ + = self.create_workspace self.imp_var = 1 self.close() var_appView.show() |