code: def load_html(self, mode, html):
          
          # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
          self._html_loaded_flag = False
  
          if mode == HTML_FILE_MODE:
              self.setUrl(QtCore.QUrl.fromLocalFile(html))
          elif mode == HTML_STR_MODE:
              self.setHtml(html)
          else:
              raise InvalidParameterError('The mode is not supported.')
  
          counter = 0
          sleep_period = 0.1  # sec
          timeout = 20  # it's generous enough!
          while not self._html_loaded_flag and counter < timeout:
              # Block until the event loop is done
              counter += sleep_period
              time.sleep(sleep_period)
              # noinspection PyArgumentList
              QgsApplication.processEvents()
docs: Load HTML to this class with the mode specified.
  
          There are two modes that can be used:
              * HTML_FILE_MODE: Directly from a local HTML file.
              * HTML_STR_MODE: From a valid HTML string.
  
          :param mode: The mode.
          :type mode: int
  
          :param html: The html that will be loaded. If the mode is a file,
              then it should be a path to the htm lfile. If the mode is a string,
              then it should be a valid HTML string.
          :type html: str