Closed oberluz closed 1 year ago
i just tried reversing the calls and it works fine in this order:
html_frame.load_html(html)
html_frame.add_css(css)
Maybe this should be stated in the docs...
Hi! load_html
clears the current page, including CSS. If you want to set the CSS before adding the HTML, use add_html
instead. Good idea - I'll tweak the docs to make that more clear.
makes sense now. thanks!
makes sense now. Great project BTW, thanks!
No worries! Let me know if you have any other questions!
Not sure if I've found a bug but if I do:
self.description_text.html.reset() # I need a reset so that the new content is not appended to the previous content
self.description_text.add_css(self.css)
self.description_text.add_html(html)
instead of
self.description_text.add_html(html)
self.description_text.add_css(self.css)
the images in the html are not displayed
Could you give me some sample code?
ok, I'll craft a small example
Run the following with an image.png in the same directory
from tkinterweb import HtmlFrame
from tkinter import Tk
class Window(Tk):
def __init__(self):
super().__init__()
self.frame = HtmlFrame(self, height='5', messages_enabled=False)
html = """
<h1>html with image</h1>
<p><img alt="" src="image.png" /></p>
<p>some text</p>
"""
# works
self.frame.load_html(html)
self.frame.pack()
# does not work
# self.frame.html.reset()
# self.frame.add_html(html)
# self.frame.pack()
def main():
window = Window()
window.mainloop()
if __name__ == '__main__':
main() # pragma: no cover
still breaks even without the call to reset
I raised https://github.com/Andereoo/TkinterWeb/issues/72 to deal with this as a separate issue as this issue is closed anyway.
Hi,
I loaded the styles.css generated by pygmentize using the html_frame.add_css method and then called html_frame.load_html with some html code that uses the styles but they are not rendered in colour.
The only way I can get it to render them is to call html_frame.load_html(' + html) and this works also without calling html_frame.add_css.
am I using html_frame.add_css incorrectly?