Which filename to use for a local CSS file?
I would like to use a CSS file in an HTML page passed on to
ui.WebView.load_htmlbut I cannot figure out which filename to use. The simple assumption that the filename should be relative to the location of the Python script calling the method does not seem to work, e.g
<html><link rel="stylesheet" type="text/css" href="etc/styles.css"><body><p id="content">TO BE FILLED</p></body></html>with
styles.csslocated in the
etcsub directory of my script directory does not work. If I use the CSS definitions inline, such as
<html><style>...</style></html>, they work fine.
Any idea? Thanks a lot!
I tried this as well and had to use absolute paths to get it work. I dont get happy with relative paths at all.
If you used load_url instead of load_html, relative paths work. Although not well documented, load_url works with an abspath(i.e, without the need for file://)
load_html has no concept of your url, so of course relative paths do not work.
You could also should be able to use a
<base>HTML tag inside the <head> to set the page address.
@JonB I changed the loading as you suggested and it works! Thanks a lot!