<div dir="ltr">hi<br><br>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 .<br>
<br>i saved your script with the name of hover.py<br><br>from PyQt4 import QtGui, QtCore<br>from PyQt4.QtCore import pyqtSignal<br>import os,sys<br><br>class HoverButton(QtGui.QToolButton):<br>   def enterEvent(self,event):<br>
       print("Enter")<br>       self.setStyleSheet("background-color:#45b545;")<br><br>   def leaveEvent(self,event):<br>       self.setStyleSheet("background-color:yellow;")<br>       print("Leave")<br>
<br>and then i call it from another program and include "hover.py" <br><br>"program.py"<br><br>import os,sys<br>from functools import partial<br>from PyQt4 import QtGui, QtCore<br>import hover<br>class main():<br>
        def Qbutton(self):<br>                buttons["a1"] = QtGui.QToolButton(widget)<br>                buttons["a1"].setIconSize(QtCore.QSize(200,200))<br>                buttons["a1"] = hover.HoverButton()<br>
app= QtGui.QApplication(sys.argv)<br>sk = main()<br>buttons = {}<br>widget = QtGui.QWidget()<br>sk.Qbutton()<br>widget.show()<br>sys.exit(app.exec_())<br><br>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 <br>
<br><br><br><div class="gmail_quote">

On Wed, Feb 22, 2012 at 2:08 AM, Hans-Peter Jansen <span dir="ltr"><<a href="mailto:hpj@urpla.net" target="_blank">hpj@urpla.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>On Tuesday 21 February 2012, 03:27:41 uahmed wrote:<br>
> hi ,<br>
><br>
> I want to do hover i saw an example and then write a script which<br>
> will be use as i made program i am facing one problem that hover only<br>
> occur if u putt mouse on the left corner of button i want that it<br>
> will happen for all the button that if i move cursor on button then<br>
> it should change. here is my code<br>
><br>
> from PyQt4 import QtGui, QtCore<br>
> from PyQt4.QtCore import pyqtSignal<br>
> import os,sys<br>
><br>
> class HoverButton(QtGui.QToolButton):<br>
>     def enterEvent(self,event):<br>
>         print("Enter")<br>
>         button.setStyleSheet("background-color:#45b545;")<br>
><br>
>     def leaveEvent(self,event):<br>
>         button.setStyleSheet("background-color:yellow;")<br>
>         print("Leave")<br>
> app = QtGui.QApplication(sys.argv)<br>
> widget = QtGui.QWidget()<br>
> button = QtGui.QToolButton(widget)<br>
> button.setMouseTracking(True)<br>
> buttonss =  HoverButton(button)<br>
> button.setIconSize(QtCore.QSize(200,200))<br>
> widget.show()<br>
> sys.exit(app.exec_())<br>
<br>
</div></div>Hi uahmed,<br>
<br>
neither your description nor your code expresses your issue properly.<br>
Here's a simpler version, that might be helpful:<br>
<div><br>
from PyQt4 import QtGui, QtCore<br>
from PyQt4.QtCore import pyqtSignal<br>
import os,sys<br>
<br>
class HoverButton(QtGui.QToolButton):<br>
    def enterEvent(self,event):<br>
        print("Enter")<br>
        button.setStyleSheet("background-color:#45b545;")<br>
<br>
    def leaveEvent(self,event):<br>
        button.setStyleSheet("background-color:yellow;")<br>
        print("Leave")<br>
<br>
app = QtGui.QApplication(sys.argv)<br>
</div>button = HoverButton()<br>
button.show()<br>
sys.exit(app.exec_())<br>
<br>
<br>
Pete<br>
_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br></div>