summaryrefslogtreecommitdiff
path: root/src/ngspiceSimulation/NgspiceWidget.py
diff options
context:
space:
mode:
authorRahul P2020-08-08 19:16:28 +0530
committerGitHub2020-08-08 19:16:28 +0530
commit8255c72075ab3541e8b6cfa7facb4e016157a905 (patch)
treee86226cc6a609e54133b527ad71912996360722b /src/ngspiceSimulation/NgspiceWidget.py
parent175208c2553bde875968a9bc53176b6039ba9360 (diff)
parent7871e58975d75eb2b02928f7a48d29113bebeb2b (diff)
downloadeSim-8255c72075ab3541e8b6cfa7facb4e016157a905.tar.gz
eSim-8255c72075ab3541e8b6cfa7facb4e016157a905.tar.bz2
eSim-8255c72075ab3541e8b6cfa7facb4e016157a905.zip
Merge pull request #156 from rahulp13/master
ported GUI to PyQt5; platform independent paths; launch ngspice through mintty on Win OS
Diffstat (limited to 'src/ngspiceSimulation/NgspiceWidget.py')
-rw-r--r--src/ngspiceSimulation/NgspiceWidget.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/ngspiceSimulation/NgspiceWidget.py b/src/ngspiceSimulation/NgspiceWidget.py
index a963c51f..ea64893b 100644
--- a/src/ngspiceSimulation/NgspiceWidget.py
+++ b/src/ngspiceSimulation/NgspiceWidget.py
@@ -1,28 +1,45 @@
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtCore
from configuration.Appconfig import Appconfig
-import platform
+from configparser import ConfigParser
import os
# This Class creates NgSpice Window
-class NgspiceWidget(QtGui.QWidget):
+class NgspiceWidget(QtWidgets.QWidget):
def __init__(self, command, projPath):
"""
- Creates constructor for NgspiceWidget class.
- - Checks whether OS is linux or windows
- and creates NgSpice window accordingly.
+ - Checks whether OS is Linux or Windows and
+ creates Ngspice window accordingly.
"""
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
self.process = QtCore.QProcess(self)
- self.terminal = QtGui.QWidget(self)
- self.layout = QtGui.QVBoxLayout(self)
+ self.terminal = QtWidgets.QWidget(self)
+ self.layout = QtWidgets.QVBoxLayout(self)
self.layout.addWidget(self.terminal)
print("Argument to ngspice command : ", command)
- # For Linux OS
- if platform.system() == 'Linux':
+
+ if os.name == 'nt': # For Windows OS
+ home = os.path.expanduser("~")
+
+ parser_nghdl = ConfigParser()
+ parser_nghdl.read(os.path.join(
+ home, os.path.join('.nghdl', 'config.ini')))
+
+ msys_bin = parser_nghdl.get('COMPILER', 'MSYS_HOME')
+
+ tempdir = os.getcwd()
+ projPath = self.obj_appconfig.current_project["ProjectName"]
+ os.chdir(projPath)
+ self.command = 'cmd /c '+'"start /min ' + \
+ msys_bin + "/mintty.exe ngspice " + command + '"'
+ self.process.start(self.command)
+ os.chdir(tempdir)
+
+ else: # For Linux OS
self.command = "cd " + projPath + ";ngspice " + command
# Creating argument for process
self.args = ['-hold', '-e', self.command]
@@ -34,12 +51,3 @@ class NgspiceWidget(QtGui.QWidget):
[self.obj_appconfig.current_project['ProjectName']].append(
self.process.pid())
)
-
- # For Windows OS
- elif platform.system() == 'Windows':
- tempdir = os.getcwd()
- projPath = self.obj_appconfig.current_project["ProjectName"]
- os.chdir(projPath)
- self.command = "ngspice " + command
- self.process.start(self.command)
- os.chdir(tempdir)