walter201230 / Python

最良心的 Python 教程:

Home Page:https://www.readwithu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(please help) im having problem in my code

boyintheroom opened this issue · comments

Description of the Bug

1.Hi Developers im new to coding. i tried to make this video uploading app to my firebase storage but im not that good at coding so im stuck at this problem. when upload button is pressed the filechooser is opened and if i select a file it gets uploaded to the firebase But if i cancel and close the filechooser it gives an error.
2. i am unaware if this file chooser works on android or nor...if it does not please help me with this code too. im stuck on this since 6 January ,thats how poor i am.

Code and Logs

from kivy.app import App
from kivy.lang import Builder

kv = '''
<MainScreen>:
    name: 'mainscreen'
    MDLabel:
        id:username_info
        text:'Hello Main'
        font_style:'H1'
        halign:'center'

    MDFloatLayout:
        id:floate
        Video:
            id:vid

        MDToolbar:
            title: 'Bottom navigation'
            md_bg_color: .2, .2, .2, 1
            specific_text_color: 1, 1, 1, 1
        MDBottomNavigation:
            panel_color: 1,1,1,1
            MDBottomNavigationItem:
                name: 'screen 1'
                text: 'Home'
                icon: 'home-outline'
                MDRaisedButton:
                    id:upload
                    text:'Upload'
                    pos_hint:{'center_x':.5, 'center_y':.4}
                    on_release:
                        app.file_chooser()
                        upload.disabled=False
'''


class goodApp(MDApp):

    def build(self):
        self.strng = Builder.load_string(help_str)
        self.url  = "link.json"
        return self.strng

    def file_chooser(self):
        filechooser.open_file(on_selection=self.selected)        
    def selected(self,selection):
        config={
              'Api keys of firebase'
        }

        firebase=pyrebase.initialize_app(config)
        storage=firebase.storage()            
        Directory=selection[0]
        Name=re.findall('[ \w-]+\..*',Directory)
        loginEmail = self.strng.get_screen('loginscreen').ids.login_email.text
        storage.child(str(f"{loginEmail}")).child(str(f"{Name}")).put(str(f"{Name[0]}"))

        if selection==True:
            self.root.ids.vid.source=firebase
            self.strng.get_screen('mainscreen').ids.upload.disabled=True
            self.strng.get_screen('mainscreen').manager.current ='uploadscreen'
            self.strng.get_screen('mainscreen').manager.transition.direction='left'            

        if selection==False:
            self.strng.get_screen('mainscreen').ids.upload.disabled=False



if __name__ == '__main__':
    goodApp().run()

Screenshots

Add images to explain us this bug. Paste urls here.

Remove this section if no images here

Versions

  • OS: win 7 pro
  • Python: 3.7
  • Kivy: latest
  • KivyMD: latest (update everyweek)