wxpython dialog - do something after ShowModal()?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Iain King

    wxpython dialog - do something after ShowModal()?

    Hi. I have a modal dialog whcih has a "Browse..." button which pops
    up a file selector. This all works fine, but the first thing the user
    has to do when they open the dialog is select a file, so I would like
    the dialog to automatically call the onBrowse function as soon as the
    dialog opens. However, I don't know how to do this.

    dlg.ShowModal()
    onBrowse()

    obviously doesn't work, and neither does the reverse. I was hoping
    that the dialog would throw some kind of "I have been shown" event,
    but it doesn't (as far as I can tell). How do I make the dialog do
    something as soon as it's been shown?

    Iain
  • Larry Bates

    #2
    Re: wxpython dialog - do something after ShowModal()?

    Iain King wrote:
    Hi. I have a modal dialog whcih has a "Browse..." button which pops
    up a file selector. This all works fine, but the first thing the user
    has to do when they open the dialog is select a file, so I would like
    the dialog to automatically call the onBrowse function as soon as the
    dialog opens. However, I don't know how to do this.
    >
    dlg.ShowModal()
    onBrowse()
    >
    obviously doesn't work, and neither does the reverse. I was hoping
    that the dialog would throw some kind of "I have been shown" event,
    but it doesn't (as far as I can tell). How do I make the dialog do
    something as soon as it's been shown?
    >
    Iain
    If the only things on your modal dialog are Browse and cancel, just call the
    wx.FileDialog directly and eliminate the intermediate modal dialog. If not
    don't bind the FileDialog to a button, just create an instance of it as the last
    you do in the __init__ method of the modal dialog code.

    If this doesn't help, you will have better luck posting to wxpython newsgroup.

    -Larry

    Comment

    • Iain King

      #3
      Re: wxpython dialog - do something after ShowModal()?

      On May 13, 2:20 pm, Larry Bates <larry.ba...@we bsafe.com`wrote :
      Iain King wrote:
      Hi. I have a modal dialog whcih has a "Browse..." button which pops
      up a file selector. This all works fine, but the first thing the user
      has to do when they open the dialog is select a file, so I would like
      the dialog to automatically call the onBrowse function as soon as the
      dialog opens. However, I don't know how to do this.
      >
      dlg.ShowModal()
      onBrowse()
      >
      obviously doesn't work, and neither does the reverse. I was hoping
      that the dialog would throw some kind of "I have been shown" event,
      but it doesn't (as far as I can tell). How do I make the dialog do
      something as soon as it's been shown?
      >
      Iain
      >
      If the only things on your modal dialog are Browse and cancel, just call the
      wx.FileDialog directly and eliminate the intermediate modal dialog. If not
      don't bind the FileDialog to a button, just create an instance of it as the last
      you do in the __init__ method of the modal dialog code.
      >
      If this doesn't help, you will have better luck posting to wxpython newsgroup.
      >
      -Larry
      The dialog doesn't only let you call the file dialog, it does other
      stuff too. Your suggestion of __init__ sounded promising, but neither
      giving the dialog an __init__() method nor an OnInit() method worked.
      Thanks anyway.

      Iain

      Comment

      • Iain King

        #4
        Re: wxpython dialog - do something after ShowModal()?

        On May 13, 2:43 pm, Iain King <iaink...@gmail .comwrote:
        On May 13, 2:20 pm, Larry Bates <larry.ba...@we bsafe.com`wrote :
        >
        >
        >
        Iain King wrote:
        Hi. I have a modal dialog whcih has a "Browse..." button which pops
        up a file selector. This all works fine, but the first thing the user
        has to do when they open the dialog is select a file, so I would like
        the dialog to automatically call the onBrowse function as soon as the
        dialog opens. However, I don't know how to do this.
        >
        dlg.ShowModal()
        onBrowse()
        >
        obviously doesn't work, and neither does the reverse. I was hoping
        that the dialog would throw some kind of "I have been shown" event,
        but it doesn't (as far as I can tell). How do I make the dialog do
        something as soon as it's been shown?
        >
        Iain
        >
        If the only things on your modal dialog are Browse and cancel, just call the
        wx.FileDialog directly and eliminate the intermediate modal dialog. If not
        don't bind the FileDialog to a button, just create an instance of it as the last
        you do in the __init__ method of the modal dialog code.
        >
        If this doesn't help, you will have better luck posting to wxpython newsgroup.
        >
        -Larry
        >
        The dialog doesn't only let you call the file dialog, it does other
        stuff too. Your suggestion of __init__ sounded promising, but neither
        giving the dialog an __init__() method nor an OnInit() method worked.
        Thanks anyway.
        >
        Iain
        After having a hunt through the wxpython mailing list archives I found
        the answer: the event is EVT_INIT_DIALOG :

        dlg.Bind(wx.EVT _INIT_DIALOG, onInit, dlg)

        work. Thanks for the pointer.

        Iain

        Comment

        • Gabriel Genellina

          #5
          Re: wxpython dialog - do something after ShowModal()?

          En Tue, 13 May 2008 09:41:25 -0300, Iain King <iainking@gmail .com>
          escribió:
          Hi. I have a modal dialog whcih has a "Browse..." button which pops
          up a file selector. This all works fine, but the first thing the user
          has to do when they open the dialog is select a file, so I would like
          the dialog to automatically call the onBrowse function as soon as the
          dialog opens. However, I don't know how to do this.
          I've seen you already answered your question. But are you sure that doing
          this is a good thing? If you try to be too clever or too helpful the
          interfase may become annoying at some times. You can't guess the user's
          intention or read his mind.
          By example, what if I already have the desired file name copied in the
          clipboard? I don't want the file selector to pop up.

          I completely *hate* Windows programs with a "Browse for folder" button
          that don't let me paste a name, neither start opened at the currently
          selected folder.

          --
          Gabriel Genellina

          Comment

          • David C. Ullrich

            #6
            Re: wxpython dialog - do something after ShowModal()?

            In article
            <a14c2400-e88b-4d90-80bb-a5fe27fedea3@m4 4g2000hsc.googl egroups.com>,
            Iain King <iainking@gmail .comwrote:
            Hi. I have a modal dialog whcih has a "Browse..." button which pops
            up a file selector. This all works fine, but the first thing the user
            has to do when they open the dialog is select a file, so I would like
            the dialog to automatically call the onBrowse function as soon as the
            dialog opens. However, I don't know how to do this.
            >
            dlg.ShowModal()
            onBrowse()
            >
            obviously doesn't work, and neither does the reverse. I was hoping
            that the dialog would throw some kind of "I have been shown" event,
            but it doesn't (as far as I can tell). How do I make the dialog do
            something as soon as it's been shown?
            It's too bad that you found an answer. You _shouldn't_ have your
            dialog pop up a file-selection box as soon as it's shown! That's
            not the way dialogs usually work, so you're going to confuse
            people.

            Instead, first pop up the file-selection box, and then pop up
            the dialog (without the Browse button) to do whatever else it
            does after you've got the filename.
            Iain

            Comment

            • Iain King

              #7
              Re: wxpython dialog - do something after ShowModal()?

              On May 14, 9:37 pm, "David C. Ullrich" <dullr...@spryn et.comwrote:
              In article
              <a14c2400-e88b-4d90-80bb-a5fe27fed...@m4 4g2000hsc.googl egroups.com>,
              Iain King <iaink...@gmail .comwrote:
              >
              Hi. I have a modal dialog whcih has a "Browse..." button which pops
              up a file selector. This all works fine, but the first thing the user
              has to do when they open the dialog is select a file, so I would like
              the dialog to automatically call the onBrowse function as soon as the
              dialog opens. However, I don't know how to do this.
              >
              dlg.ShowModal()
              onBrowse()
              >
              obviously doesn't work, and neither does the reverse. I was hoping
              that the dialog would throw some kind of "I have been shown" event,
              but it doesn't (as far as I can tell). How do I make the dialog do
              something as soon as it's been shown?
              >
              It's too bad that you found an answer. You _shouldn't_ have your
              dialog pop up a file-selection box as soon as it's shown! That's
              not the way dialogs usually work, so you're going to confuse
              people.
              >
              Instead, first pop up the file-selection box, and then pop up
              the dialog (without the Browse button) to do whatever else it
              does after you've got the filename.
              >
              That's actually what happens - the dialog throws EVT_INIT_DIALOG
              before it displays itself. Not that I really agree with you. I don't
              think that a "do such-and-such dialog" appearing with a "Select file
              for such-and-such" file selector on top of it, the file selector being
              in focus, is confusing for the user. Actually, I think it'd be
              friendlier - the user can see where the data from the file is going,
              so has an immediate reminder of what the (generic) file selector is
              for.

              Comment

              Working...