Here is an example of a simple filechooser. The point of this exercise was to add a drive selector. This is a relatively simple example that does a load and save dialogs with the filechooser.
https://github.com/ElliotGarbus/KivyFileAndDrive
run main.py
You can ignore main1.py, it is a simple test of the popup using Factory.
The filter is set to only show *.txt or *.pdf files.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAFzdpLjuLAFm56kYjwuxKuuZ8y_VBtPTnSydoeAxhwSGdr7efg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/000c01d9c7dc%24574c48d0%2405e4da70%24%40cox.net.
Looking at this code:
class Screen2(Screen):
theme_cls = ThemeManager()
def selected(self, filechooser,filename):
p=self.selected(filename)
return p
You have a problem that selected is calling itself. No need for recursion here.
Also note that selection, filename here, is a list. Print it out, you will see it a list at that the filename is an absolute filename with full path info.
You might want to change your kv code to:
on_selection: root.selected(filechooser.selection[0])
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAFzdpLhbY-r2gU7QaDn3s7xK2Rdp7KeUqFS%2BMVDmuQK725Utsg%40mail.gmail.com.
I was not suggesting you use the code – or change the look. It is just an example of a file chooser.
From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> On Behalf Of NDD Mais
Sent: Sunday, August 6, 2023 7:12 AM
To: kivy-...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAFzdpLhbY-r2gU7QaDn3s7xK2Rdp7KeUqFS%2BMVDmuQK725Utsg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/004101d9c87a%247e0878b0%247a196a10%24%40cox.net.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/004101d9c87a%247e0878b0%247a196a10%24%40cox.net.
You are calling selected when the file is selected. Store the selected filename in an instance variable, let’s call that self.selected_file. In your read method() use self.selected_file to read the file.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAFzdpLgQmRpTsby35nqFCzhDVx_hHJe0v8uk1bVJyOmGD0b5ZQ%40mail.gmail.com.
Alternatively, you could call read() and pass in the filename from kv. The core of the problem is calling selected() from read(),
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/006f01d9c88f%24d8b8d290%248a2a77b0%24%40cox.net.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/006f01d9c88f%24d8b8d290%248a2a77b0%24%40cox.net.