glitch in select_file?
Closed this issue · 4 comments
hi @gtalarico ,
first off thank for the awesome gui wrappers. (-;
I use them quite a bit. Today is the first time I needed
select_file and it seems to me that there might be a typo
in the example code on readthedocs for the select_file:
>>> from rpw.ui.forms import select_file
>>> filepath = select_file('Revit File ('*.rvt)|*.rvt'))
File "<stdin>", line 1
filepath = select_file('Revit File ('*.rvt)|*.rvt'))
^
SyntaxError: unexpected token '.'
So I thought, oh well I do a quick PR with the
(what I thought might be the ) fixed example which runs:
filepath = select_file('Revit File (*.rvt)|*.rvt)')
but when the file dialog pops up with the preset *.rvt filter, it seems like
everything except for directories is filtered away, even rvt. If I provide
the path as a string into this dialog, then filepath is considered not defined.
If I choose to not use the filter the dialog works as expected for all file
types, but obviously no filtering.
(I ran it in Revit 2017.2.2 in RevitPythonShell, rpw version: 1.7.4)
Hi!
I think the example has some extra single quotes as you probably noticed.
And I think on your 2nd attempt , you got an extra orphan parenthesis at the end
Take a look at the source code is pretty straight forward.
https://github.com/gtalarico/revitpythonwrapper/blob/master/rpw/ui/forms/os_dialog.py#L25
That filter string is standard and just gets passed to this property:
https://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.filter(v=vs.110).aspx
Thanks for the quick reply and for the links!
When I paste a rvt-adjusted version of the MSDN page into the search string it works:
"""
model_path = select_file("Revit models (.rvt)|.rvt|All files (.)|.")
"""
Thanks a lot! (-:
Awesome. You should able to remove the all files part as all if you desire.
Do you think you could contribute with a doc edit?
You can edit the .py file share above directly on github and the docs will update.