def webpage_option_setter(attr, type_=None):
    """ Helper function for defining setters for web_page options, e.g.
    ``set_images_enabled = webpage_option_setter(QWebSettings.AutoLoadImages)``
    To be used in BrowserTab subclasses.
    """
    def _setter(self, value):
        if type_ is not None:
            value = type_(value)
        settings = self.web_page.settings()
        settings.setAttribute(attr, value)
    return _setter