Add content argument to WebView instantiation
What is the problem or limitation you are having?
Similar to #2307
Right now, unlike with URL, to create a WebView and set [HTML] content to it, we have to do it in two steps:
web_view = toga.WebView()
web_view.set_content("", html_content)
Describe the solution you'd like
WebView already allows passing a URL during instantiation, so why not allow passing "content" as well? That way we can do it in one step, and be consistent with MainWindow and ScrollContainer:
web_view = toga.WebView(content=html_content)
Describe alternatives you've considered
None
Additional context
No response
To clarify - the API for webview isn't:
web_view.set_content = ("", html_content)
it's
web_view.set_content("", html_content)
The difference is critical - it's a method invocation with 2 arguments, not a single assignment of a tuple. We need 2 arguments to set static "non-URL" content.
That said - URL and content based initialisation are mutually exclusive, so we could use the interpretation that if content is specified, URL is the used as the root URL for the raw content.
To clarify - the API for webview isn't: [...]
Sorry, that was a typo. Fixed.
That said - URL and content based initialisation are mutually exclusive, so we could use the interpretation that if content is specified, URL is the used as the root URL for the raw content.
Makes sense. With a note about that in the docs, for extra clarity, sounds pretty reasonable.
Currently working on this!
Hi! Last person working on this had not responded in 5 months... may I open a PR?
for anneyshas: you've done nothing wrong, I know that you (and pretty much other foss contributors) might have other things in their lifes, so I'm going to try to get this fixed.
@johnzhou721 I think it's safe to assume this is available to be worked on.
@anneyshas If you're still interested in working on this, let us know.