summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
authornilshah982019-03-31 04:28:27 +0530
committernilshah982019-03-31 04:28:27 +0530
commit30c607ef581345958f0f9bdb5dd5603a1dd774c8 (patch)
tree106bc0624d2f0900a57e99cc125ac5df6e01db20 /src/frontEnd
parent8b986efb1c9216e284f6cc27a8f44d09e5c5cc59 (diff)
downloadeSim-30c607ef581345958f0f9bdb5dd5603a1dd774c8.tar.gz
eSim-30c607ef581345958f0f9bdb5dd5603a1dd774c8.tar.bz2
eSim-30c607ef581345958f0f9bdb5dd5603a1dd774c8.zip
port to python3
Diffstat (limited to 'src/frontEnd')
-rwxr-xr-xsrc/frontEnd/Application.py22
-rw-r--r--src/frontEnd/DockArea.py2
-rw-r--r--src/frontEnd/ProjectExplorer.py68
-rw-r--r--src/frontEnd/ProjectExplorer.py.bak147
-rw-r--r--src/frontEnd/Workspace.py6
5 files changed, 196 insertions, 49 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 2f9bca28..dd4cb740 100755
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -182,7 +182,7 @@ class Application(QtGui.QMainWindow):
def close_project(self):
- print "Function : Close Project"
+ print("Function : Close Project")
current_project = self.obj_appconfig.current_project['ProjectName']
if current_project==None:
pass
@@ -209,7 +209,7 @@ class Application(QtGui.QMainWindow):
self.obj_Mainview.obj_projectExplorer.addTreeNode(directory, filelist)
else:
- print "No new project created"
+ print("No new project created")
self.obj_appconfig.print_info('No new project created')
try:
self.obj_appconfig.print_info('Current project is : ' + self.obj_appconfig.current_project["ProjectName"])
@@ -220,7 +220,7 @@ class Application(QtGui.QMainWindow):
"""
This project call Open Project Info class
"""
- print "Function : Open Project"
+ print("Function : Open Project")
self.project = OpenProjectInfo()
try:
@@ -233,9 +233,9 @@ class Application(QtGui.QMainWindow):
def help_project(self):
- print "Function : Help"
+ print("Function : Help")
self.obj_appconfig.print_info('Help is called')
- print "Current Project is : ",self.obj_appconfig.current_project
+ print("Current Project is : ",self.obj_appconfig.current_project)
self.obj_Mainview.obj_dockarea.usermanual()
@@ -257,7 +257,7 @@ class Application(QtGui.QMainWindow):
self.msg = QtGui.QErrorMessage(None)
self.msg.showMessage('Error while opening python plotting Editor.\
Please look at console for more details ')
- print "Exception Message:",str(e)
+ print("Exception Message:",str(e))
self.obj_appconfig.print_error('Exception Message : ' + str(e))
self.msg.setWindowTitle("Error Message")
@@ -267,12 +267,12 @@ class Application(QtGui.QMainWindow):
self.msg.setWindowTitle("Error Message")
def open_subcircuit(self):
- print "Function : Subcircuit editor"
+ print("Function : Subcircuit editor")
self.obj_appconfig.print_info('Subcircuit editor is called')
self.obj_Mainview.obj_dockarea.subcircuiteditor()
def open_nghdl(self):
- print "Function : Nghdl"
+ print("Function : Nghdl")
self.obj_appconfig.print_info('Nghdl is called')
if self.obj_validation.validateTool('nghdl'):
@@ -288,7 +288,7 @@ class Application(QtGui.QMainWindow):
def open_modelEditor(self):
- print "Function : Model editor"
+ print("Function : Model editor")
self.obj_appconfig.print_info('Model editor is called')
self.obj_Mainview.obj_dockarea.modelEditor()
@@ -351,7 +351,7 @@ class Application(QtGui.QMainWindow):
def open_OMoptim(self):
- print "Function : OM Optim"
+ print("Function : OM Optim")
self.obj_appconfig.print_info('OM Optim is called')
#Check if OMOptim is installed
if self.obj_validation.validateTool("OMOptim"):
@@ -430,7 +430,7 @@ def main(args):
"""
It is main function of the module.It starts the application
"""
- print "Starting eSim......"
+ print("Starting eSim......")
app = QtGui.QApplication(args)
splash_pix = QtGui.QPixmap('../../images/splash_screen_esim.png')
diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py
index 073072bf..7ae3607c 100644
--- a/src/frontEnd/DockArea.py
+++ b/src/frontEnd/DockArea.py
@@ -167,7 +167,7 @@ class DockArea(QtGui.QMainWindow):
count = count + 1
def modelEditor(self):
- print"in model editor"
+ print("in model editor")
global count
self.modelwidget = QtGui.QWidget()
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index d14a8da9..7e03d399 100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -13,7 +13,7 @@ class ProjectExplorer(QtGui.QWidget):
header = QtGui.QTreeWidgetItem(["Projects","path"])
self.treewidget.setHeaderItem(header)
self.treewidget.setColumnHidden(1,True)
-
+
#CSS
self.treewidget.setStyleSheet(" \
QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \
@@ -25,8 +25,8 @@ class ProjectExplorer(QtGui.QWidget):
QTreeView::branch:open:has-children:!has-siblings, \
QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \
")
-
- for parents, children in self.obj_appconfig.project_explorer.items():
+
+ for parents, children in list(self.obj_appconfig.project_explorer.items()):
os.path.join(parents)
if os.path.exists(parents):
pathlist= parents.split(os.sep)
@@ -34,33 +34,33 @@ class ProjectExplorer(QtGui.QWidget):
for files in children:
childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
self.window.addWidget(self.treewidget)
-
+
self.treewidget.doubleClicked.connect(self.openProject)
self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.treewidget.customContextMenuRequested.connect(self.openMenu)
self.setLayout(self.window)
self.show()
-
+
def addTreeNode(self, parents, children):
os.path.join(parents)
pathlist= parents.split(os.sep)
parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1], parents])
for files in children:
childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
- self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
- self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
-
+ self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
+ self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
+
def openMenu(self, position):
-
+
indexes = self.treewidget.selectedIndexes()
if len(indexes) > 0:
-
+
level = 0
index = indexes[0]
while index.parent().isValid():
index = index.parent()
level += 1
-
+
menu = QtGui.QMenu()
if level == 0:
deleteproject = menu.addAction(self.tr("Remove Project"))
@@ -70,20 +70,20 @@ class ProjectExplorer(QtGui.QWidget):
elif level == 1:
openfile = menu.addAction(self.tr("Open"))
openfile.triggered.connect(self.openProject)
-
- menu.exec_(self.treewidget.viewport().mapToGlobal(position))
-
+
+ menu.exec_(self.treewidget.viewport().mapToGlobal(position))
+
def openProject(self):
self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
+ filename= self.indexItem.data()
+ self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data()
self.obj_appconfig.print_info('The current project is ' + self.filePath)
-
+
self.textwindow = QtGui.QWidget()
self.textwindow.setMinimumSize(600, 500)
self.textwindow.setGeometry(QtCore.QRect(400,150,400,400))
self.textwindow.setWindowTitle(filename)
-
+
self.text = QtGui.QTextEdit()
self.save = QtGui.QPushButton('Save and Exit')
self.save.setDisabled(True)
@@ -92,48 +92,48 @@ class ProjectExplorer(QtGui.QWidget):
self.fopen = open(str(self.filePath), 'r')
lines = self.fopen.read()
self.text.setText(lines)
-
- QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
-
+
+ QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
+
vbox_main = QtGui.QVBoxLayout(self.textwindow)
vbox_main.addWidget(self.text)
vbox_main.addWidget(self.save)
self.save.clicked.connect(self.save_data)
#self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit)
-
+
self.textwindow.show()
else:
self.obj_appconfig.current_project["ProjectName"]= str(self.filePath)
self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
if self.obj_appconfig.current_project['ProjectName'] not in self.obj_appconfig.dock_dict:
self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
-
+
def enable_save(self):
self.save.setEnabled(True)
-
+
def save_data(self):
self.fopen=open(self.filePath, 'w')
self.fopen.write(self.text.toPlainText())
self.fopen.close()
self.textwindow.close()
-
+
def removeProject(self):
self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
+ filename= self.indexItem.data()
+ self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data()
self.int = self.indexItem.row()
self.treewidget.takeTopLevelItem(self.int)
-
+
if self.obj_appconfig.current_project["ProjectName"] == self.filePath:
- self.obj_appconfig.current_project["ProjectName"] = None
-
+ self.obj_appconfig.current_project["ProjectName"] = None
+
del self.obj_appconfig.project_explorer[str(self.filePath)]
json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
-
+
def refreshProject(self):
self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= str(self.indexItem.sibling(self.indexItem.row(), 1).data().toString())
+ filename= self.indexItem.data()
+ self.filePath= str(self.indexItem.sibling(self.indexItem.row(), 1).data())
filelistnew= os.listdir(os.path.join(self.filePath))
parentnode = self.treewidget.currentItem()
count = parentnode.childCount()
@@ -142,6 +142,6 @@ class ProjectExplorer(QtGui.QWidget):
items.removeChild(items.child(0))
for files in filelistnew:
childnode= QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(self.filePath,files)])
-
+
self.obj_appconfig.project_explorer[self.filePath]= filelistnew
json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
diff --git a/src/frontEnd/ProjectExplorer.py.bak b/src/frontEnd/ProjectExplorer.py.bak
new file mode 100644
index 00000000..8c75398e
--- /dev/null
+++ b/src/frontEnd/ProjectExplorer.py.bak
@@ -0,0 +1,147 @@
+from PyQt4 import QtGui,QtCore
+import os
+import json
+from configuration.Appconfig import Appconfig
+
+
+class ProjectExplorer(QtGui.QWidget):
+ def __init__(self):
+ QtGui.QWidget.__init__(self)
+ self.obj_appconfig = Appconfig()
+ self.treewidget = QtGui.QTreeWidget()
+ self.window= QtGui.QVBoxLayout()
+ header = QtGui.QTreeWidgetItem(["Projects","path"])
+ self.treewidget.setHeaderItem(header)
+ self.treewidget.setColumnHidden(1,True)
+
+ #CSS
+ self.treewidget.setStyleSheet(" \
+ QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \
+ QTreeView::branch:has-siblings:!adjoins-item { border-image: url(../../images/vline.png) 0; } \
+ QTreeView::branch:has-siblings:adjoins-item { border-image: url(../../images/branch-more.png) 0; } \
+ QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(../../images/branch-end.png) 0; } \
+ QTreeView::branch:has-children:!has-siblings:closed, \
+ QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(../../images/branch-closed.png); } \
+ QTreeView::branch:open:has-children:!has-siblings, \
+ QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \
+ ")
+
+ for parents, children in list(self.obj_appconfig.project_explorer.items()):
+ os.path.join(parents)
+ if os.path.exists(parents):
+ pathlist= parents.split(os.sep)
+ parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1],parents])
+ for files in children:
+ childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
+ self.window.addWidget(self.treewidget)
+
+ self.treewidget.doubleClicked.connect(self.openProject)
+ self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
+ self.treewidget.customContextMenuRequested.connect(self.openMenu)
+ self.setLayout(self.window)
+ self.show()
+
+ def addTreeNode(self, parents, children):
+ os.path.join(parents)
+ pathlist= parents.split(os.sep)
+ parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1], parents])
+ for files in children:
+ childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
+ self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
+ self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
+
+ def openMenu(self, position):
+
+ indexes = self.treewidget.selectedIndexes()
+ if len(indexes) > 0:
+
+ level = 0
+ index = indexes[0]
+ while index.parent().isValid():
+ index = index.parent()
+ level += 1
+
+ menu = QtGui.QMenu()
+ if level == 0:
+ deleteproject = menu.addAction(self.tr("Remove Project"))
+ deleteproject.triggered.connect(self.removeProject)
+ refreshproject= menu.addAction(self.tr("Refresh"))
+ refreshproject.triggered.connect(self.refreshProject)
+ elif level == 1:
+ openfile = menu.addAction(self.tr("Open"))
+ openfile.triggered.connect(self.openProject)
+
+ menu.exec_(self.treewidget.viewport().mapToGlobal(position))
+
+ def openProject(self):
+ self.indexItem =self.treewidget.currentIndex()
+ filename= self.indexItem.data().toString()
+ self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
+ self.obj_appconfig.print_info('The current project is ' + self.filePath)
+
+ self.textwindow = QtGui.QWidget()
+ self.textwindow.setMinimumSize(600, 500)
+ self.textwindow.setGeometry(QtCore.QRect(400,150,400,400))
+ self.textwindow.setWindowTitle(filename)
+
+ self.text = QtGui.QTextEdit()
+ self.save = QtGui.QPushButton('Save and Exit')
+ self.save.setDisabled(True)
+ self.windowgrid = QtGui.QGridLayout()
+ if (os.path.isfile(str(self.filePath)))== True:
+ self.fopen = open(str(self.filePath), 'r')
+ lines = self.fopen.read()
+ self.text.setText(lines)
+
+ QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
+
+ vbox_main = QtGui.QVBoxLayout(self.textwindow)
+ vbox_main.addWidget(self.text)
+ vbox_main.addWidget(self.save)
+ self.save.clicked.connect(self.save_data)
+ #self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit)
+
+ self.textwindow.show()
+ else:
+ self.obj_appconfig.current_project["ProjectName"]= str(self.filePath)
+ self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
+ if self.obj_appconfig.current_project['ProjectName'] not in self.obj_appconfig.dock_dict:
+ self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
+
+ def enable_save(self):
+ self.save.setEnabled(True)
+
+ def save_data(self):
+ self.fopen=open(self.filePath, 'w')
+ self.fopen.write(self.text.toPlainText())
+ self.fopen.close()
+ self.textwindow.close()
+
+ def removeProject(self):
+ self.indexItem =self.treewidget.currentIndex()
+ filename= self.indexItem.data().toString()
+ self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
+ self.int = self.indexItem.row()
+ self.treewidget.takeTopLevelItem(self.int)
+
+ if self.obj_appconfig.current_project["ProjectName"] == self.filePath:
+ self.obj_appconfig.current_project["ProjectName"] = None
+
+ del self.obj_appconfig.project_explorer[str(self.filePath)]
+ json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
+
+ def refreshProject(self):
+ self.indexItem =self.treewidget.currentIndex()
+ filename= self.indexItem.data().toString()
+ self.filePath= str(self.indexItem.sibling(self.indexItem.row(), 1).data().toString())
+ filelistnew= os.listdir(os.path.join(self.filePath))
+ parentnode = self.treewidget.currentItem()
+ count = parentnode.childCount()
+ for i in range(count):
+ for items in self.treewidget.selectedItems():
+ items.removeChild(items.child(0))
+ for files in filelistnew:
+ childnode= QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(self.filePath,files)])
+
+ self.obj_appconfig.project_explorer[self.filePath]= filelistnew
+ json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py
index 7cefa6c6..431d49bb 100644
--- a/src/frontEnd/Workspace.py
+++ b/src/frontEnd/Workspace.py
@@ -75,7 +75,7 @@ class Workspace(QtGui.QWidget):
def defaultWorkspace(self):
- print "Default workspace selected : "+self.obj_appconfig.default_workspace["workspace"]
+ print("Default workspace selected : "+self.obj_appconfig.default_workspace["workspace"])
self.imp_var=1
self.obj_appconfig.print_info('Default workspace selected : ' + self.obj_appconfig.default_workspace["workspace"])
self.close()
@@ -98,7 +98,7 @@ class Workspace(QtGui.QWidget):
def createWorkspace(self):
- print "Function : Create workspace"
+ print("Function : Create workspace")
self.create_workspace = str(self.workspace_loc.text())
self.obj_appconfig.print_info('Workspace : ' + self.create_workspace)
#Checking if Workspace already exist or not
@@ -115,7 +115,7 @@ class Workspace(QtGui.QWidget):
def browseLocation(self):
- print "Function : Browse Location"
+ print("Function : Browse Location")
self.workspace_directory = QtGui.QFileDialog.getExistingDirectory(self, "Browse Location",os.path.expanduser("~"))
self.workspace_loc.setText(self.workspace_directory)
\ No newline at end of file