widget_monkeypatch_callbacks#

A set of functions that will be monkey patched as methods to the graphical widgets, allowing notably compound widgets from QtCreator without defining plugins

dock_resize_event(instance, event)[source]#
ensure_compound_box_patched(bx: QFrame, bx_name: str = '')[source]#

Ensure a single QFrame has compound-box methods.

Note

Idempotent

Parameters:
  • bx (QFrame) – The box to patch

  • bx_name (str) – The objectName of the box, used to determine the type of compound box and thus the methods to patch

fix_btn_boxes_text(widget)[source]#

Rewrite the text on top of QDialogButtonBox(es) based on the dynamic properties ‘applyText’, ‘okText’ and ‘openText’ defined in the ui files in QtCreator

Returns

is_compound_box(bx_name)[source]#

Check whether the name of the box is a compound box i.e. a custom widget that is not natively supported by Qt but is based on elements inserted in a QFrame in the .ui file. The behaviour is defined by the objectName

Parameters:

bx_name (str) – The objectName of the QFrame

Returns

bool

is_list_box(bx_name)[source]#

Check whether the name of the box is a list box i.e. a custom widget ending in singlet double triplet that can be used to store a list of numbers

is_optional_box(box_name)[source]#
recursive_patch_button_boxes(parent)[source]#

To shorten the syntax, QDialogButtonBoxes are patched by this method so that e.g. bx.connectApply(f) replaces bx.button(QDialogButtonBox.Apply).clicked.connect(f)

Parameters:

parent (QWidget) – The main widget to start the recursive search

recursive_patch_compound_boxes(parent)[source]#

Since it is difficult to create real custom widgets in PyQt which can be used in QtCreator, we chose a different approach based on the dynamic nature of Python. We define new compound types (e.g. checkable text edit or triplets of values) based on dynamic properties and the objectNames in QtCreator and then patch the behaviour of these widgets in this method

Parameters:

parent (QWidget) – The main widget to start the recursive search

recursive_patch_widgets(parent)[source]#

Recursively patch the widgets in the parent widget This is used to add custom methods to the widgets that are not natively supported by Qt yet do it mainly from the .ui file as it is based on the objectName

Parameters:

parent (QWidget) – The main widget to start the recursive search