Permission denied error

113 views
Skip to first unread message

ShanWick

unread,
Mar 7, 2023, 6:11:43 AM3/7/23
to Kivy users support
buildozer.spec
android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE

When I select an image through plyer filechooser on kivy android apk, the image path is shown correctly in the select_file.text label. But the problem is that after assigning the selected path to the image.source, the Image is not displayed.

I get this error:
03-07 09:23:11.172 23972 24300 I python : [Errno 13] Permission denied: '/storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20230306-WA0002.jpg'

Please help me.

# my code
from kivy.lang.builder import Builder
from kivymd.app import MDApp

from kivy.utils import platform
from plyer import filechooser
from kivy.clock import mainthread

if platform == "android":
    from android.permissions import request_permissions, Permission
    request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])


kv = """
MDScreen:
    GridLayout:
        cols:1
        padding: dp(10)
        spacing: dp(10)
        Image:
            id: image
            pos_hint: {"center_x": .5, "center_y": .5}

        MDLabel:
            id: select_file
            halign: "center"

        Button:
            text: "Select File"
            size_hint_y: None
            height: "50dp"
            on_press: app.file_manager_open()




"""

class RemoveApp(MDApp):
    def build(self):
        return Builder.load_string(kv)

    def file_manager_open(self):
        fil = [("Images", ".jpg", ".jpeg", "*.png")]
        filechooser.open_file(on_selection=self.handle_selection, filters=fil, multiple=True)

    @mainthread
    def handle_selection(self, selection):
        if not selection:
            return
        self.root.ids.select_file.text = str(selection)
        self.root.ids.image.source = selection[0]



if name == 'main':
    RemoveApp().run()


1678161294093.jpg

Robert

unread,
Mar 7, 2023, 11:45:51 AM3/7/23
to Kivy users support
Reply all
Reply to author
Forward
0 new messages