-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Qt has a really neat QInputDialog class with a few convenience functions with its own window and return value.
text, ok = QtWidgets.QInputDialog.getText(
self,
"Window title",
"Input field:",
QtWidgets.QLineEdit.Normal,
"some default value"
)
if ok and !text.isEmpty()
print("Let's do it!")We should have that.
# E.g.
options, ok = qargparse.QArgumentParser.get_ok([
arg1,
arg2,
arg3
])
if ok and options["someArgument"]:
print("Let's do it!")Example implementation
import qargparse
def get_ok():
parser = qargparse.QArgumentParser()
options = {...}
parser.add_argument("timeRange", type=qargparse.Enum, items=[
"Start/End",
"Time Slider",
"From File",
], default=options["timeRange"], help="Which part of the animation to import")
parser.add_argument(
"sourceStartTime",
default=options["sourceStartTime"],
help="From where in the input animation to read from"
)
parser.add_argument(
"sourceEndTime",
default=options["sourceEndTime"],
help="From where in the input animation to read from"
)
parser.add_argument(
"destinationStartTime",
default=options["destinationStartTime"],
help="From where in the input animation to write to"
)
parser.add_argument(
"destinationEndTime",
default=options["destinationEndTime"],
help="From where in the input animation to read from"
)
parser.add_argument("matchMethod", type=qargparse.Enum, items=[
"Hierarchy",
"Search & Replace",
], default=options["matchMethod"],
help=(
"How to correlate animation with selection\n"
"Hierarchy: Match by both name and where a node is "
"in the hierarchy\n"
"Search & Replace: Match by full path, after a text-replace "
"session with custom values"
)
)
parser.add_argument(
"search",
type=qargparse.String,
default=options["search"],
help="What to replace"
)
parser.add_argument(
"replace",
type=qargparse.String,
default=options["replace"],
help="What to replace with"
)
parser.add_argument(
"addPrefix",
type=qargparse.String,
default=options["addPrefix"],
help="What to replace with"
)
parser.add_argument(
"addSuffix",
type=qargparse.String,
default=options["addSuffix"],
help="What to replace with"
)
def on_changed(arg):
print("%s -> %s" % (arg, arg.read()))
options[arg["name"]] = arg.read()
parser.changed.connect(on_changed)
# Embed it in a QMessageBox
message = QtWidgets.QDialog(self)
message.setMinimumWidth(400)
message.setWindowTitle("Export selected animation..")
save = QtWidgets.QPushButton("Import")
cancel = QtWidgets.QPushButton("Cancel")
def on_save():
self._dcc.import_animation(fname + ".ikmanim", options=options)
message.deleteLater()
def on_cancel():
log.warning("Cancelled")
message.deleteLater()
save.clicked.connect(on_save)
cancel.clicked.connect(on_cancel)
layout = QtWidgets.QGridLayout(message)
layout.addWidget(message, 0, 0, 1, 2)
layout.addWidget(save, 2, 0)
layout.addWidget(cancel, 2, 1)
layout.setRowStretch(0, 1)
return options, message.exec_()
options, ok = get_ok()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request