首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kivy FileChooser双击

Kivy FileChooser双击
EN

Stack Overflow用户
提问于 2017-02-22 21:49:07
回答 2查看 1.4K关注 0票数 1

有没有人能用下面这个简单的doubleclick函数发布一个kivy Filechooser的小工作示例:双击一个文件将打印出文件名?

EN

回答 2

Stack Overflow用户

发布于 2017-02-23 01:11:31

这里有一个这样的例子。

代码语言:javascript
复制
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()
票数 4
EN

Stack Overflow用户

发布于 2019-02-21 05:21:16

我认为这比这更简单。

FileChooser有一个参数dirselect。默认情况下,它是False,这使得它可以单击。如果将dirselect更改为True,则它与双击一样工作。

例如,在kivy语言中

代码语言:javascript
复制
BoxLayout:
    FileChooserIconView:
        size_hint: (0.3, 0.4)
        dirselect: True

例如,在python语言中

代码语言:javascript
复制
FileChooserListView(size_hint_x=0.3, size_hint_y=0.4, dirselect=True)

希望它能帮助到某些人

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42393319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档