String return with dialogs
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...
dgelessus last edited by
In general, you can use
dialogs.text_dialoglike the standard
inputfunction: 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
dialogs.text_dialogand 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
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
It is previously posted here.
@dgelessus it works, many thanks. :)
@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.