0

In a shotgun app and pyqt window. Can I disable the close event ( event.ignore() ) anyway?

Hi Guys!

In a normal PyQt window that isnt being called by a shotgun app, if there is un-submitted data that i dont want the user to loose. I can check and event.ignore() in the def closeEvent(self,event): but that wont work here because I am not the parent app.

I was wondering if you knew a way around this?

Cheers for the help!

 

PS here is the work around that phil and I tried in the __init__.py that calls the app

 


def show_dialog(app):
    # defer imports so that the app works gracefully in batch modes
    from .rigtastic import AppDialog
    # show the dialog window using the engine's show_dialog method
    widget = app.engine.show_dialog("Rigtastic", app, AppDialog, app)
    widget.closeEvent = closeEvent
    bIcon.SetTankIcon(widget)



def closeEvent(event):

    print "CLOSE EVENT RUNNING"

    event.ignore()

댓글 9개

  • 0
    Avatar
    Manne Öhrström

    Nick!

    Terribly sorry about the delayed response here! We just realised we have missed this (and another couple of posts)! 

    The good news is that we found this bug ourselves last week and have just pushed a bug fix to the core master:

    https://github.com/shotgunsoftware/tk-core/commit/d99e02cbf05135435f3e0e556a8cbfc001677d16

    It will go out in the next core release - and once released, closeEvent should work as expected for toolkit dialogs!

    Apologies for the inconvenience!

    Manne

  • 0
    Avatar
    Hughes- Nick

    Cheers Manne! Hope you are well and have a good week!

  • 0
    Avatar
    Hughes- Nick

    Evening Manne!

    Just tried adding the close function in our app and it sadly still doesn't work with the core update?

    I tried adding the function into the app initiate and the app.py that calls the app modules though sadly the event.ignore() is ... ignored, with a slight sense of irony lol. Any chance you have tested this and know what I might be doing wrong or what I should be doing?

    Have a great weekend mate!

  • 0
    Avatar
    Manne Öhrström

    Hello Nick!

    Sorry to hear that - was that with the new 14.77 core?

    I know one of our guys wrote an app that was using this exact thing - an intercept to check "are you sure?" inside of the closeEvent, with an option for the user to cancel the close. I'll ask the team on Monday about it!

  • 0
    Avatar
    Hughes- Nick

    Hi Manne!

    Yes it was ran on the 14.77 core and from our app in max.

    I ran the same closeEvent function on a standalone pyqt window to check that it work and ran fine.   


    def closeEvent(self,event):

          reply = QtGui.QMessageBox.question(self, 'Message',

          "Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)

          if reply == QtGui.QMessageBox.Yes:
                event.accept()
            else:
                event.ignore()

    Thanks for the help!

  • 0
    Avatar
    Hughes- Nick

    Have you got an example of the working version I could see?

  • 0
    Avatar
    Hughes- Nick

    Just checked the closeEvent in one of our project level tools, and that worked and stopped the window closing, so it seems like its the implementation in max that seems to be the problem.

    Cheers

  • 0
    Avatar
    Manne Öhrström

    Ahh, that makes perfect sense! I don't think we tested the change in all the various engines before we released. Sorry about that! 

    I'll check in with the guys in our dailies today and see if we get this looked at. Is this a high priority for you guys?

    With the 3dsmax engine, we are wrapping around the blur system for dialog creation - it is possible that this is what is causing it - the event may be consumed outside of toolkit altogether - we would have to investigate to see what is going on!

    Thanks for testing this!

    Manne

  • 0
    Avatar
    Hughes- Nick

    Ah ok brilliant cheers. Its not a high priority, but would be useful as it can cause some problems with our users saving our data and making checks to that effect.

    Its the same priority with the minimize problem that Phil has a ticket in for. Its where once the pyqt app window or max window is minimized  the app cannot be maximized or seen again.

     

    Cheers

댓글을 남기려면 로그인하세요.