[wxPython-dev] How to kill/destroy wx.dirDialog programatically?

That is really strange, if I use wx.Dialog it is shown and DirDialog
is sub-classing wx.Dialog.
Hopefully someone can shed some light on this.
Werner
P.S.
copy to wxPython-user list to get greater exposer

···

On 20/11/2013 16:04, Nilay Anand wrote:

    Find attached sample script that keep printing all

active windows reference in other thread.

    Nilay


      On Wednesday, November 20, 2013 7:07:35 PM UTC+5:30, werner

wrote:

        On

20/11/2013 13:51, Nilay Anand wrote:

        > Thanks Warner for your reply.


        >


        > Interestingly, wx.GetTopLevelWindows() do not

detect/returns open

        > DirDialog reference.

It’s not that strange. The wx.DirDialog class is a proper subclass
of wx.Dialog, but the window displayed by DirDialog is not a window
created and managed by wx. It calls an operating system API
(SHBrowseForFolder), which creates its own window, and that API
ignores the window styles set by the class.

···

Werner wrote:

  That is really strange, if I use wx.Dialog it is shown and

DirDialog is sub-classing wx.Dialog.

  Hopefully someone can shed some light on this.
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

It is also worth noting that dialogs are *NOT* destroyed automatically by wxWidgets.

The reason is that there's no reason they need to be allocated within the heap ('cept for the fact that python doesn't support that of course - but wxWidgets is a c++ library) . If wxWidgets tried to free the memory and that memory was on the stack it'd (rightfully) crash.

Not-dialogs need to exist on the heap because their destruction may require wxWidgets to process events and those events will have the ability to get the thing they are about and use it.

You could do this at the top of a destructor, if and only if it is the first destructor being run. Base classes are not destroyed until the subclass has finished being destroyed, the event emitting part would be in the wxFrame destructor (or lower), which'd run after the sub-class had been destroyed, it'd be a difficult and complicated mess.

Hence the destroy method and leaving wxWidgets to it and the special treatment of dialogs.

Alec

···

On 20/11/13 18:27, Tim Roberts wrote:

Werner wrote:

That is really strange, if I use wx.Dialog it is shown and DirDialog is sub-classing wx.Dialog.

Hopefully someone can shed some light on this.

It's not that strange. The wx.DirDialog class is a proper subclass of wx.Dialog, but the window displayed by DirDialog is not a window created and managed by wx. It calls an operating system API (SHBrowseForFolder), which creates its own window, and that API ignores the window styles set by the class.
--
Tim Roberts,timr@probo.com
Providenza & Boekelheide, Inc.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

That is really strange, if I use wx.Dialog it is shown and DirDialog

is sub-classing wx.Dialog.
Hopefully someone can shed some light on this.

DirDialog is a wrapper around the system file dialog–maybe that makes a difference.

Chris

···

On 20/11/2013 16:04, Nilay wx.GetTopLevelWindows() do not
detect/returns open

        > DirDialog reference.