Modal dialogs

  • active8

    active8 - 2004-09-06

    I create a modal dialog class from my main frame. That class' __init__ function is:

    def __init__(self, parent):
            self.prnt = parent
            ret = self.ShowModal()

    I'm wondering whether it's better to do:

    dlgNew = newDlg.create(self)
    ret = dlgNew.ShowModal()

    in the main frame - after the instanciation of the dialog class and it's subsequent __init__ call.

    Personally, I think it's better to do it in the __init__ function to keep all that implementation out of the main frame code, but maybe someone knows a reason  to do otherwise.



    • active8

      active8 - 2004-09-06

      Oops! It doesn't make sense to call EndModal(ret) if ret won't be set until ShowModal returns which won't happen until the dialog is dismissed with EndModal.

      The problem I can't wrap my mind around is that I want to call EndModal from an OK button or cancel button event handler - I'll do:


      But I don't know what happens when the close button "x" is clicked, i.e., do I still need to call EndModal?

      I'd hope that was in the default close event code.

      If I call EndModal in the handler and the "x" is clicked instead, I'd need it in the main frame code - don't know if calling EndModal twice will hurt or not, other than redundant code.

      But if I don't call EndModal in the handler, the dialog will never dismiss.

      All this circular stuff is making me dizzy :)



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks