Genere una acción clcik a un Label con un pixmap asociado, al hacer click sobre la etiqueta solo visualizo el QMessageBox que coloque como referencia, la función que cambia el color al pixmap no hace nada. Les dejo el codigo y ojala puedan ayudarme.
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel,QMessageBox
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtGui import QPainter, QColor, QPen
from PyQt5.QtCore import Qt
from PyQt5.QtCore import (Qt, pyqtSignal)
import LabelClickeable
from LabelClickeable import QLabelClickable
class App(QWidget):
def __init__(self):
super().__init__()
self.title = 'PyQt5 Cambio de Colores con Clic '
self.left = 10
self.top = 10
self.width = 1280
self.height = 720
self.initUI()
def CambioColor(self,MiPixmap):
QMessageBox.information(self, "Correcto", "Cambio de Color", QMessageBox.Ok)
Peda1 = QLabel(self)
p = QPainter(MiPixmap)
pix=QPixmap(MiPixmap)
mask1 = pix.createMaskFromColor(QColor(221,221,221), Qt.MaskOutColor)
p.setPen(QColor(120, 255, 255))
p.drawPixmap(pix.rect(), mask1, mask1.rect())
p.end()
Peda1.setPixmap(pix)
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
Peda1 = QLabel(self)
pixmapPed1 = QPixmap('C:\\python\\proyectos\\pyqt5\\MainWindow\\MainWindow\\images\\peda1n.png')
Peda1 = QLabelClickable(self)
Peda1.clicked.connect(lambda: self.CambioColor(pixmapPed1))
Peda1.move(300,100)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())