diff options
-rw-r--r-- | CONTRIBUTION.md | 2 | ||||
-rw-r--r-- | README.md | 40 | ||||
-rw-r--r-- | library/browser/welcome.html | 1 | ||||
-rw-r--r-- | library/kicadLibrary/template/kicad.pro | 1 | ||||
-rw-r--r-- | src/frontEnd/Application.py | 32 | ||||
-rw-r--r-- | src/frontEnd/Workspace.py | 12 | ||||
-rw-r--r-- | src/kicadtoNgspice/DeviceModel.py | 9 | ||||
-rw-r--r-- | src/kicadtoNgspice/SubcircuitTab.py | 27 | ||||
-rw-r--r-- | src/modelEditor/ModelEditor.py | 126 | ||||
-rw-r--r-- | src/ngspiceSimulation/NgspiceWidget.py | 2 | ||||
-rw-r--r-- | src/ngspiceSimulation/pythonPlotting.py | 48 | ||||
-rw-r--r-- | src/ngspicetoModelica/ModelicaUI.py | 12 | ||||
-rw-r--r-- | src/projManagement/Worker.py | 7 | ||||
-rw-r--r-- | src/projManagement/newProject.py | 3 | ||||
-rw-r--r-- | src/projManagement/openProject.py | 9 | ||||
-rw-r--r-- | src/subcircuit/Subcircuit.py | 13 | ||||
-rw-r--r-- | src/subcircuit/openSub.py | 12 | ||||
-rw-r--r-- | src/subcircuit/uploadSub.py | 15 |
18 files changed, 263 insertions, 108 deletions
diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index a46bf859..ce6338b7 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -4,7 +4,7 @@ If you want to add any enhancement feature or have found any bug and want to wor #### Points on how to make pull request * You need to fork this repository to your account. -* Clone it using ``` git clone https://github.com/[username]/eSim.git ``` +* Clone it using ``` git clone https://github.com/FOSSEE/eSim.git ``` * Always create a new branch before making any changes. You can create new branch using ```git branch <branch-name> ``` @@ -1,13 +1,26 @@ +![GitHub release (latest by date)](https://img.shields.io/github/v/release/fossee/esim?color=blueviolet) +![GitHub](https://img.shields.io/github/license/fossee/esim?color=blue) +![Python](https://img.shields.io/badge/python-v3.6+-blue.svg) +[![PEP8](https://img.shields.io/badge/code%20style-pep8-orange.svg)](https://www.python.org/dev/peps/pep-0008/) +![Travis (.org)](https://img.shields.io/travis/fossee/esim) +[![Documentation Status](https://readthedocs.org/projects/esim/badge/?version=latest)](https://esim.readthedocs.io/en/latest/?badge=latest) +[![GitHub forks](https://img.shields.io/github/forks/fossee/esim)](https://github.com/fossee/esim/network) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/fossee/esim) +![GitHub contributors](https://img.shields.io/github/contributors/fossee/esim) + ## eSim [eSim](https://esim.fossee.in/) is an open source EDA tool for circuit design, simulation, analysis and PCB design, developed by [FOSSEE Team](https://www.fossee.in/) at [IIT Bombay](http://www.iitb.ac.in/). It is an integrated tool build using open source softwares such as KiCad, Ngspice and GHDL. -## Releases +## Releases and Installation +eSim is released for the following distributions (operating systems): * Ubuntu 16.04 OS and above LTS versions. * Microsoft Windows 7, 8 and 10. -> Note: Refer [`installers`](https://github.com/fossee/eSim/tree/installers) branch for documentation on packaging for above mentioned platforms. +To use eSim on your machine having above distributions, please refer to link [here](https://esim.fossee.in/downloads) for installation and other guidelines. + +> Note for other distributions: You can refer [`installers`](https://github.com/fossee/eSim/tree/installers) branch for documentation on packaging (for above mentioned distributions) to build installers for your operating system in a similar way. For providing your build, please check the `Contribution` section mentioned below. ## Features * An open-source EDA tool. @@ -20,28 +33,17 @@ It is an integrated tool build using open source softwares such as KiCad, Ngspic ## Open-Source Softwares Used * [Python](https://www.python.org/) -* [KiCad](http://www.kicad-pcd.org) -* [Ngspice](http://ngspice.sourcefouge.net/) -* [GHDL](http://ghdl.free.fr/) - -## Pre-requisites -1. Python v3.5+ -2. Ngspice v31+ -3. KiCad v4.0.7 -4. [NGHDL](https://github.com/fossee/nghdl) - -## eSim Installation: - -To use eSim on your machine please refer to link [here](https://esim.fossee.in/downloads) for installation and other guidelines. +* [KiCad](https://kicad.org/) +* [NGHDL](https://github.com/fossee/nghdl) ## eSim Manual -To know everything about eSim, how it works and it's feature please download manual [here](https://static.fossee.in/esim/installation-files/eSim_Manual_2.0.pdf) +To know everything about eSim, how it works and it's feature please download manual [here](https://static.fossee.in/esim/manuals/eSim_Manual_2020_August.pdf) ## Contact -For any queries regarding eSim please write us on at this [address](mailto:contact-esim@fossee.in). +For any queries regarding eSim please write us on at this [email address](mailto:contact-esim@fossee.in). ## Contribution -Please refer [here](https://github.com/FOSSEE/eSim/tree/master/CONTRIBUTION.md) for further details. +Please refer [here](https://github.com/FOSSEE/eSim/blob/master/CONTRIBUTION.md) for further details. ## License -It is developed by FOSSEE Team at IIT Bombay. It is released under GNU GPL License. +It is developed by FOSSEE Team at IIT Bombay and is released under GNU GPL License. diff --git a/library/browser/welcome.html b/library/browser/welcome.html index f1300f49..c438194e 100644 --- a/library/browser/welcome.html +++ b/library/browser/welcome.html @@ -20,6 +20,7 @@ p{ margin: 0px 10px 0px 10px; + font-size: 13pt; } pre{ diff --git a/library/kicadLibrary/template/kicad.pro b/library/kicadLibrary/template/kicad.pro index f63b751e..0d4f13cb 100644 --- a/library/kicadLibrary/template/kicad.pro +++ b/library/kicadLibrary/template/kicad.pro @@ -67,3 +67,4 @@ LibName33=eSim_Miscellaneous LibName34=eSim_Power LibName35=eSim_Sources LibName36=eSim_Subckt +LibName37=eSim_Nghdl diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 44616ab7..94bce4ae 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -13,7 +13,7 @@ # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Saturday 01 August 2020 +# REVISION: Sunday 13 December 2020 # ========================================================================= import os @@ -293,13 +293,20 @@ class Application(QtWidgets.QMainWindow): text, ok = QtWidgets.QInputDialog.getText( self, 'New Project Info', 'Enter Project Name:' ) + updated = False + if ok: self.projname = (str(text)) self.project = NewProjectInfo() directory, filelist = self.project.createProject(self.projname) - self.obj_Mainview.obj_projectExplorer.addTreeNode( - directory, filelist) - else: + + if directory and filelist: + self.obj_Mainview.obj_projectExplorer.addTreeNode( + directory, filelist + ) + updated = True + + if not updated: print("No new project created") self.obj_appconfig.print_info('No new project created') try: @@ -532,16 +539,27 @@ class Application(QtWidgets.QMainWindow): break except Exception: pass - time.sleep(0.5) + time.sleep(1) # Fail Safe ===> count += 1 if count >= 10: - raise Exception( + print( "Ngspice taking too long for simulation. " "Check netlist file to change simulation parameters." ) + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Ngspice taking too long for simulation. ' + 'Check netlist file to change simulation parameters.' + ) + self.msg.exec_() + + return + # Calling Python Plotting try: self.obj_Mainview.obj_dockarea.plottingEditor() @@ -703,7 +721,7 @@ class Application(QtWidgets.QMainWindow): 'Please select the project first. ' + 'You can either create a new project or open existing project' ) - self.exec_() + self.msg.exec_() def open_OMoptim(self): """ diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 0a80d357..4d033539 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -13,7 +13,7 @@ # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Wednesday 05 February 2015 -# REVISION: Saturday 25 July 2020 +# REVISION: Sunday 13 December 2020 # ========================================================================= from PyQt5 import QtCore, QtGui, QtWidgets @@ -172,7 +172,11 @@ class Workspace(QtWidgets.QWidget): def browseLocation(self): print("Function : Browse Location") - self.workspace_directory = QtWidgets.QFileDialog.getExistingDirectory( - self, "Browse Location", os.path.expanduser("~") + self.workspace_directory = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getExistingDirectory( + self, "Browse Location", os.path.expanduser("~") + ) ) - self.workspace_loc.setText(self.workspace_directory) + + if self.workspace_directory: + self.workspace_loc.setText(self.workspace_directory) diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 1c77cabc..5fd4d829 100644 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -1,4 +1,4 @@ -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtCore import os from xml.etree import ElementTree as ET from . import TrackWidget @@ -368,10 +368,15 @@ class DeviceModel(QtWidgets.QWidget): if os.name == 'nt': init_path = '' - self.libfile = QtWidgets.QFileDialog.getOpenFileName( + self.libfile = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getOpenFileName( self, "Open Library Directory", init_path + "library/deviceModelLibrary", "*.lib" )[0] + ) + + if not self.libfile: + return # Setting Library to Text Edit Line self.entry_var[self.widgetObjCount].setText(self.libfile) diff --git a/src/kicadtoNgspice/SubcircuitTab.py b/src/kicadtoNgspice/SubcircuitTab.py index 4c7179d3..6b98167d 100644 --- a/src/kicadtoNgspice/SubcircuitTab.py +++ b/src/kicadtoNgspice/SubcircuitTab.py @@ -1,4 +1,4 @@ -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtCore from . import TrackWidget from projManagement import Validation import os @@ -151,26 +151,36 @@ class SubcircuitTab(QtWidgets.QWidget): init_path = '' self.subfile = str( - QtWidgets.QFileDialog.getExistingDirectory( - self, "Open Subcircuit", - init_path + "library/SubcircuitLibrary") + QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getExistingDirectory( + self, "Open Subcircuit", + init_path + "library/SubcircuitLibrary" + ) ) + ) + + if not self.subfile: + return + self.reply = self.obj_validation.validateSub( - self.subfile, self.numPorts[self.widgetObjCount - 1]) + self.subfile, self.numPorts[self.widgetObjCount - 1] + ) + if self.reply == "True": # Setting Library to Text Edit Line self.entry_var[self.widgetObjCount].setText(self.subfile) self.subName = self.subDetail[self.widgetObjCount] # Storing to track it during conversion - self.obj_trac.subcircuitTrack[self.subName] = self.subfile + elif self.reply == "PORT": self.msg = QtWidgets.QErrorMessage(self) self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( - "Please select a Subcircuit with correct number of ports.") + "Please select a Subcircuit with correct number of ports." + ) self.msg.exec_() elif self.reply == "DIREC": self.msg = QtWidgets.QErrorMessage(self) @@ -178,7 +188,8 @@ class SubcircuitTab(QtWidgets.QWidget): self.msg.setWindowTitle("Error Message") self.msg.showMessage( "Please select a valid Subcircuit directory " - "(Containing '.sub' file).") + "(Containing '.sub' file)." + ) self.msg.exec_() def trackSubcircuitWithoutButton(self, iter_value, path_value): diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index bf5687a7..cddcc78f 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -129,8 +129,20 @@ class ModelEditorclass(QtWidgets.QWidget): # Opens new dialog box text, ok = QtWidgets.QInputDialog.getText( - self, 'New Model', 'Enter Model Name:') + self, 'New Model', 'Enter Model Name:' + ) + if ok: + if not text: + print("Model name cannot be empty") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('The model name cannot be empty') + msg.exec_() + return + self.newflag = 1 self.diode.setDisabled(False) self.bjt.setDisabled(False) @@ -140,7 +152,7 @@ class ModelEditorclass(QtWidgets.QWidget): self.magnetic.setDisabled(False) self.modelname = (str(text)) else: - pass + return # Validate if the file created exists already or not # Show error accordingly @@ -327,12 +339,15 @@ class ModelEditorclass(QtWidgets.QWidget): self.bjt.setDisabled(True) self.magnetic.setDisabled(True) try: - self.editfile = QtWidgets.QFileDialog.getOpenFileName( - self, "Open Library Directory", - self.init_path + "library/deviceModelLibrary", "*.lib" - )[0] - - self.createtable(self.editfile) + self.editfile = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getOpenFileName( + self, "Open Library Directory", + self.init_path + "library/deviceModelLibrary", "*.lib" + )[0] + ) + + if self.editfile: + self.createtable(self.editfile) except BaseException: print("No File selected for edit") @@ -422,30 +437,50 @@ class ModelEditorclass(QtWidgets.QWidget): - text1 => parameter, text2 => value ''' text1, ok = QtWidgets.QInputDialog.getText( - self, 'Parameter', 'Enter Parameter') + self, 'Parameter', 'Enter Parameter' + ) if ok: - if text1 in list(self.modeldict.keys()): + if not text1: + print("Parameter name cannot be empty") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('The parameter name cannot be empty') + msg.exec_() + return + elif text1 in list(self.modeldict.keys()): self.msg = QtWidgets.QErrorMessage(self) self.msg.setModal(True) self.msg.setWindowTitle("Error Message") self.msg.showMessage( - "The paramaeter " + text1 + " is already in the list") + "The paramaeter " + text1 + " is already in the list" + ) self.msg.exec_() return text2, ok = QtWidgets.QInputDialog.getText( - self, 'Value', 'Enter Value') + self, 'Value', 'Enter Value' + ) if ok: + if not text2: + print("Value cannot be empty") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('Value cannot be empty') + msg.exec_() + return + currentRowCount = self.modeltable.rowCount() self.modeltable.insertRow(currentRowCount) self.modeltable.setItem( - currentRowCount, 0, QTableWidgetItem(text1)) + currentRowCount, 0, QTableWidgetItem(text1) + ) self.modeltable.setItem( - currentRowCount, 1, QTableWidgetItem(text2)) + currentRowCount, 1, QTableWidgetItem(text2) + ) self.modeldict[str(text1)] = str(text2) - else: - pass - else: - pass def savemodelfile(self): ''' @@ -676,9 +711,20 @@ class ModelEditorclass(QtWidgets.QWidget): ''' self.savebtn.setDisabled(False) index = self.modeltable.currentIndex() - remove_item = self.modeltable.item(index.row(), 0).text() - self.modeltable.removeRow(index.row()) - del self.modeldict[str(remove_item)] + remove_item = self.modeltable.item(index.row(), 0) + + if remove_item: + remove_item = remove_item.text() + self.modeltable.removeRow(index.row()) + del self.modeldict[str(remove_item)] + else: + print("No parameter selected to remove") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('No parameter selected to remove') + msg.exec_() def converttoxml(self): ''' @@ -696,10 +742,15 @@ class ModelEditorclass(QtWidgets.QWidget): model_dict = {} stringof = [] - self.libfile = QtWidgets.QFileDialog.getOpenFileName( - self, "Open Library Directory", - self.init_path + "library/deviceModelLibrary", "*.lib" - )[0] + self.libfile = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getOpenFileName( + self, "Open Library Directory", + self.init_path + "library/deviceModelLibrary", "*.lib" + )[0] + ) + + if not self.libfile: + return libopen = open(self.libfile) filedata = libopen.read().split() @@ -796,14 +847,25 @@ class ModelEditorclass(QtWidgets.QWidget): savepath = os.path.join(self.savepathtest, 'User Libraries') os.chdir(savepath) text, ok1 = QtWidgets.QInputDialog.getText( - self, 'Model Name', 'Enter Model Library Name') + self, 'Model Name', 'Enter Model Library Name' + ) if ok1: - tree.write(text + ".xml") - fileopen = open(text + ".lib", 'w') - f = open(self.libfile) - fileopen.write(f.read()) - f.close() - fileopen.close() + if not text: + print("Model library name cannot be empty") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('The model library name cannot be empty') + msg.exec_() + else: + tree.write(text + ".xml") + fileopen = open(text + ".lib", 'w') + f = open(self.libfile) + fileopen.write(f.read()) + f.close() + fileopen.close() + os.chdir(defaultcwd) libopen.close() libopen1.close() diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py index ea64893b..8114f56d 100644 --- a/src/ngspiceSimulation/NgspiceWidget.py +++ b/src/ngspiceSimulation/NgspiceWidget.py @@ -35,7 +35,7 @@ class NgspiceWidget(QtWidgets.QWidget): projPath = self.obj_appconfig.current_project["ProjectName"] os.chdir(projPath) self.command = 'cmd /c '+'"start /min ' + \ - msys_bin + "/mintty.exe ngspice " + command + '"' + msys_bin + "/mintty.exe ngspice -p " + command + '"' self.process.start(self.command) os.chdir(tempdir) diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index 8df5c508..615ad02b 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -3,9 +3,9 @@ from __future__ import division # Used for decimal division import os from PyQt5 import QtGui, QtCore, QtWidgets from decimal import Decimal, getcontext -from matplotlib.backends.backend_qt4agg\ +from matplotlib.backends.backend_qt5agg\ import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt4agg\ +from matplotlib.backends.backend_qt5agg\ import NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure from configuration.Appconfig import Appconfig @@ -237,6 +237,7 @@ class plotWindow(QtWidgets.QMainWindow): QtWidgets.QMessageBox.about( self, "Warning!!", "Too Few Arguments/SYNTAX Error!\ \n Refer Examples") + return else: self.warnning.setText("") @@ -252,10 +253,11 @@ class plotWindow(QtWidgets.QMainWindow): if len(a) != len(self.parts) // 2 + 1: QtWidgets.QMessageBox.about( - self, - "Warning!!", + self, "Warning!!", "One of the operands doesn't belong to " - "the above list of Nodes!!") + "the above list of Nodes!!" + ) + return for i in a: self.comboAll.append(self.obj_dataext.y[i]) @@ -271,13 +273,15 @@ class plotWindow(QtWidgets.QMainWindow): "<font color='red'>To Err Is Human!<br>One of the " + "operands doesn't belong to the above list!!</font>" ) + return if self.parts[1] == 'vs': if len(self.parts) > 3: self.warnning.setText("Enter two operands only!!") QtWidgets.QMessageBox.about( - self, "Warning!!", "Recheck the expression syntax!") - + self, "Warning!!", "Recheck the expression syntax!" + ) + return else: self.axes.cla() @@ -300,7 +304,9 @@ class plotWindow(QtWidgets.QMainWindow): elif max(a) >= self.volts_length and min(a) < self.volts_length: QtWidgets.QMessageBox.about( - self, "Warning!!", "Do not combine Voltage and Current!!") + self, "Warning!!", "Do not combine Voltage and Current!!" + ) + return else: for j in range(len(self.comboAll[0])): @@ -312,7 +318,9 @@ class plotWindow(QtWidgets.QMainWindow): finalResult.append(eval(re)) except ArithmeticError: QtWidgets.QMessageBox.about( - self, "Warning!!", "Dividing by zero!!") + self, "Warning!!", "Dividing by zero!!" + ) + return if self.plotType2[0] == 0: # self.setWindowTitle('AC Analysis') @@ -392,7 +400,10 @@ class plotWindow(QtWidgets.QMainWindow): self.axes.grid(True) if boxCheck == 0: QtWidgets.QMessageBox.about( - self, "Warning!!", "Please select at least one Node OR Branch") + self, "Warning!!", "Please select at least one Node OR Branch" + ) + return + self.canvas.draw() def onPush_ac(self): @@ -415,7 +426,10 @@ class plotWindow(QtWidgets.QMainWindow): self.axes.grid(True) if boxCheck == 0: QtWidgets.QMessageBox.about( - self, "Warning!!", "Please select at least one Node OR Branch") + self, "Warning!!", "Please select at least one Node OR Branch" + ) + return + self.canvas.draw() def onPush_trans(self): @@ -438,7 +452,9 @@ class plotWindow(QtWidgets.QMainWindow): self.axes.grid(True) if boxCheck == 0: QtWidgets.QMessageBox.about( - self, "Warning!!", "Please select at least one Node OR Branch") + self, "Warning!!", "Please select at least one Node OR Branch" + ) + return self.canvas.draw() def onPush_dc(self): @@ -462,7 +478,10 @@ class plotWindow(QtWidgets.QMainWindow): self.axes.grid(True) if boxCheck == 0: QtWidgets.QMessageBox.about( - self, "Warning!!", "Please select atleast one Node OR Branch") + self, "Warning!!", "Please select atleast one Node OR Branch" + ) + return + self.canvas.draw() def colorName(self, letter): @@ -507,7 +526,8 @@ class plotWindow(QtWidgets.QMainWindow): if boxCheck == 0: QtWidgets.QMessageBox.about( - self, "Warning!!", "Please select at least one Node OR Branch") + self, "Warning!!", "Please select at least one Node OR Branch" + ) def getRMSValue(self, dataPoints): getcontext().prec = 5 diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py index 8e2479c9..6cd736b7 100644 --- a/src/ngspicetoModelica/ModelicaUI.py +++ b/src/ngspicetoModelica/ModelicaUI.py @@ -45,9 +45,15 @@ class OpenModelicaEditor(QtWidgets.QWidget): self.show() def browseFile(self): - self.ngspiceNetlist = QtWidgets.QFileDialog.getOpenFileName( - self, 'Open Ngspice Netlist', BROWSE_LOCATION)[0] - self.FileEdit.setText(self.ngspiceNetlist) + temp = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getOpenFileName( + self, 'Open Ngspice Netlist', BROWSE_LOCATION + )[0] + ) + + if temp: + self.ngspiceNetlist = temp + self.FileEdit.setText(self.ngspiceNetlist) def callConverter(self): diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index cdad4170..970bfccd 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -13,13 +13,12 @@ # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Sunday 02 August 2020 +# REVISION: Sunday 16 August 2020 # ========================================================================= from PyQt5 import QtCore import subprocess from configuration.Appconfig import Appconfig -import threading class WorkerThread(QtCore.QThread): @@ -53,8 +52,10 @@ class WorkerThread(QtCore.QThread): @return None """ - if threading.active_count() > 1: + try: self.wait() + except BaseException: + pass def get_proc_threads(self): """ diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index ad29dc76..278cfbe3 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -124,6 +124,7 @@ class NewProjectInfo(QtWidgets.QWidget): ' existing project' ) self.msg.exec_() + return None, None elif self.reply == "CHECKNAME": self.msg = QtWidgets.QErrorMessage(self) @@ -132,6 +133,7 @@ class NewProjectInfo(QtWidgets.QWidget): self.msg.showMessage( 'The project name should not contain space between them') self.msg.exec_() + return None, None elif self.reply == "NONE": self.msg = QtWidgets.QErrorMessage(self) @@ -139,6 +141,7 @@ class NewProjectInfo(QtWidgets.QWidget): self.msg.setWindowTitle("Error Message") self.msg.showMessage('The project name cannot be empty') self.msg.exec_() + return None, None def cancelProject(self): self.close() diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 04944d29..c5bc2dec 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -16,7 +16,7 @@ # REVISION: Sunday 26 July 2020 # ========================================================================= -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtCore from .Validation import Validation from configuration.Appconfig import Appconfig import os @@ -45,8 +45,11 @@ class OpenProjectInfo(QtWidgets.QWidget): """ self.obj_Appconfig = Appconfig() self.openDir = self.obj_Appconfig.default_workspace["workspace"] - self.projDir = QtWidgets.QFileDialog.getExistingDirectory( - self, "open", self.openDir) + self.projDir = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getExistingDirectory( + self, "open", self.openDir + ) + ) if self.obj_validation.validateOpenproj(self.projDir): self.obj_Appconfig.current_project['ProjectName'] = str( diff --git a/src/subcircuit/Subcircuit.py b/src/subcircuit/Subcircuit.py index 298ff96e..eb06e145 100644 --- a/src/subcircuit/Subcircuit.py +++ b/src/subcircuit/Subcircuit.py @@ -64,8 +64,19 @@ class Subcircuit(QtWidgets.QWidget): def newsch(self): text, ok = QtWidgets.QInputDialog.getText( - self, 'New Schematic', 'Enter Schematic Name:') + self, 'New Schematic', 'Enter Schematic Name:' + ) if ok: + if not text: + print("Schematic name cannot be empty") + print("==================") + msg = QtWidgets.QErrorMessage(self) + msg.setModal(True) + msg.setWindowTitle("Error Message") + msg.showMessage('The schematic name cannot be empty') + msg.exec_() + return + self.schematic_name = (str(text)) self.subcircuit = NewSub() self.subcircuit.createSubcircuit(self.schematic_name) diff --git a/src/subcircuit/openSub.py b/src/subcircuit/openSub.py index 63597661..f98fe69f 100644 --- a/src/subcircuit/openSub.py +++ b/src/subcircuit/openSub.py @@ -1,7 +1,7 @@ -from PyQt5 import QtWidgets +import os +from PyQt5 import QtWidgets, QtCore from configuration.Appconfig import Appconfig from projManagement.Worker import WorkerThread -import os # This class is called when User clicks on Edit Subcircuit Button. @@ -21,8 +21,12 @@ class openSub(QtWidgets.QWidget): if os.name == 'nt': init_path = '' - self.editfile = QtWidgets.QFileDialog.getExistingDirectory( - None, "Open File", init_path + "library/SubcircuitLibrary") + self.editfile = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getExistingDirectory( + None, "Open File", init_path + "library/SubcircuitLibrary" + ) + ) + if self.editfile: self.obj_Appconfig = Appconfig() self.obj_Appconfig.current_subcircuit['SubcircuitName'] \ diff --git a/src/subcircuit/uploadSub.py b/src/subcircuit/uploadSub.py index 13924bf3..5ae50df8 100644 --- a/src/subcircuit/uploadSub.py +++ b/src/subcircuit/uploadSub.py @@ -1,4 +1,4 @@ -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtCore from configuration.Appconfig import Appconfig from projManagement.Validation import Validation import os @@ -20,7 +20,7 @@ class UploadSub(QtWidgets.QWidget): def upload(self): """ - This method opens a dialogue box when Upload subcircuit button is + This method opens a dialog box when Upload subcircuit button is clicked and after entering folder name, it opens directory system to chose file for folder, it only shows file with extension .sub and with the name of project entered earlier as folder name. @@ -30,11 +30,14 @@ class UploadSub(QtWidgets.QWidget): true if file has valid format or else it shows an error message. """ - editfile = QtWidgets.QFileDialog.getOpenFileName( - None, "Upload Subcircuit File", os.path.expanduser("~"), "*.sub" - )[0] + editfile = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getOpenFileName( + None, "Upload Subcircuit File", + os.path.expanduser("~"), "*.sub" + )[0] + ) - if editfile == '': + if not editfile: return upload = os.path.basename(editfile) |