diff options
Diffstat (limited to 'src/subcircuit')
-rw-r--r-- | src/subcircuit/Subcircuit.py | 37 | ||||
-rw-r--r-- | src/subcircuit/convertSub.py | 35 | ||||
-rw-r--r-- | src/subcircuit/newSub.py | 58 | ||||
-rw-r--r-- | src/subcircuit/openSub.py | 13 |
4 files changed, 82 insertions, 61 deletions
diff --git a/src/subcircuit/Subcircuit.py b/src/subcircuit/Subcircuit.py index bf7481eb..259ae40a 100644 --- a/src/subcircuit/Subcircuit.py +++ b/src/subcircuit/Subcircuit.py @@ -5,31 +5,34 @@ from subcircuit.newSub import NewSub from subcircuit.openSub import openSub from subcircuit.convertSub import convertSub + class Subcircuit(QtGui.QWidget): """ This class creates Subcircuit GUI. """ - def __init__(self,parent=None): + + def __init__(self, parent=None): super(Subcircuit, self).__init__() QtGui.QWidget.__init__(self) - self.obj_appconfig=Appconfig() - self.obj_validation=Validation() - self.obj_dockarea=parent + self.obj_appconfig = Appconfig() + self.obj_validation = Validation() + self.obj_dockarea = parent self.layout = QtGui.QVBoxLayout() - self.splitter= QtGui.QSplitter() + self.splitter = QtGui.QSplitter() self.splitter.setOrientation(QtCore.Qt.Vertical) self.newbtn = QtGui.QPushButton('New Subcircuit Schematic') self.newbtn.setToolTip('<b>To create new Subcircuit Schematic</b>') - self.newbtn.setFixedSize(200,40) + self.newbtn.setFixedSize(200, 40) self.newbtn.clicked.connect(self.newsch) self.editbtn = QtGui.QPushButton('Edit Subcircuit Schematic') self.editbtn.setToolTip('<b>To edit existing Subcircuit Schematic</b>') - self.editbtn.setFixedSize(200,40) + self.editbtn.setFixedSize(200, 40) self.editbtn.clicked.connect(self.editsch) self.convertbtn = QtGui.QPushButton('Convert Kicad to Ngspice') - self.convertbtn.setToolTip('<b>To convert Subcircuit Kicad Netlist to Ngspice Netlist</b>') - self.convertbtn.setFixedSize(200,40) + self.convertbtn.setToolTip( + '<b>To convert Subcircuit Kicad Netlist to Ngspice Netlist</b>') + self.convertbtn.setFixedSize(200, 40) self.convertbtn.clicked.connect(self.convertsch) self.hbox = QtGui.QHBoxLayout() @@ -41,25 +44,25 @@ class Subcircuit(QtGui.QWidget): self.vbox = QtGui.QVBoxLayout() self.vbox.addLayout(self.hbox) self.vbox.addStretch(1) - + self.setLayout(self.vbox) self.show() - + def newsch(self): - text,ok = QtGui.QInputDialog.getText(self, 'New Schematic','Enter Schematic Name:') + text, ok = QtGui.QInputDialog.getText( + self, 'New Schematic', 'Enter Schematic Name:') if ok: self.schematic_name = (str(text)) self.subcircuit = NewSub() self.subcircuit.createSubcircuit(self.schematic_name) - + else: print("Sub circuit creation cancelled") - - + def editsch(self): self.obj_opensubcircuit = openSub() self.obj_opensubcircuit.body() - + def convertsch(self): self.obj_convertsubcircuit = convertSub(self.obj_dockarea) - self.obj_convertsubcircuit.createSub()
\ No newline at end of file + self.obj_convertsubcircuit.createSub() diff --git a/src/subcircuit/convertSub.py b/src/subcircuit/convertSub.py index ca1d1a4f..23e6d52b 100644 --- a/src/subcircuit/convertSub.py +++ b/src/subcircuit/convertSub.py @@ -3,39 +3,42 @@ from projManagement.Validation import Validation from configuration.Appconfig import Appconfig import os + class convertSub(QtGui.QWidget): """ This class is called when User create new Project. """ - - def __init__(self,dockarea): + + def __init__(self, dockarea): super(convertSub, self).__init__() self.obj_validation = Validation() - self.obj_appconfig=Appconfig() - self.obj_dockarea=dockarea - + self.obj_appconfig = Appconfig() + self.obj_dockarea = dockarea + def createSub(self): """ This function create command to call kicad to Ngspice converter. """ print("Openinig Kicad-to-Ngspice converter from Subcircuit Module") self.projDir = self.obj_appconfig.current_subcircuit["SubcircuitName"] - #Validating if current project is available or not + # Validating if current project is available or not if self.obj_validation.validateKicad(self.projDir): - #Checking if project has .cir file or not + # Checking if project has .cir file or not if self.obj_validation.validateCir(self.projDir): #print "CIR file present" self.projName = os.path.basename(self.projDir) - self.project = os.path.join(self.projDir,self.projName) - - var1=self.project+".cir" - var2="sub" - self.obj_dockarea.kicadToNgspiceEditor(var1,var2) + self.project = os.path.join(self.projDir, self.projName) + + var1 = self.project + ".cir" + var2 = "sub" + self.obj_dockarea.kicadToNgspiceEditor(var1, var2) else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('The subcircuit does not contain any Kicad netlist file for conversion.') - self.msg.setWindowTitle("Error Message") + self.msg.showMessage( + 'The subcircuit does not contain any Kicad netlist file for conversion.') + self.msg.setWindowTitle("Error Message") else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('Please select the subcircuit first. You can either create new subcircuit or open existing subcircuit') - self.msg.setWindowTitle("Error Message")
\ No newline at end of file + self.msg.showMessage( + 'Please select the subcircuit first. You can either create new subcircuit or open existing subcircuit') + self.msg.setWindowTitle("Error Message") diff --git a/src/subcircuit/newSub.py b/src/subcircuit/newSub.py index 229c3f46..6e0c7e63 100644 --- a/src/subcircuit/newSub.py +++ b/src/subcircuit/newSub.py @@ -1,65 +1,77 @@ -from PyQt4 import QtGui,QtCore +from PyQt4 import QtGui, QtCore from projManagement.Validation import Validation from configuration.Appconfig import Appconfig from projManagement import Worker import os + class NewSub(QtGui.QWidget): """ This class is called when User create new Project. """ - + def __init__(self): super(NewSub, self).__init__() self.obj_validation = Validation() self.obj_appconfig = Appconfig() - - def createSubcircuit(self,subName): + def createSubcircuit(self, subName): """ This function create Subcircuit related directories and files """ self.create_schematic = subName - #Checking if Workspace already exist or not - self.schematic_path = (os.path.join(os.path.abspath('..'),'SubcircuitLibrary',self.create_schematic)) - - #Validation for new subcircuit + # Checking if Workspace already exist or not + self.schematic_path = ( + os.path.join( + os.path.abspath('..'), + 'SubcircuitLibrary', + self.create_schematic)) + + # Validation for new subcircuit if self.schematic_path == "": self.reply = "NONE" else: - self.reply = self.obj_validation.validateNewproj(str(self.schematic_path)) - - #Checking Validations Response + self.reply = self.obj_validation.validateNewproj( + str(self.schematic_path)) + + # Checking Validations Response if self.reply == "VALID": print("Validated : Creating subcircuit directory") try: os.mkdir(self.schematic_path) - self.schematic = os.path.join(self.schematic_path,self.create_schematic) - self.cmd = "eeschema "+self.schematic+".sch" + self.schematic = os.path.join( + self.schematic_path, self.create_schematic) + self.cmd = "eeschema " + self.schematic + ".sch" self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() self.close() - except: + except BaseException: #print "Some Thing Went Wrong" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('Unable to create subcircuit. Please make sure you have write permission on '+self.schematic_path) + self.msg.showMessage( + 'Unable to create subcircuit. Please make sure you have write permission on ' + + self.schematic_path) self.msg.setWindowTitle("Error Message") - - self.obj_appconfig.current_subcircuit['SubcircuitName'] = self.schematic_path - + + self.obj_appconfig.current_subcircuit['SubcircuitName'] = self.schematic_path + elif self.reply == "CHECKEXIST": #print "Project already exist" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('The subcircuit "'+self.create_schematic+'" already exist.Please select the different name or delete existing subcircuit') + self.msg.showMessage( + 'The subcircuit "' + + self.create_schematic + + '" already exist.Please select the different name or delete existing subcircuit') self.msg.setWindowTitle("Error Message") - + elif self.reply == "CHECKNAME": #print "Name is not proper" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('The subcircuit name should not contain space between them') + self.msg.showMessage( + 'The subcircuit name should not contain space between them') self.msg.setWindowTitle("Error Message") - + elif self.reply == "NONE": self.msg = QtGui.QErrorMessage(self) self.msg.showMessage('The subcircuit name cannot be empty') - self.msg.setWindowTitle("Error Message")
\ No newline at end of file + self.msg.setWindowTitle("Error Message") diff --git a/src/subcircuit/openSub.py b/src/subcircuit/openSub.py index fb349f0a..32ad5d39 100644 --- a/src/subcircuit/openSub.py +++ b/src/subcircuit/openSub.py @@ -8,17 +8,20 @@ class openSub(QtGui.QWidget): """ This class is called when User click on Open Project Button """ + def __init__(self): super(openSub, self).__init__() self.obj_appconfig = Appconfig() - + def body(self): - self.editfile = str(QtGui.QFileDialog.getExistingDirectory(None,"Open File","../SubcircuitLibrary")) + self.editfile = str( + QtGui.QFileDialog.getExistingDirectory( + None, "Open File", "../SubcircuitLibrary")) if self.editfile: self.obj_Appconfig = Appconfig() self.obj_Appconfig.current_subcircuit['SubcircuitName'] = self.editfile self.schname = os.path.basename(self.editfile) - self.editfile = os.path.join(self.editfile,self.schname) - self.cmd = "eeschema "+self.editfile+".sch " + self.editfile = os.path.join(self.editfile, self.schname) + self.cmd = "eeschema " + self.editfile + ".sch " self.obj_workThread = WorkerThread(self.cmd) - self.obj_workThread.start()
\ No newline at end of file + self.obj_workThread.start() |