summaryrefslogtreecommitdiff
path: root/src/frontEnd/Workspace.py
diff options
context:
space:
mode:
authorrahulp132020-02-16 22:56:59 +0530
committerrahulp132020-02-16 22:56:59 +0530
commit453c2dab78f81046fcbd42034a86c4e759a0ff68 (patch)
tree1e52dc08cfb0a86666372421d90502976715f35c /src/frontEnd/Workspace.py
parent3e27f0dcb8555e1708497b48ad251e93fed93b6e (diff)
downloadeSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.tar.gz
eSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.tar.bz2
eSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.zip
workspace functionality
Diffstat (limited to 'src/frontEnd/Workspace.py')
-rw-r--r--src/frontEnd/Workspace.py54
1 files changed, 50 insertions, 4 deletions
diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py
index 29be09fc..09092a69 100644
--- a/src/frontEnd/Workspace.py
+++ b/src/frontEnd/Workspace.py
@@ -20,6 +20,7 @@ from PyQt4 import QtCore, QtGui
from configuration.Appconfig import Appconfig
import time
import os
+import json
class Workspace(QtGui.QWidget):
@@ -62,13 +63,19 @@ class Workspace(QtGui.QWidget):
self.okbtn.clicked.connect(self.createWorkspace)
self.cancelbtn = QtGui.QPushButton('Cancel')
self.cancelbtn.clicked.connect(self.defaultWorkspace)
+
+ #Checkbox
+ self.chkbox = QtGui.QCheckBox('Set Default', self)
+ self.chkbox.setCheckState(int(self.obj_appconfig.workspace_check))
+
# Layout
self.grid.addWidget(self.note, 0, 0, 1, 15)
self.grid.addWidget(self.workspace_label, 2, 1)
self.grid.addWidget(self.workspace_loc, 2, 2, 2, 12)
self.grid.addWidget(self.browsebtn, 2, 14)
- self.grid.addWidget(self.okbtn, 4, 13)
- self.grid.addWidget(self.cancelbtn, 4, 14)
+ self.grid.addWidget(self.chkbox, 4, 2)
+ self.grid.addWidget(self.okbtn, 5, 13)
+ self.grid.addWidget(self.cancelbtn, 5, 14)
self.setGeometry(QtCore.QRect(500, 250, 400, 400))
self.setMaximumSize(4000, 200)
@@ -77,7 +84,6 @@ class Workspace(QtGui.QWidget):
self.note.setReadOnly(True)
self.setWindowIcon(QtGui.QIcon('../../images/logo.png'))
self.setLayout(self.grid)
- self.show()
def defaultWorkspace(self):
print("Default workspace selected : " +
@@ -87,6 +93,13 @@ class Workspace(QtGui.QWidget):
'Default workspace selected : ' +
self.obj_appconfig.default_workspace["workspace"])
self.close()
+
+ var_appView.obj_Mainview.obj_projectExplorer.treewidget.clear()
+ for parent, children in self.obj_appconfig.project_explorer.items():
+ var_appView.obj_Mainview.obj_projectExplorer.addTreeNode(
+ parent, children
+ )
+
var_appView.show()
time.sleep(1)
var_appView.splash.close()
@@ -102,6 +115,17 @@ class Workspace(QtGui.QWidget):
def createWorkspace(self):
print("Function : Create workspace")
+
+ self.obj_appconfig.workspace_check = self.chkbox.checkState()
+ print(self.workspace_loc.text())
+ file = open(os.path.join(
+ os.path.expanduser("~"), ".esim/workspace.txt"), 'w'
+ )
+ file.writelines(str(self.obj_appconfig.workspace_check) +
+ " " + self.workspace_loc.text()
+ )
+ file.close()
+
self.create_workspace = str(self.workspace_loc.text())
self.obj_appconfig.print_info('Workspace : ' + self.create_workspace)
# Checking if Workspace already exist or not
@@ -114,6 +138,27 @@ class Workspace(QtGui.QWidget):
= self.create_workspace
self.imp_var = 1
self.close()
+
+ self.obj_appconfig.dictPath["path"] = os.path.join(
+ self.obj_appconfig.default_workspace["workspace"],
+ ".projectExplorer.txt"
+ )
+
+ try:
+ self.obj_appconfig.project_explorer = json.load(
+ open(self.obj_appconfig.dictPath["path"])
+ )
+ except:
+ self.obj_appconfig.project_explorer = {}
+
+ Appconfig.project_explorer = self.obj_appconfig.project_explorer
+
+ var_appView.obj_Mainview.obj_projectExplorer.treewidget.clear()
+ for parent, children in self.obj_appconfig.project_explorer.items():
+ var_appView.obj_Mainview.obj_projectExplorer.addTreeNode(
+ parent, children
+ )
+
var_appView.show()
time.sleep(1)
var_appView.splash.close()
@@ -121,5 +166,6 @@ class Workspace(QtGui.QWidget):
def browseLocation(self):
print("Function : Browse Location")
self.workspace_directory = QtGui.QFileDialog.getExistingDirectory(
- self, "Browse Location", os.path.expanduser("~"))
+ self, "Browse Location", os.path.expanduser("~")
+ )
self.workspace_loc.setText(self.workspace_directory)