Kivy FileChooser 双击
问题描述
有人可以发布一个带有以下简单双击功能的 kivy Filechooser 的小型工作示例:双击文件将打印出文件名?
Could somebody post a small working example of a kivy Filechooser with the following simple doubleclick function: doubleclicking on a file will print out the filename?
解决方案
这是一个例子.
from kivy.app import App
from kivy.uix.filechooser import FileChooserListView
from kivy.uix.boxlayout import BoxLayout
class MyFileChooser(FileChooserListView):
def on_submit(*args):
print(args[1][0])
class MyLayout(BoxLayout):
def __init__(self,**kwargs):
super(MyLayout,self).__init__(**kwargs)
# filter added. Since windows will throw error on sys files
self.fclv = MyFileChooser(filters= [lambda folder, filename: not filename.endswith('.sys')])
self.add_widget(self.fclv)
class MyApp(App):
def build(self):
return MyLayout()
MyApp().run()
相关文章