summaryrefslogtreecommitdiff
path: root/src/subcircuit
diff options
context:
space:
mode:
authorrahulp132020-12-14 21:08:43 +0530
committerrahulp132020-12-14 21:08:43 +0530
commit779eac4d604c082442ba9ca72a7c23509a78e5f5 (patch)
tree43831dac148767334754754988a6abc5c4352f9e /src/subcircuit
parentb3b25b6f1b6c5202620548cce59985d8b79a495f (diff)
downloadeSim-779eac4d604c082442ba9ca72a7c23509a78e5f5.tar.gz
eSim-779eac4d604c082442ba9ca72a7c23509a78e5f5.tar.bz2
eSim-779eac4d604c082442ba9ca72a7c23509a78e5f5.zip
changed QFileDialog separator and handled crash exception for all input fields
Diffstat (limited to 'src/subcircuit')
-rw-r--r--src/subcircuit/Subcircuit.py13
-rw-r--r--src/subcircuit/openSub.py12
-rw-r--r--src/subcircuit/uploadSub.py15
3 files changed, 29 insertions, 11 deletions
diff --git a/src/subcircuit/Subcircuit.py b/src/subcircuit/Subcircuit.py
index 298ff96e..eb06e145 100644
--- a/src/subcircuit/Subcircuit.py
+++ b/src/subcircuit/Subcircuit.py
@@ -64,8 +64,19 @@ class Subcircuit(QtWidgets.QWidget):
def newsch(self):
text, ok = QtWidgets.QInputDialog.getText(
- self, 'New Schematic', 'Enter Schematic Name:')
+ self, 'New Schematic', 'Enter Schematic Name:'
+ )
if ok:
+ if not text:
+ print("Schematic name cannot be empty")
+ print("==================")
+ msg = QtWidgets.QErrorMessage(self)
+ msg.setModal(True)
+ msg.setWindowTitle("Error Message")
+ msg.showMessage('The schematic name cannot be empty')
+ msg.exec_()
+ return
+
self.schematic_name = (str(text))
self.subcircuit = NewSub()
self.subcircuit.createSubcircuit(self.schematic_name)
diff --git a/src/subcircuit/openSub.py b/src/subcircuit/openSub.py
index 63597661..f98fe69f 100644
--- a/src/subcircuit/openSub.py
+++ b/src/subcircuit/openSub.py
@@ -1,7 +1,7 @@
-from PyQt5 import QtWidgets
+import os
+from PyQt5 import QtWidgets, QtCore
from configuration.Appconfig import Appconfig
from projManagement.Worker import WorkerThread
-import os
# This class is called when User clicks on Edit Subcircuit Button.
@@ -21,8 +21,12 @@ class openSub(QtWidgets.QWidget):
if os.name == 'nt':
init_path = ''
- self.editfile = QtWidgets.QFileDialog.getExistingDirectory(
- None, "Open File", init_path + "library/SubcircuitLibrary")
+ self.editfile = QtCore.QDir.toNativeSeparators(
+ QtWidgets.QFileDialog.getExistingDirectory(
+ None, "Open File", init_path + "library/SubcircuitLibrary"
+ )
+ )
+
if self.editfile:
self.obj_Appconfig = Appconfig()
self.obj_Appconfig.current_subcircuit['SubcircuitName'] \
diff --git a/src/subcircuit/uploadSub.py b/src/subcircuit/uploadSub.py
index 13924bf3..5ae50df8 100644
--- a/src/subcircuit/uploadSub.py
+++ b/src/subcircuit/uploadSub.py
@@ -1,4 +1,4 @@
-from PyQt5 import QtWidgets
+from PyQt5 import QtWidgets, QtCore
from configuration.Appconfig import Appconfig
from projManagement.Validation import Validation
import os
@@ -20,7 +20,7 @@ class UploadSub(QtWidgets.QWidget):
def upload(self):
"""
- This method opens a dialogue box when Upload subcircuit button is
+ This method opens a dialog box when Upload subcircuit button is
clicked and after entering folder name, it opens directory system
to chose file for folder, it only shows file with extension .sub
and with the name of project entered earlier as folder name.
@@ -30,11 +30,14 @@ class UploadSub(QtWidgets.QWidget):
true if file has valid format or else it shows an error message.
"""
- editfile = QtWidgets.QFileDialog.getOpenFileName(
- None, "Upload Subcircuit File", os.path.expanduser("~"), "*.sub"
- )[0]
+ editfile = QtCore.QDir.toNativeSeparators(
+ QtWidgets.QFileDialog.getOpenFileName(
+ None, "Upload Subcircuit File",
+ os.path.expanduser("~"), "*.sub"
+ )[0]
+ )
- if editfile == '':
+ if not editfile:
return
upload = os.path.basename(editfile)