hi Thanks for the reply thats exactly what i want , i already made a code of more than 1000 lines(chunk of code is in program.py script) and when i try to add your code for mouse over effect its not giving me required result .
i saved your script with the name of hover.py from PyQt4 import QtGui, QtCore from PyQt4.QtCore import pyqtSignal import os,sys class HoverButton(QtGui.QToolButton): def enterEvent(self,event): print("Enter") self.setStyleSheet("background-color:#45b545;") def leaveEvent(self,event): self.setStyleSheet("background-color:yellow;") print("Leave") and then i call it from another program and include "hover.py" "program.py" import os,sys from functools import partial from PyQt4 import QtGui, QtCore import hover class main(): def Qbutton(self): buttons["a1"] = QtGui.QToolButton(widget) buttons["a1"].setIconSize(QtCore.QSize(200,200)) buttons["a1"] = hover.HoverButton() app= QtGui.QApplication(sys.argv) sk = main() buttons = {} widget = QtGui.QWidget() sk.Qbutton() widget.show() sys.exit(app.exec_()) Can you please guide me how to add that script to program.py so it works fine .It will really solve my problem .Thanks in advance On Wed, Feb 22, 2012 at 2:08 AM, Hans-Peter Jansen <h...@urpla.net> wrote: > On Tuesday 21 February 2012, 03:27:41 uahmed wrote: > > hi , > > > > I want to do hover i saw an example and then write a script which > > will be use as i made program i am facing one problem that hover only > > occur if u putt mouse on the left corner of button i want that it > > will happen for all the button that if i move cursor on button then > > it should change. here is my code > > > > from PyQt4 import QtGui, QtCore > > from PyQt4.QtCore import pyqtSignal > > import os,sys > > > > class HoverButton(QtGui.QToolButton): > > def enterEvent(self,event): > > print("Enter") > > button.setStyleSheet("background-color:#45b545;") > > > > def leaveEvent(self,event): > > button.setStyleSheet("background-color:yellow;") > > print("Leave") > > app = QtGui.QApplication(sys.argv) > > widget = QtGui.QWidget() > > button = QtGui.QToolButton(widget) > > button.setMouseTracking(True) > > buttonss = HoverButton(button) > > button.setIconSize(QtCore.QSize(200,200)) > > widget.show() > > sys.exit(app.exec_()) > > Hi uahmed, > > neither your description nor your code expresses your issue properly. > Here's a simpler version, that might be helpful: > > from PyQt4 import QtGui, QtCore > from PyQt4.QtCore import pyqtSignal > import os,sys > > class HoverButton(QtGui.QToolButton): > def enterEvent(self,event): > print("Enter") > button.setStyleSheet("background-color:#45b545;") > > def leaveEvent(self,event): > button.setStyleSheet("background-color:yellow;") > print("Leave") > > app = QtGui.QApplication(sys.argv) > button = HoverButton() > button.show() > sys.exit(app.exec_()) > > > Pete > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt