Dear Forum/Support,
i need the user to select a item from a dropdown / list.
i found an old post where something similar has been achieved,
a dialog with string input for user, as seen here:
https://support.shotgunsoftware.com/hc/en-us/community/posts/209497808-Dialog-to-ask-the-user-for-a-string-
i edited the given snippet, but struggle to get it displaying a dropdown menu.
here is my code:
def getUserInputList(itemlist):
title = “Select project”
label = “Projects”
# e.g. itemlist
itemlist= [“no1”, “no2”]
dialogCode = “”"
{
use qt;
(string,bool) ans = qt.QInputDialog.getItem(commands.mainWindowWidget(), “%s”, “%s”, “%s”, 0, False);
ans._0 + “|” + string(ans._1);
}
“”"
stringInput = “%s” % runtime.eval(dialogCode % (title, label, itemlist), [“qt”, “commands”])
stringInput = stringInput.replace(‘’‘"’‘’, “”)
print stringInput
InputList = stringInput.split(“|”)
print InputList
if InputList[1] == “true”:
return InputList[0]
else:
return None
on execution i get a syntax error; on line
stringInput = “%s” % runtime.eval(dialogCode % (title, label, itemlist), [“qt”, “commands”])
can please someone point me the error in the code?
my resources are:
https://doc.qt.io/qtforpython/PySide2/QtWidgets/QInputDialog.html
thanks upfront!