DirDialog always creates dir if non-existent

When I use a DirDialog, a new directory is created if the user enters a non-existent name in the Location field. I’d like to validate the name with app specific criteria and create the directory myself if desired. This behavior occurs whether or not I specify wx.DD_DEFAULT_STYLE. Is this correct behavior for this class? Is there any way I can override it? Is there a different widget I can use?

I am using python-wxgtk3.0 on Ubuntu 16.4.

Thank you.
Mark

schnepper wrote:

This behavior occurs whether or not I specify wx.DD_DEFAULT_STYLE.

wx.DD_DEFAULT_STYLE doesn't include the flag you need. Use wx.DD_DIR_MUST_EXIST.

> wx.DD_DIR_MUST_EXIST: The dialog will allow the user to choose only an existing folder. When this style is not given, a “Create new directory” button is added to the dialog (on Windows) or some other way is provided to the user to type the name of a new folder.

···

--
James Scholes
http://twitter.com/JamesScholes

Thanks, James. I tried that and it had no effect. With or without that flag, the user is able to type a new value into the Location field and a new directory is created. My guess is that it is a feature of the underlying GTK dialog. What I want is for the user to be able to select an existing directory or specify a new directory without creating it. I think I’ll have to use a TreeCtl and populate it myself. I’ve attached a short program that illustrates the problem.

Mark

dirdi.py (1.42 KB)

···

On Wednesday, September 6, 2017 at 4:47:34 PM UTC-4, James Scholes wrote:

schnepper wrote:

This behavior occurs whether or not I specify wx.DD_DEFAULT_STYLE.

wx.DD_DEFAULT_STYLE doesn’t include the flag you need. Use
wx.DD_DIR_MUST_EXIST.

wx.DD_DIR_MUST_EXIST: The dialog will allow the user to choose only
an existing folder. When this style is not given, a “Create new
directory” button is added to the dialog (on Windows) or some other way
is provided to the user to type the name of a new folder.


James Scholes

http://twitter.com/JamesScholes

You may want to start with the wx.GenericDirCtrl class.

Robin

···

On Wednesday, September 6, 2017 at 2:41:06 PM UTC-7, schnepper wrote:

Thanks, James. I tried that and it had no effect. With or without that flag, the user is able to type a new value into the Location field and a new directory is created. My guess is that it is a feature of the underlying GTK dialog. What I want is for the user to be able to select an existing directory or specify a new directory without creating it. I think I’ll have to use a TreeCtl and populate it myself. I’ve attached a short program that illustrates the problem.

Mark

On Wednesday, September 6, 2017 at 4:47:34 PM UTC-4, James Scholes wrote:

schnepper wrote:

This behavior occurs whether or not I specify wx.DD_DEFAULT_STYLE.

wx.DD_DEFAULT_STYLE doesn’t include the flag you need. Use
wx.DD_DIR_MUST_EXIST.

wx.DD_DIR_MUST_EXIST: The dialog will allow the user to choose only
an existing folder. When this style is not given, a “Create new
directory” button is added to the dialog (on Windows) or some other way
is provided to the user to type the name of a new folder.


James Scholes

http://twitter.com/JamesScholes