Generate a clcik action to a Label with an associated pixmap, when clicking on the label, only visualize the QMessageBox that you put as a reference, the function that changes the color to the pixmap does nothing. I leave the code and hopefully you can help me.
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_())