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.


    String return with dialogs

    Pythonista
    3
    5
    3015
    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.
    • Tito
      Tito last edited by

      Hi, i´m working on a more visual version of a little script for helping me in my job.

      The initial script was a simple console thing with prints and prompts formatted in the end.

      Now I would like to make it a bit visual importing the dialogs module.

      The documentation, after showing the function says: The edited text is returned as a string (if the dialog is cancelled, None is returned instead), and I’m unable to use the text, it disappears just with the prompt.

      Here is part of the code, I hope somebody could give me a hand.

      from sys import argv
      import dialogs, string
      
      dialogs.text_dialog(title='¿Quién es la persona destinataria de la oferta?')
      
      

      Thanks a lot...

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

        In general, you can use dialogs.text_dialog like the standard input function: you give the function a string that is shown to the user, and the text typed by the user is returned. So if your original script looks like this for example:

        name = input("What is your name? ")
        print("Hello " + name)
        

        You can replace input with dialogs.text_dialog and it will work the same, but it will use a text dialog instead of the console:

        import dialogs
        name = dialogs.text_dialog("What is your name?")
        print("Hello " + name)
        

        You can also show the response in an alert (instead of the console) using dialogs.alert instead of print.

        Tito 1 Reply Last reply Reply Quote 1
        • enceladus
          enceladus last edited by

          Here is a simple dialog template that uses a pyui file created using designer. This helps to use ui controls like images, textviews, segmentedcontrol in dialogs. The gist with sample pyui file is here. I hope it helps

          https://gist.github.com/73431fef1f00c462c3bee0551bd14be8

          It is previously posted here.

          https://forum.omz-software.com/topic/4507/form-dialogs-add-segmented-control-type/7

          Tito 1 Reply Last reply Reply Quote 0
          • Tito
            Tito @dgelessus last edited by

            @dgelessus it works, many thanks. :)

            1 Reply Last reply Reply Quote 0
            • Tito
              Tito @enceladus last edited by

              @enceladus hi, I’m overwhelmed for your script, I think right now is out of my capabilities, I’m just a learner and got a lot of obstacles in my way, I thought could learn Python trough Pythonista from scratch and couldn’t be more wrong.

              I hope someday could give a use to your great code and tell you.

              Thanks.

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