docs: def qteGetMacroObject(self, macroName: str, widgetObj: QtGui.QWidget):
          """
          Return macro that is name- and signature compatible with
          ``macroName`` and ``widgetObj``.
  
          The method considers all macros with name ``macroName`` and
          returns the one that matches 'best'. To determine this best
          match, the applet-and widget signatures of the macro are
          compared to those of ``widgetObj`` and picked in the following
          order:
  
          1. Applet- and widget signature of both match.
          2. Widget signature matches, applet signature in macro is "*"
          3. Applet signature matches, widget signature in macro is "*"
          4. Macro reports "*" for both its applet- and widget signature.
  
          If the macro does not fit any of these four criteria, then no
          compatible macro is available and the method returns **None**.
  
          |Args|
  
          * ``macroName`` (**str**): name of macro.
          * ``widgetObj`` (**QWidget**): widget for which a compatible
            macro is sought.
  
          |Returns|
  
          * **QtmacsMacro**: best matching macro, or **None**.
  
          |Raises|
  
          * **QtmacsArgumentError** if at least one argument has an invalid type.
          """
          # Determine the applet- and widget signature. This is trivial
          # if the widget was registered with Qtmacs because its
          # '_qteAdmin' attribute will provide this information. If, on
          # the other hand, the widget was not registered with Qtmacs
          # then it has no signature, yet its parent applet must because
          # every applet has one. The only exception when the applet
          # signature is therefore when there are no applets to begin
          # with, ie. the the window is empty.
          if hasattr(widgetObj, '_qteAdmin'):
              app_signature = widgetObj._qteAdmin.appletSignature
              wid_signature = widgetObj._qteAdmin.widgetSignature
  
              # Return immediately if the applet signature is None
              # (should be impossible).
              if app_signature is None:
                  msg = 'Applet has no signature.'
                  self.qteLogger.error(msg, stack_info=True)
                  return None
          else:
              wid_signature = None
              app = qteGetAppletFromWidget(widgetObj)
              if app is None:
                  app_signature = None
              else:
                  app_signature = app._qteAdmin.appletSignature
  
          # Find all macros with name 'macroName'. This will produce a list of
          # tuples with entries (macroName, app_sig, wid_sig).
          name_match = [m for m in self._qteRegistryMacros if m[0] == macroName]
  
          # Find all macros with a compatible applet signature. This is
          # produce another list of tuples with the same format as
          # the name_match list (see above).
          app_sig_match = [_ for _ in name_match if _[1] in (app_signature, '*')]
  
          if wid_signature is None:
              wid_sig_match = [_ for _ in app_sig_match if _[2] == '*']
          else:
              # Find all macros with a compatible widget signature. This is
              # a list of tuples, each tuple consisting of (macroName,
              # app_sig, wid_sig).
              wid_sig_match = [_ for _ in app_sig_match
                               if _[2] in (wid_signature, '*')]
  
          # Pick a macro.
          if len(wid_sig_match) == 0:
              # No macro is compatible with either the applet- or widget
              # signature.
              return None
          elif len(wid_sig_match) == 1:
              match = wid_sig_match[0]
              # Exactly one macro is compatible with either the applet-
              # or widget signature.
              return self._qteRegistryMacros[match]
          else:
              # Found multiple matches. For any given macro 'name',
              # applet signature 'app', and widget signature 'wid' there
              # can be at most four macros in the list: *:*:name,
              # wid:*:name, *:app:name, and wid:app:name.
  
              # See if there is a macro for which both the applet and
              # widget signature match.
              tmp = [match for match in wid_sig_match if (match[1] != '*')
                     and (match[2] != '*')]
              if len(tmp) > 0:
                  match = tmp[0]
                  return self._qteRegistryMacros[match]
  
              # See if there is a macro with a matching widget signature.
              tmp = [match for match in wid_sig_match if match[2] != '*']
              if len(tmp) > 0:
                  match = tmp[0]
                  return self._qteRegistryMacros[match]
  
              # See if there is a macro with a matching applet signature.
              tmp = [match for match in wid_sig_match if match[1] != '*']
              if len(tmp) > 0:
                  match = tmp[0]
                  return self._qteRegistryMacros[match]
  
              # At this point only one possibility is left, namely a
              # generic macro that is applicable to arbitrary applets
              # and widgets, eg. NextApplet.
              tmp = [match for match in wid_sig_match if (match[1] == '*')
                     and (match[2] == '*')]
              if len(tmp) > 0:
                  match = tmp[0]
                  return self._qteRegistryMacros[match]
  
              # This should be impossible.
              msg = 'No compatible macro found - should be impossible.'
              self.qteLogger.error(msg, stack_info=True)