Create form dialog data: datalist, datagroup title: str comment: str icon: QIcon instance parent: parent QWidget apply: apply callback (function) datalist: list/tuple of (field_name, field_value) datagroup: list/tuple of (datalist *or* datagroup, title, comment
(data, title="", comment="", icon=None, parent=None, apply=None)
| 497 | |
| 498 | |
| 499 | def fedit(data, title="", comment="", icon=None, parent=None, apply=None): |
| 500 | """ |
| 501 | Create form dialog |
| 502 | |
| 503 | data: datalist, datagroup |
| 504 | title: str |
| 505 | comment: str |
| 506 | icon: QIcon instance |
| 507 | parent: parent QWidget |
| 508 | apply: apply callback (function) |
| 509 | |
| 510 | datalist: list/tuple of (field_name, field_value) |
| 511 | datagroup: list/tuple of (datalist *or* datagroup, title, comment) |
| 512 | |
| 513 | -> one field for each member of a datalist |
| 514 | -> one tab for each member of a top-level datagroup |
| 515 | -> one page (of a multipage widget, each page can be selected with a combo |
| 516 | box) for each member of a datagroup inside a datagroup |
| 517 | |
| 518 | Supported types for field_value: |
| 519 | - int, float, str, bool |
| 520 | - colors: in Qt-compatible text form, i.e. in hex format or name |
| 521 | (red, ...) (automatically detected from a string) |
| 522 | - list/tuple: |
| 523 | * the first element will be the selected index (or value) |
| 524 | * the other elements can be couples (key, value) or only values |
| 525 | """ |
| 526 | |
| 527 | # Create a QApplication instance if no instance currently exists |
| 528 | # (e.g., if the module is used directly from the interpreter) |
| 529 | if QtWidgets.QApplication.startingUp(): |
| 530 | _app = QtWidgets.QApplication([]) |
| 531 | dialog = FormDialog(data, title, comment, icon, parent, apply) |
| 532 | |
| 533 | if parent is not None: |
| 534 | if hasattr(parent, "_fedit_dialog"): |
| 535 | parent._fedit_dialog.close() |
| 536 | parent._fedit_dialog = dialog |
| 537 | |
| 538 | dialog.show() |
| 539 | |
| 540 | |
| 541 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…