A class attribute should do the trick. class Region(QtCore.QObject): clicked = False
Set to true in any of the events and it will persist across runs. Assuming that, by "once" you mean once per run, and not once *ever*, as that would involve storing clicked somewhere where it could last across sessions, like on disk. On 31 March 2014 11:43, Arvid Schneider <[email protected]> wrote: > Hey Group, > > I have a command which returns click and release coordinates of the mouse > pointer. I should only run once though, and I cant figure out how to do > that. > Can someone give me an insight please. > The wrapinstance method is a custom one (it just checks if PySide or PyQt4 > ist running) > > class Region(QtCore.QObject): >> >> """ Class contains methods to provide information for a specific >>> selected region """ >> >> >>> def eventFilter(self, obj, event): >> >> >>> if event.type() == QtCore.QEvent.MouseButtonPress: >> >> >>> print QtGui.QCursor().pos() >> >> press = QtGui.QCursor().pos() >> >> >>> return False >> >> if event.type() == QtCore.QEvent.MouseButtonRelease: >> >> >>> print QtGui.QCursor().pos() >> >> release = QtGui.QCursor().pos() >> >> >>> return False >> >> # Call Base Class Method to Continue Normal Event Processing >> >> return super(Region, self).eventFilter(obj, event) >> >> >>> def regionDataOnSetup(): >> >> >>> global filter >> >> filter = Region() >> >> view = omui.M3dView.active3dView() >> >> viewWidget = wrapinstance(long(view.widget()), QtCore.QObject) >> >> viewWidget.installEventFilter(filter) >> >> > > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/f4b50bee-75d5-4359-b6e8-c6c24ab065c9%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/f4b50bee-75d5-4359-b6e8-c6c24ab065c9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- *Marcus Ottosson* [email protected] -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAvxpTR-GAL3X%2B5OzrT9xO%2Bv4rZ02aNNVJt_Jagie5csA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
