DirDialog always creates dir if non-existent

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

DirDialog always creates dir if non-existent

schnepper
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

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DirDialog always creates dir if non-existent

James Scholes
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 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: DirDialog always creates dir if non-existent

schnepper
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
<a href="http://twitter.com/JamesScholes" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2FJamesScholes\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6ZgoUeZElthUwf1lkQibh0cP4sA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2FJamesScholes\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6ZgoUeZElthUwf1lkQibh0cP4sA&#39;;return true;">http://twitter.com/JamesScholes

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

dirdi.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DirDialog always creates dir if non-existent

Robin Dunn
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
<a href="http://twitter.com/JamesScholes" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2FJamesScholes\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6ZgoUeZElthUwf1lkQibh0cP4sA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2FJamesScholes\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6ZgoUeZElthUwf1lkQibh0cP4sA&#39;;return true;">http://twitter.com/JamesScholes

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.