I'm fairly new to Python and also Kivy and it's been giving me a hard time with this issue. The filechooser is working, also can choose multiple files but it only adds the last chosen file to the list and not the rest. What am I doing wrong?
Py File
class UploadWindow(Screen):
paths = StringProperty()
text_input = StringProperty()
def show_load_list(self):
content = LoadDialog(load=self.load_list, cancel=self.dismiss_popup)
self._popup = Popup(title="Load the sound files", content=content, size_hint=(.5, .5))
self._popup.open()
def load_list(self, path, filename):
with open(os.path.join(path, filename[0]), encoding="utf8", errors='ignore') as stream:
filename_actual = os.path.basename(filename.pop())
global importedfiles
importedfiles.append((filename_actual, path))
print(importedfiles)
self.dismiss_popup()
def dismiss_popup(self):
self._popup.dismiss()
class LoadDialog(FloatLayout):
load = ObjectProperty(None)
cancel = ObjectProperty(None)
Kv file
<LoadDialog>:
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"
FileChooserIconView:
id: filechooser
path: './'
filters: ['*.wav']
multiselect: True
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)