diff options
author | Blaine | 2020-06-09 11:08:32 +0530 |
---|---|---|
committer | Blaine | 2020-06-09 11:08:32 +0530 |
commit | 3ea92365befd56852288fdaac5d551c4b96d269a (patch) | |
tree | 1471d88a2b8496785912a35ea497a0963b896676 /src | |
parent | 994a0f5c1fb80d0065b8fd3134111ca8790b46bd (diff) | |
download | Chemical-PFD-3ea92365befd56852288fdaac5d551c4b96d269a.tar.gz Chemical-PFD-3ea92365befd56852288fdaac5d551c4b96d269a.tar.bz2 Chemical-PFD-3ea92365befd56852288fdaac5d551c4b96d269a.zip |
2nd fix
Diffstat (limited to 'src')
-rw-r--r-- | src/main/python/main.py | 4 | ||||
-rw-r--r-- | src/main/python/shapes/shapes.py | 6 | ||||
-rw-r--r-- | src/main/python/utils/app.py | 6 | ||||
-rw-r--r-- | src/main/python/utils/canvas.py | 4 | ||||
-rw-r--r-- | src/main/python/utils/fileWindow.py | 4 |
5 files changed, 14 insertions, 10 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py index 40384d5..ff41413 100644 --- a/src/main/python/main.py +++ b/src/main/python/main.py @@ -12,7 +12,7 @@ from utils.fileWindow import fileWindow from utils.data import ppiList, sheetDimensionList from utils import dialogs from utils.toolbar import toolbar -from utils.app import app, settings, loads +from utils.app import app, settings, load import shapes @@ -104,7 +104,7 @@ class appWindow(QMainWindow): if name: for files in name[0]: with open(files,'r') as file: - projectData = loads(file) + projectData = load(file) project = fileWindow(self.mdi) self.mdi.addSubWindow(project) project.__setstate__(projectData) diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 2da1ca0..a795f6a 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -316,9 +316,9 @@ class NodeItem(QGraphicsSvgItem): # set a common renderer for all svg renderer = QSvgRenderer(fileImporter(f'svg/ellipse.svg')) - def __init__(self, unitOperationType, parent=None): + def __init__(self, unitOperationType=None, parent=None): QGraphicsSvgItem.__init__(self, parent) - self.m_type = unitOperationType + self.m_type = str(unitOperationType) self.id = None # self.m_renderer = QSvgRenderer("svg/" + unitOperationType + ".svg") # self.m_renderer = QSvgRenderer(fileImporter(f'svg/{unitOperationType}.svg')) @@ -504,7 +504,7 @@ class NodeItem(QGraphicsSvgItem): "_classname_": self.__class__.__name__, "width": self.width, "height": self.height, - "pos": (self.pos.x(), self.pos.y()) + "pos": (self.pos().x(), self.pos().y()) } def __setstate__(self, dict): diff --git a/src/main/python/utils/app.py b/src/main/python/utils/app.py index aa1ce28..5d85cb7 100644 --- a/src/main/python/utils/app.py +++ b/src/main/python/utils/app.py @@ -4,7 +4,7 @@ Declare fbs application so that it can be imported in other modules. from fbs_runtime.application_context.PyQt5 import ApplicationContext from PyQt5.QtCore import QSettings -from json import JSONEncoder, dumps, loads +from json import JSONEncoder, dumps, loads, dump, load app = ApplicationContext() settings = QSettings(QSettings.IniFormat, QSettings.UserScope ,"FOSSEE", "Chemical-PFD") @@ -41,6 +41,10 @@ class JSON_Encoder: return obj class JSON_Typer(JSONEncoder): + + def default(self, o): + return o.__getstate__() + def _encode(self, obj): return JSON_Encoder._encode(obj) diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 10601f2..a83aeb2 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -128,8 +128,8 @@ class canvas(QWidget): "ppi": self._ppi, "canvasSize": self._canvasSize, "ObjectName": self.objectName(), - "symbols": [dumps(i, indent=4, cls=JSON_Typer) for i in self.painter.items() if isinstance(i, shapes.NodeItem)], - "lines": [dumps(i, indent=4, cls=JSON_Typer) for i in self.painter.items() if isinstance(i, shapes.Line)], + "symbols": [i for i in self.painter.items() if isinstance(i, shapes.NodeItem)], + "lines": [i for i in self.painter.items() if isinstance(i, shapes.Line)], # "lineLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.LineLabel)], # "itemLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.itemLabel)] } diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py index 215ebfe..04ed81a 100644 --- a/src/main/python/utils/fileWindow.py +++ b/src/main/python/utils/fileWindow.py @@ -9,7 +9,7 @@ from .graphics import customView from .canvas import canvas from .tabs import customTabWidget from .undo import resizeCommand -from .app import dumps, loads, JSON_Typer +from .app import dump, loads, JSON_Typer class fileWindow(QMdiSubWindow): @@ -222,7 +222,7 @@ class fileWindow(QMdiSubWindow): name = QFileDialog.getSaveFileName(self, 'Save File', f'New Diagram', 'Process Flow Diagram (*.pfd)') if not name else name if name[0]: with open(name[0],'w') as file: - dumps(self, file, indent=4, cls=JSON_Typer) + dump(self, file, indent=4, cls=JSON_Typer) return True else: return False |