MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / FormDialog

Class FormDialog

lib/matplotlib/backends/qt_editor/_formlayout.py:419–496  ·  view source on GitHub ↗

Form Dialog

Source from the content-addressed store, hash-verified

417
418
419class FormDialog(QtWidgets.QDialog):
420 """Form Dialog"""
421 def __init__(self, data, title="", comment="",
422 icon=None, parent=None, apply=None):
423 super().__init__(parent)
424
425 self.apply_callback = apply
426
427 # Form
428 if isinstance(data[0][0], (list, tuple)):
429 self.formwidget = FormTabWidget(data, comment=comment,
430 parent=self)
431 elif len(data[0]) == 3:
432 self.formwidget = FormComboWidget(data, comment=comment,
433 parent=self)
434 else:
435 self.formwidget = FormWidget(data, comment=comment,
436 parent=self)
437 layout = QtWidgets.QVBoxLayout()
438 layout.addWidget(self.formwidget)
439
440 self.float_fields = []
441 self.formwidget.setup()
442
443 # Button box
444 self.bbox = bbox = QtWidgets.QDialogButtonBox(
445 QtWidgets.QDialogButtonBox.StandardButton(
446 _to_int(QtWidgets.QDialogButtonBox.StandardButton.Ok) |
447 _to_int(QtWidgets.QDialogButtonBox.StandardButton.Cancel)
448 ))
449 self.formwidget.update_buttons.connect(self.update_buttons)
450 if self.apply_callback is not None:
451 apply_btn = bbox.addButton(
452 QtWidgets.QDialogButtonBox.StandardButton.Apply)
453 apply_btn.clicked.connect(self.apply)
454
455 bbox.accepted.connect(self.accept)
456 bbox.rejected.connect(self.reject)
457 layout.addWidget(bbox)
458
459 self.setLayout(layout)
460
461 self.setWindowTitle(title)
462 if not isinstance(icon, QtGui.QIcon):
463 icon = QtWidgets.QWidget().style().standardIcon(
464 QtWidgets.QStyle.SP_MessageBoxQuestion)
465 self.setWindowIcon(icon)
466
467 def register_float_field(self, field):
468 self.float_fields.append(field)
469
470 def update_buttons(self):
471 valid = True
472 for field in self.float_fields:
473 if not is_edit_valid(field):
474 valid = False
475 for btn_type in ["Ok", "Apply"]:
476 btn = self.bbox.button(

Callers 1

feditFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…