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.


    Best practice for choosing a folder in a dialog

    Pythonista
    2
    2
    1111
    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.
    • techteej
      techteej last edited by

      files1 = sorted(os.listdir(os.getcwd()), key=str.lower)
      script = dialogs.list_dialog(title='', items=files1, multiple=False)
      if '.py' not in script:
      files1 = sorted(os.listdir(script), key=str.lower)
      script = dialogs.list_dialog(title='', items=files1, multiple=False)
      url = 'pythonista://' + script + '?action=run'

      Pretty sure there is a better way to do this.

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

        Unless I'm completely missing something obvious, there isn't an official folder dialogue. As such, your way seems to be the best you can do without recursion. Although, you could iterate over each subdirectory (presumably using os.walk) and display separate list dialogues for each subdirectory the user taps into. This would allow for the user to have as many subdirectory levels as they want. I haven't tried actually implementing such a system (I haven't had the need to) but in theory, at least, this should work.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors