更改 kivy FileChooserIconView 模块中的默认路径
Change default path in kivy FileChooserIconView module
我想更改 FileChooserIconView kivy 模块的默认路径位置(到桌面)。我的尝试:
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.
我需要向 get_default_path 函数添加 return 语句:
#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
我想更改 FileChooserIconView kivy 模块的默认路径位置(到桌面)。我的尝试:
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.
我需要向 get_default_path 函数添加 return 语句:
#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