diff options
Diffstat (limited to 'src/main/python/utils')
-rw-r--r-- | src/main/python/utils/graphics.py | 6 | ||||
-rw-r--r-- | src/main/python/utils/toolbar.py | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py index fdc0a40..1e701f9 100644 --- a/src/main/python/utils/graphics.py +++ b/src/main/python/utils/graphics.py @@ -44,10 +44,12 @@ class customView(QGraphicsView): #defines item drop, fetches text, creates corresponding QGraphicItem and adds it to scene if QDropEvent.mimeData().hasText(): #QDropEvent.mimeData().text() defines intended drop item, the pos values define position - graphic = getattr(shapes, QDropEvent.mimeData().text())(QDropEvent.pos().x()-150, QDropEvent.pos().y()-150, 300, 300) + obj = QDropEvent.mimeData().text().split('/') + graphic = getattr(shapes, obj[0])(*map(int, obj[1:])) graphic.setPen(QPen(Qt.black, 2)) graphic.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsMovable) - self.scene().addItemPlus(graphic) + self.scene().addItemPlus(graphic) + graphic.setPos(QDropEvent.pos().x()-150, QDropEvent.pos().y()-150) QDropEvent.acceptProposedAction() def wheelEvent(self, QWheelEvent): diff --git a/src/main/python/utils/toolbar.py b/src/main/python/utils/toolbar.py index 4152f81..af6feae 100644 --- a/src/main/python/utils/toolbar.py +++ b/src/main/python/utils/toolbar.py @@ -112,6 +112,8 @@ class toolbarButton(QToolButton): self.setIconSize(QSize(64, 64)) #unecessary but left for future references self.dragStartPosition = None #intialize value for drag event self.itemObject = item['object'] #refer current item object, to handle drag mime + for i in item['args']: + self.itemObject += f"/{i}" self.setText(item["name"]) #button text self.setToolTip(item["name"]) #button tooltip |