You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from os.path import expanduser
from traits.api import HasTraits, File, Unicode
from traitsui.api import FileEditor, Item, View
class Foo(HasTraits):
f = Unicode()
def _f_default(self):
return expanduser("~")
view = View(Item('f', editor=FileEditor(), show_label=False),resizable=True)
foo = Foo()
foo.edit_traits(view=view)
Note the default style.
Use the folder icon to open the native directory browser.
Navigate to the Desktop and choose "Open".
The resulting path has an extra <username> appended after Desktop.
In [11]: traitsui.__version__
Out[11]: '6.0.0'
In [13]: pyface.__version__
Out[13]: '6.0.0'
PyQt version 4.12-1
The text was updated successfully, but these errors were encountered:
I think this is sort-of expected/desirable behavior for FileEditor. It is expecting you to specify a filename that may not currently exist (the default is dialog_style='open'; you probably want dialog_style='save' for this use case). It populates the "File name:" field (which is the basename of the eventual complete filename that it returns) with the basename of the old value being edited. Pressing "Open" combines the currently-viewed directory with the basename to construct the new edited value.
Using DirectoryEditor, the edited value is the directory whose contents are being displayed. I think that's the behavior that you wanted in this use case.
The extra 'eric' after closing is definitely the correct behaviour based on the appearance of the dialog before closing. Assuming that it displayed C:\Users with directory eric selected when you first open the dialog, then everything is as it should be with the dialog, and the behaviour of remembering eric as you change directories is baked in Windows dialog behaviour that we don't control.
It would be useful to know what it is that you are trying to do (select a directory? open a file? save a file?) as you may want different options and/or editors.
Finally, is there a reason you are using a Unicode instead of a File or Directory trait?
Note the default
style
.Use the folder icon to open the native directory browser.
Navigate to the Desktop and choose "Open".
The resulting path has an extra
<username>
appended afterDesktop
.PyQt version 4.12-1
The text was updated successfully, but these errors were encountered: