Destroy a dialog

Hi Andrea,

thank you very much wx.YieldIfNeeded( ) works perfect for me.

Oh! wx.BeginBusyCursor() and wx.EndBusyCursor() was something a forgot to delete
when I changed the old code into the new one… so thanks for mention it! : )

Leticia.

···

----- Mensaje original ----
De: Andrea Gavana andrea.gavana@gmail.com
Para: wxpython-users@lists.wxwidgets.org
Enviado: martes, 3 de junio, 2008 11:18:48
Asunto: Re: [wxpython-users] Destroy a dialog

Hi
Leticia,

On Tue, Jun 3, 2008 at 11:06 AM, leticia Fernandez wrote:

I have a normal file dialog:

dlg = wx.FileDialog(self, message=“Open…”, defaultDir=os.getcwd(),
defaultFile=“”, style=wx.OPEN)

   if dlg.ShowModal() == wx.ID_OK:

       filename = dlg.GetPath()
       wx.BeginBusyCursor()
       wx.EndBusyCursor()

       dlg.Destroy()

   # code to read the file

but the dialog isnt destroy until the file is read ( thatd be the rest of
the code). I tried to refresh it, but it didnt work.
Any idea of what Im doing
wrong?

Toplevel windows are usually not destroyed immediately, they are kept
alive until the next chain of events is processed by the application
main loop (if I am not wrong here…). But anyway, I think your
problem is that you are seeing your dialog staying on screen when you
are doing your text processing, and you want it to disappear as soon
as you call Destroy() on it. One solution, is to call:

wx.SafeYield() or
wx.Yield() or
wx.YieldIfNeeded()

Right after you call Destroy() on your dialog, i.e.:

dlg = wx.FileDialog(self, message=“Open…”, defaultDir=os.getcwd(),
defaultFile=“”, style=wx.OPEN)

    if dlg.ShowModal() == wx.ID_OK:

        filename = dlg.GetPath()

dlg.Destroy()
wx.SafeYield()

I don’t knwo why you have a sequence of wx.BeginBusyCursor() and
wx.EndBusyCursor() one after the other… they are usually meant to be
separated by several lines of code, informing the user your app is
doing something lengthy that needs some patience.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Enviado desde Correo Yahoo!
La bandeja de entrada más inteligente.