I'm new to kivy and I'm using FileChooserIconView to display the files. I am trying to display the current path of the file, however, it cannot show the full path of a file. It is possible to show the full path?
I have tried to set a root path, it can show the full path of a file. However, it will not show a “..” directory to go up to the root path. I want to show the ".." directory too.
This is my kivy code:
48 <Browse>:
49 title: 'Select the ouput directory'
50 size_hint: .8, .8 #the presentage size of the original window
51 auto_dismiss: False
52 FileChooserIconView:
53 path: '.'
54 id: fc2
55 filters: [root.is_dir]
56 on_selection:
57 BoxLayout:
58 size_hint_y: .1
59 orientation: 'horizontal'
60 GridLayout:
61 size_hint_y: None
62 height: 150
63 rows: 2
64 orientation: 'vertical'
65 spacing:1.5
66 BoxLayout:
67 Label:
69 text: "Path of directory: " + fc2.path
70 BoxLayout:
71 Button:
72 text: 'Back'
73 on_release: root.dismiss() #close the popup
74 Button:
75 text: "Choose"
76 on_release:
77 root.dismiss()
When I run this code and click the button "Browse", it will popup and show as follow: Path of directory: . and if I click "../", it can show the full path.
But I want to show the full path of the directory when I click the button "Browse".
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/4184e7b9-662c-49f6-8747-6fc78205f081%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
#: import pathlib pathlib
text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/0b4cd1b7-a29c-42b1-9a4d-cfa81d733f36%40googlegroups.com.
52 FileChooserIconView:
53 path: '.'
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/0b4cd1b7-a29c-42b1-9a4d-cfa81d733f36%40googlegroups.com.
You can set path in filechoose to the initial path you want:
path: ‘the/initial/path/you/want/’
You can use pathlib to get the absolute current working directory or the home directory.
path: str(pathlib. Path.cwd()) # the current working directory
OR
path: str(pathlib.Path.home()) # the home directory
these calls return a Path object, so need to be converted to strings to be used as the filechooser path.
Pathlib objects make it very easy to create paths.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e8b331d9-dd8c-4cd8-ac31-6f025b19f326%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e8b331d9-dd8c-4cd8-ac31-6f025b19f326%40googlegroups.com.