FileChooser filter problem

950 views
Skip to first unread message

embryo

unread,
Aug 5, 2015, 6:24:40 AM8/5/15
to Kivy users support
Hi,
I'm using a FileChooserListView for a file selector and it works mostly OK.

The problem is that when I use filters for the files (like ['\*.txt']) they work at the first ListView of the root path, but when I change into an other folder they stop working.
Not only the ListView does not display the *.txt files, it doesn't display any file.
And it doesn't fall back to the default which is [] (equal to '\*').

The only reference I found was that:
"The filters are not reset when the path changes. You need to do that yourself if desired."
Searching on the net didn't find me anything and all my tries to do it myself were useless.
I can not find when to reset the filters and how to do that.

Trying to do something "on_selection" didn't change anything.
The same happened when I tried to subclass FileChooserListView and override the "open_entry" function.

Does anybody knows about this problem and a way out of it.
I would appreciated it if any answer would be a little detailed and not something like just "subclass FileChooserListView" ...

TIA

ZenCODE

unread,
Aug 5, 2015, 8:07:54 AM8/5/15
to Kivy users support
It might be to do with the way you are using it? Try posting a minimal, runnable example of the code so we can test and suggest changes in a concrete form, instead of just guessing 'Well, try this..' .:-)

Also, this may be OS related. What OS oare you using? What OS are you testing/deploying to?

Peace

embryo

unread,
Aug 5, 2015, 8:26:58 AM8/5/15
to Kivy users support
You can use the code from here.
If you add the "filters" property to the FileChooserListView like:
FileChooserListView:
    id: filechooser
    filters: ['\*.txt']
it will work for the first view (the root of your current directory) but after you get in a folder, it stops displaying any files, even at the root.
I'm using kivy 1.9, python 2.7.8 on WinXP.
The app I'm making is for windows and android.

ZenCODE

unread,
Aug 6, 2015, 2:53:48 PM8/6/15
to Kivy users support
You have

  filters: ['\*.txt']

So that tells it to display only text files in your root. Try

  filters: ['*.txt']

To display text files anywhere. No?

embryo

unread,
Aug 6, 2015, 3:08:40 PM8/6/15
to Kivy users support
And yes, you're right!

I used ['\*.txt'] because at the example of the source it was ['\*.png'] and I thought it had to be like this!
I just checked on the online example and its fixed.

Thank you for your time.

ZenCODE

unread,
Aug 7, 2015, 12:48:10 PM8/7/15
to Kivy users support
:-)

ZenCODE

unread,
Aug 7, 2015, 4:40:19 PM8/7/15
to Kivy users support
Ha ha. I'm working through the source now and see what you mean. In the source code, they are escaped with a backslash. Sphinx (the document generator) requests this and removes them from the final, generated docs. The are escaped due to the following warning in the sphinx documentation:

If asterisks or backquotes appear in running text and could be confused with inline markup delimiters, they have to be escaped with a backslash.


Cheers
Reply all
Reply to author
Forward
0 new messages