wxpython dialog - do something after ShowModal()?

Iain King iainking at gmail.com
Tue May 13 10:06:07 EDT 2008


On May 13, 2:43 pm, Iain King <iaink... at gmail.com> wrote:
> On May 13, 2:20 pm, Larry Bates <larry.ba... at websafe.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



More information about the Python-list mailing list