From cb55e59de7ee4383c04edfae7c39ad9ae9552b36 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Fri, 14 Feb 2020 15:16:35 +0530 Subject: common code for Win and Linux, merged py2 changes --- src/frontEnd/Workspace.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/frontEnd/Workspace.py') diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 55a8c95e..29be09fc 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -1,5 +1,4 @@ # ========================================================================= -# # FILE: Workspace.py # # USAGE: --- @@ -11,27 +10,26 @@ # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com +# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 05 February 2015 -# REVISION: --- +# REVISION: Friday 14 February 2020 # ========================================================================= + from PyQt4 import QtCore, QtGui from configuration.Appconfig import Appconfig import time import os -# This class creates Workspace GUI. class Workspace(QtGui.QWidget): """ This class creates UI for WorkSpace selection window. - This window contains text area to select location of your choice - or browse location for workspace area. - - By default workspace is set in ~/eSim-Workspace. - - This workspace area contains all the projects made by user. + - This window contains text area to select location of your choice \ + or browse location for workspace area. + - By default workspace is set in ~/eSim-Workspace. + - This workspace area contains all the projects made by user. """ @@ -43,7 +41,6 @@ class Workspace(QtGui.QWidget): self.initWorkspace() def initWorkspace(self): - # print "Calling workspace" self.mainwindow = QtGui.QVBoxLayout() self.split = QtGui.QSplitter() -- cgit From 453c2dab78f81046fcbd42034a86c4e759a0ff68 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Sun, 16 Feb 2020 22:56:59 +0530 Subject: workspace functionality --- src/frontEnd/Workspace.py | 54 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'src/frontEnd/Workspace.py') 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) -- cgit From 567e3b725fcc9d22e27cfd854a573d3e64deaff1 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Fri, 21 Feb 2020 12:39:52 +0530 Subject: restructured code - pyinstaller --- src/frontEnd/Workspace.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/frontEnd/Workspace.py') diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index 09092a69..6940da59 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -64,7 +64,7 @@ class Workspace(QtGui.QWidget): self.cancelbtn = QtGui.QPushButton('Cancel') self.cancelbtn.clicked.connect(self.defaultWorkspace) - #Checkbox + # Checkbox self.chkbox = QtGui.QCheckBox('Set Default', self) self.chkbox.setCheckState(int(self.obj_appconfig.workspace_check)) @@ -82,7 +82,7 @@ class Workspace(QtGui.QWidget): self.setWindowTitle("eSim") self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.note.setReadOnly(True) - self.setWindowIcon(QtGui.QIcon('../../images/logo.png')) + self.setWindowIcon(QtGui.QIcon('images/logo.png')) self.setLayout(self.grid) def defaultWorkspace(self): @@ -121,7 +121,8 @@ class Workspace(QtGui.QWidget): file = open(os.path.join( os.path.expanduser("~"), ".esim/workspace.txt"), 'w' ) - file.writelines(str(self.obj_appconfig.workspace_check) + + file.writelines( + str(self.obj_appconfig.workspace_check) + " " + self.workspace_loc.text() ) file.close() @@ -148,10 +149,10 @@ class Workspace(QtGui.QWidget): self.obj_appconfig.project_explorer = json.load( open(self.obj_appconfig.dictPath["path"]) ) - except: + except BaseException: self.obj_appconfig.project_explorer = {} - Appconfig.project_explorer = 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(): -- cgit