crahan / ipyfilechooser

Python file chooser widget for use in Jupyter/IPython in conjunction with ipywidgets
MIT License
103 stars 20 forks source link

Chooser should have propery, 'value' which returns same as 'selected' #57

Closed tombelpasso closed 3 years ago

tombelpasso commented 3 years ago

Most ipywidgets have a 'value' attribute. The 'selected' property naming makes sense for the chooser, but even drop down selectors have 'value' .

crahan commented 3 years ago

Thank you for the suggestion. This has now been added and pushed to the width_and_fixes branch. You can now use a .value property to return the same value as .selected. Please feel free to checkout the new branch and test.

tombelpasso commented 3 years ago

I tested the suggested branch and fc.value return None, while fc.selected returned the full file path.

Setting the width with fc.layout.width = 'auto' works.

Code:

Print the selected path, filename, or both

print(fc.selected_path) print(fc.selected_filename) print(fc.selected) print(fc.value)

Output: C:\Portable\Documents\Python laserRepairNew.ipynb C:\Portable\Documents\Python\laserRepairNew.ipynb None

crahan commented 3 years ago

I'm sorry, but I'm unable to replicate that issue. Here's a recording using your sample code. As you can see, both .selected and .value return the proper value:

https://user-images.githubusercontent.com/172588/130286161-268d92b2-d5da-4a8d-94d2-2716ad0f52db.mov

I did notice an issue with the width fix however which now causes rendering issues when the selected path becomes too long and the buttons are not showing their full text as a result anymore. I'll have to revisit the earlier fix to find a better way to handle this so it doesn't break.

Update: updated the layout code so both button do not resize below a certain mininum width and button labels always remain fully visible.

crahan commented 3 years ago

v0.5.0 has now been published to PyPi. Conda-forge feedstock release will follow shortly. Thanks again for reporting this issue and helping to make the project better!