-
Notifications
You must be signed in to change notification settings - Fork 1
/
shape_select_widget.py
76 lines (65 loc) · 3.54 KB
/
shape_select_widget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QColor, QIcon,QPixmap
from shapes import allButtonShapes,allShapes
from settings import *
def shapeSelectWidget(main,select):
main.shapeSelectWidget=QWidget()
main.shapeSelectWidgetLayout=QGridLayout()
main.shapeSelectWidget.setLayout(main.shapeSelectWidgetLayout)
#---shape selecttion buttons
circleButton=QPushButton()
circleButton.setIcon(QIcon(allButtonShapes['circle']))
circleButton.clicked.connect(lambda:setShape(main,'circle',select))
main.shapeSelectWidgetLayout.addWidget(circleButton,0,0)
triangleButton=QPushButton()
triangleButton.setIcon(QIcon(allButtonShapes['triangle']))
triangleButton.clicked.connect(lambda:setShape(main,'triangle',select))
main.shapeSelectWidgetLayout.addWidget(triangleButton,0,1)
squareButton=QPushButton()
squareButton.setIcon(QIcon(allButtonShapes['square']))
squareButton.clicked.connect(lambda:setShape(main,'square',select))
main.shapeSelectWidgetLayout.addWidget(squareButton,0,2)
pentagonButton=QPushButton()
pentagonButton.setIcon(QIcon(allButtonShapes['pentagon']))
pentagonButton.clicked.connect(lambda:setShape(main,'pentagon',select))
main.shapeSelectWidgetLayout.addWidget(pentagonButton,1,0)
hexagonButton=QPushButton()
hexagonButton.setIcon(QIcon(allButtonShapes['hexagon']))
hexagonButton.clicked.connect(lambda:setShape(main,'hexagon',select))
main.shapeSelectWidgetLayout.addWidget(hexagonButton,1,1)
heptagonButton=QPushButton()
heptagonButton.setIcon(QIcon(allButtonShapes['heptagon']))
heptagonButton.clicked.connect(lambda:setShape(main,'heptagon',select))
main.shapeSelectWidgetLayout.addWidget(heptagonButton,1,2)
octagonButton=QPushButton()
octagonButton.setIcon(QIcon(allButtonShapes['octagon']))
octagonButton.clicked.connect(lambda:setShape(main,'octagon',select))
main.shapeSelectWidgetLayout.addWidget(octagonButton,3,0)
nonagonButton=QPushButton()
nonagonButton.setIcon(QIcon(allButtonShapes['nonagon']))
nonagonButton.clicked.connect(lambda:setShape(main,'nonagon',select))
main.shapeSelectWidgetLayout.addWidget(nonagonButton,3,1)
decagonButton=QPushButton()
decagonButton.setIcon(QIcon(allButtonShapes['decagon']))
decagonButton.clicked.connect(lambda:setShape(main,'decagon',select))
main.shapeSelectWidgetLayout.addWidget(decagonButton,3,2)
main.shapeSelectWidget.show()
#---handle shape selection & apply changes to selected settings box
def setShape(main,shape,select):
main.shapeSelectWidget.close()
if select =="unup":
main.unupNodeShapePixmap=QPixmap(allShapes[shape])
main.unupNodeShapeMask = main.unupNodeShapePixmap.createMaskFromColor(QColor(BLACK), Qt.MaskInColor)
main.unupNodeShapePixmap.fill(main.unup_node_color_ui)
main.unupNodeShapePixmap.setMask(main.unupNodeShapeMask)
main.unupNodeShapePixmap=main.unupNodeShapePixmap.scaled(30,30)
main.unupNodeShapePreview.setPixmap(main.unupNodeShapePixmap)
elif select =="editor":
main.editor_node_shape=shape
main.editorNodeShapePixmap=QPixmap(allShapes[shape])
main.editorNodeShapeMask = main.editorNodeShapePixmap.createMaskFromColor(QColor(BLACK), Qt.MaskInColor)
main.editorNodeShapePixmap.fill(main.editor_node_color_ui)
main.editorNodeShapePixmap.setMask(main.editorNodeShapeMask)
main.editorNodeShapePixmap=main.editorNodeShapePixmap.scaled(30,30)
main.editorNodeShapePreview.setPixmap(main.editorNodeShapePixmap)