Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

wxpython dialog - do something after ShowModal()?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


iainking at gmail

May 13, 2008, 5:41 AM

Post #1 of 7 (612 views)
Permalink
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
--
http://mail.python.org/mailman/listinfo/python-list


larry.bates at websafe

May 13, 2008, 6:20 AM

Post #2 of 7 (588 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

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
--
http://mail.python.org/mailman/listinfo/python-list


iainking at gmail

May 13, 2008, 6:43 AM

Post #3 of 7 (587 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

On May 13, 2:20 pm, Larry Bates <larry.ba...@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
--
http://mail.python.org/mailman/listinfo/python-list


iainking at gmail

May 13, 2008, 7:06 AM

Post #4 of 7 (587 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

On May 13, 2:43 pm, Iain King <iaink...@gmail.com> wrote:
> On May 13, 2:20 pm, Larry Bates <larry.ba...@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
--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

May 13, 2008, 8:49 PM

Post #5 of 7 (575 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

En Tue, 13 May 2008 09:41:25 -0300, Iain King <iainking [at] gmail>
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

--
http://mail.python.org/mailman/listinfo/python-list


dullrich at sprynet

May 14, 2008, 1:37 PM

Post #6 of 7 (577 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

In article
<a14c2400-e88b-4d90-80bb-a5fe27fedea3 [at] m44g2000hsc>,
Iain King <iainking [at] gmail> 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?

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
--
http://mail.python.org/mailman/listinfo/python-list


iainking at gmail

May 15, 2008, 1:19 AM

Post #7 of 7 (575 views)
Permalink
Re: wxpython dialog - do something after ShowModal()? [In reply to]

On May 14, 9:37 pm, "David C. Ullrich" <dullr...@sprynet.com> wrote:
> In article
> <a14c2400-e88b-4d90-80bb-a5fe27fed...@m44g2000hsc.googlegroups.com>,
> Iain King <iaink...@gmail.com> 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?
>
> 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.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.