0

I want to change the default path location (to the desktop) of the FileChooserIconView kivy module. My attempt:

main.py

class LoadDialog(FloatLayout):
    load = ObjectProperty(None)
    cancel = ObjectProperty(None)
    
    def get_default_path(self): 
        self.path = os.path.expanduser("~/Desktop") ## Get desktop path. 

my.kv

<LoadDialog>:
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"
     
        FileChooserIconView:
            id: filechooser
            path: root.get_default_path() ## THE PROBLEM. Calling but not working. 
Community
  • 1
  • 1
Ushuaia81
  • 495
  • 1
  • 6
  • 14

1 Answers1

0

I needed to add a return statment to the get_default_path function:

#main.py
class LoadDialog(FloatLayout):
    load = ObjectProperty(None)
    cancel = ObjectProperty(None)

    def get_default_path(self): 
        self.path = os.path.expanduser("~/Desktop") 
        return self.path ## I added the return statement

#my.kv
<LoadDialog>:
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"

        FileChooserIconView:
            id: filechooser
            path: root.get_default_path() ## WORKING 
Ushuaia81
  • 495
  • 1
  • 6
  • 14