summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontEnd/Application.py32
-rw-r--r--src/frontEnd/Workspace.py12
-rw-r--r--src/kicadtoNgspice/DeviceModel.py9
-rw-r--r--src/kicadtoNgspice/SubcircuitTab.py27
-rw-r--r--src/modelEditor/ModelEditor.py126
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py2
-rw-r--r--src/ngspiceSimulation/pythonPlotting.py48
-rw-r--r--src/ngspicetoModelica/ModelicaUI.py12
-rw-r--r--src/projManagement/Worker.py7
-rw-r--r--src/projManagement/newProject.py3
-rw-r--r--src/projManagement/openProject.py9
-rw-r--r--src/subcircuit/Subcircuit.py13
-rw-r--r--src/subcircuit/openSub.py12
-rw-r--r--src/subcircuit/uploadSub.py15
14 files changed, 239 insertions, 88 deletions
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)