Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filechooser: Use full path #6624

Merged
merged 1 commit into from
Sep 26, 2020
Merged

Filechooser: Use full path #6624

merged 1 commit into from
Sep 26, 2020

Conversation

s0h3ck
Copy link
Contributor

@s0h3ck s0h3ck commented Nov 28, 2019

Description

When the path attribute is set, the full path is duplicated. Here is an example:
https://github.com/kivy/kivy/blob/master/kivy/uix/filechooser.py#L615

self.path = ./data/images/
entry.path = data/images/minecraft/skeleton.png

Example of the problem

The problem is with join. See the example here:

from os.path import abspath
print(abspath(join('./data/images/', 'data/images/minecraft/skeleton.png')))
# /home/s0h3ck/data/images/data/images/minecraft/skeleton.png
print(abspath(join('./data/images/', '/home/s0h3ck/data/images/minecraft/skeleton.png')))
# /home/s0h3ck/data/images/minecraft/skeleton.png

Suggestions

First

self.selection = abspath(entry.path)
https://github.com/kivy/kivy/blob/master/kivy/uix/filechooser.py#L615

Second

https://github.com/kivy/kivy/blob/master/kivy/uix/filechooser.py#L690
self.path = abspath(self.path)

Information

I applied the second suggestion because I don't know if the first suggestion can break something. on Windows or MacOS. The first would be better for performance because the second is called more than once.

@welcome
Copy link

welcome bot commented Nov 28, 2019

Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines.

@Zen-CODE
Copy link
Member

Zen-CODE commented Sep 26, 2020

Nice, thanks. I struggled to reproduce this. Setting the path to a relative path was the trick. It crashes on selection, and this fixes it. Thanks +1

Copy link
Member

@Zen-CODE Zen-CODE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the path on initialization to a relative path crashes the filechooser on selection. This fixes that problem.

@Zen-CODE Zen-CODE merged commit f6c0747 into kivy:master Sep 26, 2020
@welcome
Copy link

welcome bot commented Sep 26, 2020

Congrats on merging your first pull request! 🎉🎉🎉

@Zen-CODE Zen-CODE mentioned this pull request Oct 20, 2020
@matham matham added this to the 2.0.0 milestone Oct 28, 2020
@matham matham changed the title Update filechooser.py Filechooser: Use full path Dec 8, 2020
@matham matham added the Component: Widgets kivy/uix, style.kv label Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Widgets kivy/uix, style.kv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants