Hello. I have been trying to find a way to run a function when the mouse is on top of a button. I tried to overrride the QPushButton class, and the enterEvent function, but I dont have any results. This is what I have:
class CustomButtom(QtGui.QPushButton):
def __init__(self):
pass
def mouseMoveEvent(self, event):
print("in focus")
def enterEvent(self, event):
print("Enter")
def leaveEvent(self, event):
print("Leave")
I have an extra function to create the buttons, and in there I set the setMouseTracking(1) to 1.
What am I missing?. My guess is that I need to connect the enter and and leave event, but, to who?I thought they would be connected to the mouse movement already.
Thanks.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/693291aa-7811-42ad-8660-3e51b25ebe3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d3b8286d-39f9-4ad0-9f3d-3d72bfd7ea3f%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c1fd2da1-c565-44a4-88f7-eeabee24317b%40googlegroups.com.
but I still have no results when my cursor hovers on top of the button:
This works for me.
from PySide import QtGui
class CustomButtom(QtGui.QPushButton):
def enterEvent(self, event):
print("Enter")
def leaveEvent(self, event):
print("Leave")
button = CustomButton()
button.show()
# Enter
# Leave
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2tywvG4xg4Vg65Bwf%2B6Vq1iZukOu7EQBEnr_3tTAn%2B%3DQ%40mail.gmail.com.
Hi Justin. I have 2 questions tho. You mention that I am operating in my custom CustomButtom logic, but when I create a button, I have the text from that custom class. If it`s picking up the default QPushButton class, why I have the text?I think I`m confused about this.
The second thing is that you say create and save. My guess is that I need to create an instance from the CustomButtom class, and return it, which is something I am not doing right now. Is that it?
thanks again for your time, it would take me some time to figure it out by myself.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8bcc6aca-04b6-4fef-93b9-8df019f1baba%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4864dffa-cb76-4150-b53f-d37cd9dacb52%40googlegroups.com.