Exemple #1
0
    def on_pressed(self):
        """Button pressed event handler

        Shows color dialog and sets the chosen color.

        """

        dlg = QColorDialog(self.parent())

        dlg.setCurrentColor(self.color)
        dlg.setWindowTitle(self.title)

        dlg.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint)
        dlg.setWindowModality(Qt.ApplicationModal)
        dlg.setOptions(QColorDialog.DontUseNativeDialog)

        p = self.mapFromGlobal(QCursor.pos())
        p.setX(p.x() + (self.rect().width() / 2))
        p.setY(p.y() + (self.rect().height() / 2))
        dlg.move(self.mapToGlobal(p))

        if dlg.exec_():
            self.color = dlg.currentColor()
            self.colorChanged.emit()