本文介绍了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()
这篇关于Kivy FileChooser 双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!