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.


    BETA: Dialogs module

    Pythonista
    4
    7
    4102
    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.
    • tomkirn
      tomkirn last edited by

      Hi all,

      When trying to use a dialogs.list_dialog from within an Ui.view I got no result back from dialog. Is this a bug or do I misunderstood something?

      Regards
      Tom

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

        Apparently UI and dialogs don't mix:

        • If the @ui.in_background line is commented out then action() only runs once you have closed view.
        • If the @ui.in_background line is not commented out then dialogs.list_dialog() always returns None.
        import dialogs, ui
        
        @ui.in_background  # try it with this line commented out and with this line not commented out.
        def action(sender):
            print('action() starts')
            #sender.superview.hidden = True
            #sender.superview.sent_to_back()
            print(dialogs.list_dialog(sender.title, sender.title))
            #sender.superview.hidden = False
            print('action() ends')
        
        view = ui.View()
        button = ui.Button(title='Show List')
        button.action = action
        view.add_subview(button)
        view.present()
        button.center = view.center
        # view.wait_modal()  # FIX: commented out as suggested by @omz below.
        
        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          If you remove the view.wait_modal() line, it should work.

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

            That works!

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

              Ok, got it. I forgot the @ui.in_background

              Now it works

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

                When using the dialogs module, is the size of the text_dialogs box fixed or can it be made a specified size?

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

                  It uses a fixed size, but you could define your own text_dialog function like this:

                  import dialogs
                  import ui
                  
                  def custom_text_dialog(size=(500, 500), title='', text='', font=('<system>', 16), autocorrection=None, autocapitalization=ui.AUTOCAPITALIZE_SENTENCES, spellchecking=None, done_button_title='Done'):
                  	c = dialogs._TextDialogController(title=title, text=text, font=font, autocorrection=autocorrection, autocapitalization=autocapitalization, spellchecking=spellchecking, done_button_title=done_button_title)
                  	c.view.bounds = (0, 0, size[0], size[1])
                  	c.view.present('sheet')
                  	c.view.begin_editing()
                  	c.view.wait_modal()
                  	return c.text
                  
                  print 'Result:', custom_text_dialog(size=(300, 400))
                  

                  (this is basically just a variation of the actual text_dialog source code)

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