Right now the file chooser opens the very root as the default location but i want it to skip that and open as default the internal storage (sdcard) and the user can go down from there.
this is a snipped of my code so far The class:
class LoadDialog(FloatLayout):
load = ObjectProperty(None)
cancel = ObjectProperty(None)
The definition in the kv file
<LoadDialog>:
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"
FileChooserListView:
id: filechooser
BoxLayout:
size_hint_y: None
height: 30
Button:
text: "Cancel"
on_release: root.cancel()
Button:
text: "Load"
on_release: root.load(filechooser.path, filechooser.selection)
The actual load code:
def show_load(self):
content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title="Load file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def load(self, path, filename):
wimg = os.path.join(path, filename[0])
self.image_source = wimg
self.dismiss_popup()
So basically the user should not have to go up 1 directory to get to the sdcard, should already be there. Worst case scenario is filtering all the other folders there except the ones that contain the word sdcard.
Set the path attribute.
FileChooserListView:
id: filechooser
path: "/your/path"
To find a directory on your system with python, you can do something like this:
import os
for root, dirs, files in os.walk("/"):
for name in dirs:
if name == "DCIM":
print(root, name)
Just be aware that it might find two or more directories named DCIM, on your sdcard and internal storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With