【发布时间】:2018-06-08 14:26:26
【问题描述】:
我是 Kivy 的新手,经过大量的反复试验,我得到了一个相当不错的工作应用程序。
我一生无法弄清楚的是如何让 FileChooser 根据我选择的内容(目录或其他)更新其路径。
.selection 总是返回并清空列表,.path 总是返回起始目录,即使我已经移动了。我在某个地方错过了一些活动,并且花了很多时间试图解决这个问题,并希望这里有人可以提供帮助。
我以为.selection 和.path 会在我导航时更新,但它们似乎停留在它们的第一个/默认值上。我创建了testbutton 只是为了看看我是否可以获得路径或选择来打印/更新。
一旦他们点击另一个按钮,这一切都会被触发
def testbutton(self,test,iconview,*args):
print(test,iconview.path)
filepop=Popup(title='SaveFile')
FileChooserLayout=BoxLayout(orientation='vertical')
ButtonArea=BoxLayout(orientation='horizontal',spacing=50,size_hint=(.5,.5),pos_hint={'center_x': 0.5, 'center_y': 0.5})
listview=FileChooserListView(path='somepath',dirselect=True)
test=listview.path
testbutton=Button(text='test',on_press=partial(self.testbutton, test,iconview))
ButtonArea.add_widget(testbutton)
FileChooserLayout.add_widget(ButtonArea)
filepop.add_widget(FileChooserLayout)
感谢您的帮助!
【问题讨论】:
标签: python-3.x kivy filechooser