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?
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.
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.
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.
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.