omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    File parts error running apps via home shorcut

    Pythonista
    4
    6
    3113
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CastroSATT
      CastroSATT last edited by

      Hiya guys taking a break from the pdf issue I had,, I think I found a solution but it’s on a take me a week or so to implement... so on to the easier issue

      I have an app that uses a load of subvies etc also uses a few folder for templates and invoices also got a folder for sound effects banners etc

      No the issue is works fine when I run the script from within pythonista... but if I run from shortcut straight into the app I get file not found errors it’s almost as if the app can not see its file paths

      And help would be great

      This is a pic of the error

      [https://drive.google.com/file/d/1KyJGl9R7DdBXhh1JRl45r34mAXsEhhhT/view?usp=drivesdk](link url)

      1 Reply Last reply Reply Quote 0
      • afelix
        afelix last edited by

        Can you include a snippet of your code, and the way you attempt to view that path? Do you use os.path.expanduser for example? Based on the image I would say you're trying to call a path relative to a directory, but when running from the shortcut it might not know how to find it. It's safer to call it relative from the user directory, then use os.path.expanduser to solve the path.

        CastroSATT 1 Reply Last reply Reply Quote 0
        • CastroSATT
          CastroSATT last edited by

          Cool

          Here’s a snippet really it’s for reading and writing the ini file

          For example Same command used but for the sound fx

          def SoundFx(N):
          	if N == 1:
          		# Honour position of phone silent switch  
          		sound.set_honors_silent_switch(True)
          		# sets volume 
          		sound.set_volume(1.0)
          		#preloads 
          		sound.load_effect('./RR/img/hadouken.mp3')
          		#sample to be played when imaged pressed
          		sound.play_effect('./RR/img/hadouken.mp3')
          		vibrate()
          
          
          1 Reply Last reply Reply Quote 0
          • CastroSATT
            CastroSATT @afelix last edited by

            Looks like that would work not sure how to implement it if you got any clues a am full beginnerish

            cvp mikael 2 Replies Last reply Reply Quote 0
            • cvp
              cvp @CastroSATT last edited by cvp

              @CastroSATT Is your script in the root?

              Begin your script with

              import os
              print(os.listdir())
              

              Only to check the difference when you run in Pythonista and from an home screen shortcut

              1 Reply Last reply Reply Quote 0
              • mikael
                mikael @CastroSATT last edited by

                @CastroSATT

                import os.path
                my_sounds_dir = os.path.expanduser('~/Documents/dir_where_the_script_is_now/RR/img/')
                sound.load_effect(my_sounds_dir+'hadouken.mp3')
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors