(self, argspec, parent=None, window_title='Function arguments', doc=None)
| 954 | class ArgumentsInputDialog(QtGui.QDialog): |
| 955 | |
| 956 | def __init__(self, argspec, parent=None, window_title='Function arguments', doc=None): |
| 957 | super().__init__(parent) |
| 958 | |
| 959 | vlayout = QtGui.QVBoxLayout(self) |
| 960 | |
| 961 | layout = QtGui.QFormLayout() |
| 962 | |
| 963 | widgets = [] |
| 964 | |
| 965 | defaults = argspec.defaults if argspec.defaults else () |
| 966 | defaults = ('', ) * (len(argspec.args[1:]) - len(defaults)) + defaults |
| 967 | |
| 968 | self.arguments = {} |
| 969 | for arg, default in zip(argspec.args[1:], defaults): |
| 970 | wid = QtGui.QLineEdit(self) |
| 971 | wid.setObjectName(arg) |
| 972 | wid.setText(json.dumps(default)) |
| 973 | self.arguments[arg] = default |
| 974 | |
| 975 | layout.addRow(arg, wid) |
| 976 | widgets.append(wid) |
| 977 | wid.textChanged.connect(self.on_widget_change(wid)) |
| 978 | if doc and arg in doc: |
| 979 | wid.setToolTip(doc[arg]) |
| 980 | |
| 981 | |
| 982 | self.widgets = widgets |
| 983 | |
| 984 | buttonBox = QtGui.QDialogButtonBox() |
| 985 | buttonBox.setOrientation(QtCore.Qt.Horizontal) |
| 986 | buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) |
| 987 | buttonBox.setEnabled(True) |
| 988 | buttonBox.accepted.connect(self.accept) |
| 989 | |
| 990 | vlayout.addLayout(layout) |
| 991 | |
| 992 | label = QtGui.QLabel() |
| 993 | label.setText('Values are decoded from text using as JSON.') |
| 994 | vlayout.addWidget(label) |
| 995 | |
| 996 | vlayout.addWidget(buttonBox) |
| 997 | |
| 998 | self.buttonBox = buttonBox |
| 999 | self.valid = {wid.objectName(): True for wid in self.widgets} |
| 1000 | |
| 1001 | self.setWindowTitle(window_title) |
| 1002 | |
| 1003 | |
| 1004 | def on_widget_change(self, widget): |
nothing calls this directly
no test coverage detected