Exemple #1
0
def AncestorShortcutsHandlers(widget: QW.QWidget):

    shortcuts_handlers = []

    window = widget.window()

    if window == widget:

        return shortcuts_handlers

    widget = widget.parent()

    while True:

        child_shortcuts_handlers = [
            child for child in widget.children()
            if isinstance(child, ShortcutsHandler)
        ]

        shortcuts_handlers.extend(child_shortcuts_handlers)

        if widget == window:

            break

        widget = widget.parent()

        if widget is None:

            break

    return shortcuts_handlers
Exemple #2
0
    def add_context_menu_to_children(self, widget: QtWidgets.QWidget) -> None:
        """
        Distribute the context menu to child widgets.

        This makes it so you can right click to configure the table from
        within any of the contained widgets.
        """
        for widget in widget.children():
            widget.contextMenuEvent = self.contextMenuEvent