
להגיב ל: איך משנים צבע לBUTTON בPYQT כשהעכבר עובר עליו?
קדם ‹ Forums ‹ הייטק ‹ Programming Languages ‹ איך משנים צבע לBUTTON בPYQT כשהעכבר עובר עליו? ‹ הייטק
-
0
0
0
חברה חדשה
וואו, תודה. עשיתי את זה, והאנימציה לא עושה כלום, זאת אומרת – כשאני עוזבת עם העכבר – הוא פועל מצוין, אבל כשאני עוברת עם העכבר – הוא לא עושה כלום. אני מצרפת את הקוד: class MyButton(QtWidgets.QPushButton):
def __init__(self, parent=”none”):
super(MyButton, self).__init__(parent)self.setMinimumSize(80, 50)
self.setText(‘QPushButton’)
self.setStyleSheet(
“border: 1px solid white;border-radius:15px;background-color: white;”)def enterEvent(self, event):
global animanim = QPropertyAnimation(self, b’background-color’)
anim.setDuration(200)
anim.setStartValue(QColor(255, 255, 255))
anim.setEndValue(QColor(0, 170, 0))
anim.start()
def leaveEvent(self, event):
self.setStyleSheet(
“border: 1px solid white;border-radius:15px;background-color: white;”)