summaryrefslogtreecommitdiff
path: root/src/main/python/utils/canvas.py
diff options
context:
space:
mode:
authorBlaine2020-04-21 16:55:43 +0530
committerBlaine2020-04-21 16:55:43 +0530
commit16332668592bb1fcaa1b4f1bbd48c65bb55bc139 (patch)
tree13f455d67504192e31598e66ebb30f597e004733 /src/main/python/utils/canvas.py
parentd4ac81a1bf396aa7b9888957e2918bcc574e8ed1 (diff)
downloadChemical-PFD-16332668592bb1fcaa1b4f1bbd48c65bb55bc139.tar.gz
Chemical-PFD-16332668592bb1fcaa1b4f1bbd48c65bb55bc139.tar.bz2
Chemical-PFD-16332668592bb1fcaa1b4f1bbd48c65bb55bc139.zip
Moved to QMainWindow. canvas is now seperate
Diffstat (limited to 'src/main/python/utils/canvas.py')
-rw-r--r--src/main/python/utils/canvas.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py
new file mode 100644
index 0000000..ad72544
--- /dev/null
+++ b/src/main/python/utils/canvas.py
@@ -0,0 +1,46 @@
+from PyQt5.QtCore import Qt
+from PyQt5.QtGui import QBrush
+from PyQt5.QtWidgets import QWidget, QGraphicsScene, QGraphicsView, QHBoxLayout
+from .sizes import paperSizes
+class canvas(QWidget):
+ def __init__(self, parent=None):
+ super(canvas, self).__init__(parent)
+
+ self._ppi = 72
+ self._canvasSize = "A0"
+ self.resize(1280, 720)
+
+
+ self.painter = QGraphicsScene(0, 0, *paperSizes[self.canvasSize][self.ppi])
+ self.painter.setBackgroundBrush(QBrush(Qt.white))
+ self.view = QGraphicsView(self.painter)
+ self.layout = QHBoxLayout(self)
+ self.layout.addWidget(self.view)
+ self.setLayout(self.layout)
+
+ def setCanvasSize(self, size):
+ self.canvasSize = size
+
+ def setCanvasPPI(self, ppi):
+ self.ppi = ppi
+
+ @property
+ def canvasSize(self):
+ return self._canvasSize
+ @property
+ def ppi(self):
+ return self._ppi
+
+ @canvasSize.setter
+ def canvasSize(self, size):
+ self._canvasSize = size
+ if self.painter:
+ self.painter.setSceneRect(0, 0, *paperSizes[self.canvasSize][self.ppi])
+ # print(*paperSizes[self.canvasSize][self.ppi])
+
+ @ppi.setter
+ def ppi(self, ppi):
+ self._ppi = int(ppi)
+ if self.painter:
+ self.painter.setSceneRect(0, 0, *paperSizes[self.canvasSize][self.ppi])
+ # print(*paperSizes[self.canvasSize][self.ppi]) \ No newline at end of file