23 from PyQt5
import QtCore, QtWidgets, QtGui
28 colorChanged = QtCore.pyqtSignal()
30 def __init__(self, width, height, color, parent=None):
31 QtWidgets.QWidget.__init__(self, parent)
38 self.
color_ = QtWidgets.QColor(
"White")
47 self.change_color_.triggered.connect(self.
ChangeColor)
50 self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
55 color = QtWidgets.QColorDialog.getColor(initial = self.
color_, parent = self,
56 title =
"Select Color")
58 if(color != self.
color_ and color.isValid()):
60 self.colorChanged.emit()
68 return gfx.RGB(color.redF(), color.greenF(), color.blueF())
73 self.colorChanged.emit()
77 qcolor= QtWidgets.QColor(color.Red()*255,color.Green()*255,color.Blue()*255,color.Alpha()*255)
83 paint = QtGui.QPainter()
85 brush = QtGui.QBrush(self.
color_)