summaryrefslogtreecommitdiff
path: root/src/frontEnd/ProjectExplorer.py
diff options
context:
space:
mode:
authormaddy-22019-05-27 12:32:49 +0530
committernilshah982019-06-07 11:03:14 +0530
commit28d8fd378bf717e8daba8a564708856769f24b98 (patch)
treeee8cc6592c690708d5f35cb5304feeae3d014c97 /src/frontEnd/ProjectExplorer.py
parent7e7b6d372aac718f857fcad5c49faf019ff83bb4 (diff)
downloadeSim-28d8fd378bf717e8daba8a564708856769f24b98.tar.gz
eSim-28d8fd378bf717e8daba8a564708856769f24b98.tar.bz2
eSim-28d8fd378bf717e8daba8a564708856769f24b98.zip
initialise pep8 compliance, using autopep8
Diffstat (limited to 'src/frontEnd/ProjectExplorer.py')
-rw-r--r--src/frontEnd/ProjectExplorer.py104
1 files changed, 66 insertions, 38 deletions
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index 7e03d399..677d934a 100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -1,4 +1,4 @@
-from PyQt4 import QtGui,QtCore
+from PyQt4 import QtGui, QtCore
import os
import json
from configuration.Appconfig import Appconfig
@@ -9,12 +9,12 @@ class ProjectExplorer(QtGui.QWidget):
QtGui.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
self.treewidget = QtGui.QTreeWidget()
- self.window= QtGui.QVBoxLayout()
- header = QtGui.QTreeWidgetItem(["Projects","path"])
+ self.window = QtGui.QVBoxLayout()
+ header = QtGui.QTreeWidgetItem(["Projects", "path"])
self.treewidget.setHeaderItem(header)
- self.treewidget.setColumnHidden(1,True)
+ self.treewidget.setColumnHidden(1, True)
- #CSS
+ # 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; } \
@@ -26,13 +26,16 @@ class ProjectExplorer(QtGui.QWidget):
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()):
+ 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])
+ 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)])
+ childnode = QtGui.QTreeWidgetItem(
+ parentnode, [files, os.path.join(parents, files)])
self.window.addWidget(self.treewidget)
self.treewidget.doubleClicked.connect(self.openProject)
@@ -43,12 +46,16 @@ class ProjectExplorer(QtGui.QWidget):
def addTreeNode(self, parents, children):
os.path.join(parents)
- pathlist= parents.split(os.sep)
- parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1], 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']] = []
+ 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):
@@ -65,7 +72,7 @@ class ProjectExplorer(QtGui.QWidget):
if level == 0:
deleteproject = menu.addAction(self.tr("Remove Project"))
deleteproject.triggered.connect(self.removeProject)
- refreshproject= menu.addAction(self.tr("Refresh"))
+ refreshproject = menu.addAction(self.tr("Refresh"))
refreshproject.triggered.connect(self.refreshProject)
elif level == 1:
openfile = menu.addAction(self.tr("Open"))
@@ -74,26 +81,33 @@ class ProjectExplorer(QtGui.QWidget):
menu.exec_(self.treewidget.viewport().mapToGlobal(position))
def openProject(self):
- self.indexItem =self.treewidget.currentIndex()
- 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.indexItem = self.treewidget.currentIndex()
+ filename = str(self.indexItem.data())
+ self.filePath = str(
+ 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.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:
+ 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)
+ QtCore.QObject.connect(
+ self.text,
+ QtCore.SIGNAL("textChanged()"),
+ self.enable_save)
vbox_main = QtGui.QVBoxLayout(self.textwindow)
vbox_main.addWidget(self.text)
@@ -103,24 +117,30 @@ class ProjectExplorer(QtGui.QWidget):
self.textwindow.show()
else:
- self.obj_appconfig.current_project["ProjectName"]= str(self.filePath)
- self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
+ 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']] = []
+ 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 = 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()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data()
+ self.indexItem = self.treewidget.currentIndex()
+ filename = str(self.indexItem.data())
+ self.filePath = str(
+ self.indexItem.sibling(
+ self.indexItem.row(),
+ 1).data())
self.int = self.indexItem.row()
self.treewidget.takeTopLevelItem(self.int)
@@ -128,20 +148,28 @@ class ProjectExplorer(QtGui.QWidget):
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'))
+ 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()
- self.filePath= str(self.indexItem.sibling(self.indexItem.row(), 1).data())
- filelistnew= os.listdir(os.path.join(self.filePath))
+ self.indexItem = self.treewidget.currentIndex()
+ filename = str(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()
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'))
+ 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'))