summaryrefslogtreecommitdiff
path: root/src/createKicadLibrary.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/createKicadLibrary.py')
-rw-r--r--src/createKicadLibrary.py42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/createKicadLibrary.py b/src/createKicadLibrary.py
index 2b3e7d7..e98d0d0 100644
--- a/src/createKicadLibrary.py
+++ b/src/createKicadLibrary.py
@@ -2,13 +2,14 @@ from Appconfig import Appconfig
import re
import os
import xml.etree.cElementTree as ET
-from PyQt4 import QtGui
+from PyQt5 import QtWidgets
-class AutoSchematic(QtGui.QWidget):
+class AutoSchematic(QtWidgets.QWidget):
- def __init__(self, modelname):
- QtGui.QWidget.__init__(self)
+ def __init__(self, parent, modelname):
+ QtWidgets.QWidget.__init__(self)
+ self.parent = parent
self.modelname = modelname.split('.')[0]
self.template = Appconfig.kicad_lib_template.copy()
self.xml_loc = Appconfig.xml_loc
@@ -16,7 +17,8 @@ class AutoSchematic(QtGui.QWidget):
if os.name == 'nt':
eSim_src = Appconfig.src_home
inst_dir = eSim_src.replace('\eSim', '')
- self.kicad_nghdl_lib = inst_dir + '/KiCad/share/kicad/library/eSim_Nghdl.lib'
+ self.kicad_nghdl_lib = \
+ inst_dir + '/KiCad/share/kicad/library/eSim_Nghdl.lib'
else:
self.kicad_nghdl_lib = '/usr/share/kicad/library/eSim_Nghdl.lib'
self.parser = Appconfig.parser_nghdl
@@ -33,14 +35,14 @@ class AutoSchematic(QtGui.QWidget):
self.createLib()
elif (xmlFound == os.path.join(self.xml_loc, 'Nghdl')):
print('Library already exists...')
- ret = QtGui.QMessageBox.warning(
- self, "Warning", '''<b>Library files for this model ''' +
+ ret = QtWidgets.QMessageBox.warning(
+ self.parent, "Warning", '''<b>Library files for this model ''' +
'''already exist. Do you want to overwrite it?</b><br/>
If yes press ok, else cancel it and ''' +
'''change the name of your vhdl file.''',
- QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel
+ QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel
)
- if ret == QtGui.QMessageBox.Ok:
+ if ret == QtWidgets.QMessageBox.Ok:
print("Overwriting existing libraries")
self.getPortInformation()
self.createXML()
@@ -51,11 +53,11 @@ class AutoSchematic(QtGui.QWidget):
quit()
else:
print('Pre existing library...')
- ret = QtGui.QMessageBox.critical(
- self, "Error", '''<b>A standard library already exists ''' +
+ ret = QtWidgets.QMessageBox.critical(
+ self.parent, "Error", '''<b>A standard library already exists ''' +
'''with this name.</b><br/><b>Please change the name ''' +
'''of your vhdl file and upload it again</b>''',
- QtGui.QMessageBox.Ok
+ QtWidgets.QMessageBox.Ok
)
# quit()
@@ -82,17 +84,17 @@ class AutoSchematic(QtGui.QWidget):
ET.SubElement(root, "type").text = "Nghdl"
ET.SubElement(root, "node_number").text = str(len(self.portInfo))
ET.SubElement(root, "title").text = (
- "Add parameters for " + str(self.modelname))
+ "Add parameters for " + str(self.modelname))
ET.SubElement(root, "split").text = self.splitText
param = ET.SubElement(root, "param")
ET.SubElement(param, "rise_delay", default="1.0e-9").text = (
- "Enter Rise Delay (default=1.0e-9)")
+ "Enter Rise Delay (default=1.0e-9)")
ET.SubElement(param, "fall_delay", default="1.0e-9").text = (
- "Enter Fall Delay (default=1.0e-9)")
+ "Enter Fall Delay (default=1.0e-9)")
ET.SubElement(param, "input_load", default="1.0e-12").text = (
- "Enter Input Load (default=1.0e-12)")
+ "Enter Input Load (default=1.0e-12)")
ET.SubElement(param, "instance_id", default="1").text = (
- "Enter Instance ID (Between 0-99)")
+ "Enter Instance ID (Between 0-99)")
tree = ET.ElementTree(root)
tree.write(str(self.modelname) + '.xml')
print("Leaving the directory ", xmlDestination)
@@ -229,11 +231,11 @@ class AutoSchematic(QtGui.QWidget):
os.chdir(cwd)
print('Leaving directory, ', self.lib_loc)
- QtGui.QMessageBox.information(
- self, "Library added",
+ QtWidgets.QMessageBox.information(
+ self.parent, "Library added",
'''Library details for this model is added to the ''' +
'''<b>eSim_Nghdl.lib</b> in the KiCad shared directory''',
- QtGui.QMessageBox.Ok
+ QtWidgets.QMessageBox.Ok
)