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

2008-05-15 Thread Iain King
On May 14, 9:37 pm, David C. Ullrich [EMAIL PROTECTED] wrote:
 In article
 [EMAIL PROTECTED],
  Iain King [EMAIL PROTECTED] 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


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

2008-05-14 Thread David C. Ullrich
In article 
[EMAIL PROTECTED],
 Iain King [EMAIL PROTECTED] 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


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

2008-05-13 Thread Larry Bates

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


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

2008-05-13 Thread Iain King
On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] 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


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

2008-05-13 Thread Iain King
On May 13, 2:43 pm, Iain King [EMAIL PROTECTED] wrote:
 On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] 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


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

2008-05-13 Thread Gabriel Genellina
En Tue, 13 May 2008 09:41:25 -0300, Iain King [EMAIL PROTECTED]  
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