On Fri, Jul 5, 2019 at 6:21 AM likage <dissidia....@gmail.com> wrote:
> Got it, thanks! > > Is there a way in which I can also use script job to detects when my > custom tool is closed? > I am using `MayaQWidgetDockableMixin` in which the `closeEvent` is not > calling (`dockCloseEventTriggered` does gets called and executed if the > tool is docked) and it is not removing the scriptjobs that I have created.. > MayaQWidgetDockableMixin isn't exactly the same as using a normal QDockWidget set with your own widget. This custom maya mixin does its own configuration and wiring of signals. If you run help(MayaQWidgetDockableMixin) in your Script Editor you will see the functionality that it provides. You will find that it gives you a hook for when the dock widget is closed. Note though that closing the widget doesn't neccessarily mean it was deleted. It is likely just hidden unless you choose to delete on close. So you can use something like this: 1. from PySide import QtCore, QtGui 2. from maya.app.general.mayaMixin import MayaQWidgetDockableMixin 3. 4. # help(MayaQWidgetDockableMixin) 5. 6. class DockWidget(MayaQWidgetDockableMixin, QtGui.QDialog): 7. 8. def __init__(self, parent=None): 9. super(DockWidget, self).__init__(parent=parent) 10. self.resize(400,400) 11. self._has_init = False 12. 13. def dockCloseEventTriggered(self): 14. print "dockClose" 15. self._has_init = False 16. 17. def showEvent(self, e): 18. print "show" 19. if not self._has_init: 20. print " do setup stuff" 21. self._has_init = False 22. super(DockWidget, self).showEvent(e) This gives you a hook into when the dock is closed and when it is shown, tracking when it has actually been shown for the first time again rather than how the show event is going to be triggered constantly when you re-dock the widget around Maya. Justin -- > 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_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/42b20895-e304-4b11-9902-e9d48d0bf24e%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/42b20895-e304-4b11-9902-e9d48d0bf24e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1EcFjJygwxaQicKd2SnGtzp94PQCGzPo7fVh7S2xV%2BJQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.