Andereoo / TkinterWeb

Python bindings for Tkhtml.
MIT License
153 stars 16 forks source link

<textarea> doesn't populate contents #65

Closed nickzoic closed 1 year ago

nickzoic commented 1 year ago

Example:

from tkinterweb import HtmlFrame
import tkinter as tk

html = """
<form>
<h1>This is a textarea:</h1>
<textarea name="ta">hello

there          world</textarea>
</form>
"""

root = tk.Tk()
frame = HtmlFrame(root, messages_enabled=False)
frame.load_html(html)
frame.pack(fill="both", expand=True)

root.mainloop()

Expected: Should display a textarea with contents "hello there world", like a browser would.

Observed: Textarea is created with no content.

Andereoo commented 1 year ago

Hi! Thanks for the suggestion and code.

I fixed the bug. Try upgrading TkinterWeb and let me know if it works!

nickzoic commented 1 year ago

Aha, -pre, fantastic :-) I wondered if there was such a thing but hadn't dared go looking into the depths of Tkhtml! Thanks!

Andereoo commented 1 year ago

Yes! You were right about Tkhtml stripping whitespace.

I don't entirely blame you about Tkhtml... It took some digging in the source code for Hv3 (Tkhtml's web browser counterpart) to find that trick :)

nickzoic commented 1 year ago

Yeah once I saw your code I went and looked up http://tkhtml.tcl.tk/tkhtml.html and found TODO: Document -tokens and -pre. :-)

Andereoo commented 1 year ago

Good point! It would really help if they finished the documentation so I wouldn't have to do so much fishing around to get the right usage though...

After all this time I still can't quite figure out how some of those commands work :)

Thanks again for your suggestion here, and the pull request made it really easy!