Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
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_html
but 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>
withstyles.css
located in theetc
sub 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! -
Hi,
I tried this as well and had to use absolute paths to get it work. I dont get happy with relative paths at all.
BR Tom
-
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!