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.


    List Dialog Returns None

    Pythonista
    dialogs
    2
    3
    2387
    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 techteej

      self.var = str(dialogs.list_dialog(title='Select a file type', items=[".txt", ".py"], multiple=False))
      print self.var
      

      Returns none when I select an item, any ideas why?

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

        Possible reason: You're calling this from the main UI thread (e.g. from a button action etc.). Blocking that thread would effectively "hang" the app, so list_dialog returns immediately, without waiting for a return value.

        Try decorating your action/function with @ui.in_background, like this:

        @ui.in_background
        def my_action(sender):
          self.var = str(dialogs.list_dialog(title='Select a file type', items=[".txt", ".py"], multiple=False))
          print self.var
        
        1 Reply Last reply Reply Quote 0
        • techteej
          techteej last edited by

          @omz That was it, thanks. You could tell it's been a while!

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