[GIS] How to use raw_input() in QGIS python console

pythonqgis

I'm hoping to use raw_input() inside a loop to prompt the user when s/he wants to continue running the script. However, I'm getting an error:

Traceback (most recent call last):
   File "<input>", line 1, in <module>
EOFError: EOF when reading a line

Is this function supported in qgis' python console? If not, do you have any suggestion?

I don't need to read the user's input. I just need the loop to pause for a while to let the user do some other stuff, then when ready, to resume working again.

Best Answer

The alternative to raw_input is QInputDialog.getText as explained in Maximus' answer above. A quick and Dirty example would be:

##Import libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qgis.utils import *

from PyQt4.QtGui import QInputDialog #this is for your dialogs

 tempTuple = QInputDialog.getText(None, "Your Name" ,"Enter your Full Name: ")
 userName = tempTuple[0]

see also: https://stackoverflow.com/questions/35707849/link-qinputdialog-text-to-a-variable

Related Question