Changelog
The API changed significantly in version 4.
Key Changes
Faster load speed
A more intuitive API
Support for experimental Tkhtml features, such as page printing
Widget behaviour and API is now more closely aligned with standard Tkinter widgets
Many DOM improvements. The DOM API now more closely mirrors its JavaScript counterpart.
Dozens of new configuration options, including access to more settings and the ability to link a JavaScript interpreter
Added basic JavaScript support (new in version 4.1)
Improved embedded widget handling (new in version 4.2)
Cross-platform SVG and
border-radiussupport (new in version 4.4)Support for Tcl 9 (new in version 4.5)
Caret browsing functionality (new in version 4.8)
Improved thread safety (new in version 4.9)
Ability to bind to HTML elements (new in version 4.10)
Added an HTML-based text widget (new in version 4.15)
Removed
Version 4.0:
HtmlFrame.get_zoom()- useHtmlFrame.cget("zoom")HtmlFrame.set_zoom()- useHtmlFrame.configure(zoom=)HtmlFrame.get_fontscale()- useHtmlFrame.cget("fontscale")HtmlFrame.set_fontscale()- useHtmlFrame.configure(fontscale=)HtmlFrame.get_parsemode()- useHtmlFrame.cget("parsemode")HtmlFrame.set_parsemode()- useHtmlFrame.configure(parsemode=)HtmlFrame.set_message_func()- useHtmlFrame.configure(message_func=)HtmlFrame.set_broken_webpage_message()- useHtmlFrame.configure(on_navigate_fail=). Note thaton_navigate_failrequires a function instead.HtmlFrame.set_maximum_thread_count()- useHtmlFrame.configure(threading_enabled=)HtmlFrame.set_recursive_hover_depth()- useHtmlFrame.html.recursive_hover_depth=HtmlFrame.add_visited_links()- useHtmlFrame.configure(visited_links=)HtmlFrame.clear_visited_links()- useHtmlFrame.configure(visited_links=)HtmlFrame.enable_stylesheets()- useHtmlFrame.configure(stylesheets_enabled=)HtmlFrame.enable_images()- useHtmlFrame.configure(images_enabled=)HtmlFrame.enable_forms()- useHtmlFrame.configure(forms_enabled=)HtmlFrame.enable_objects()- useHtmlFrame.configure(objects_enabled=)HtmlFrame.enable_caches()- useHtmlFrame.configure(caches_enabled=)HtmlFrame.enable_dark_theme()- useHtmlFrame.configure(dark_theme_enabled=, image_inversion_enabled=)HtmlFrame.on_image_setup()- useHtmlFrame.configure(on_resource_setup=)HtmlFrame.on_downloading_resource()- bind to<<DownloadingResource>>/utilities.DOWNLOADING_RESOURCE_EVENTHtmlFrame.on_done_loading()- bind to<<DoneLoading>>/utilities.DONE_LOADING_EVENTHtmlFrame.on_url_change()- bind to<<UrlChanged>>/utilities.URL_CHANGED_EVENT and use :attr:.HtmlFrame.current_url`HtmlFrame.on_icon_change()- bind to<<IconChanged>>/utilities.ICON_CHANGED_EVENTand useHtmlFrame.titleHtmlFrame.on_title_change()- bind to<<TitleChanged>>/utilities.TITLE_CHANGED_EVENTand useHtmlFrame.titleHtmlFrame.on_form_submit()- useHtmlFrame.configure(on_form_submit=)HtmlFrame.on_link_click()- useHtmlFrame.configure(on_link_click=)HtmlFrame.yview_toelement()- useHTMLElement.scrollIntoView()HtmlFrame.get_currently_hovered_node_text()-HtmlFrame.get_currently_hovered_element()HtmlFrame.get_currently_hovered_node_tag()-HtmlFrame.get_currently_hovered_element()HtmlFrame.get_currently_hovered_node_attribute()-HtmlFrame.get_currently_hovered_element()HtmlFrame.get_current_link()- useHtmlFrame.get_currently_hovered_element()The
widgetidattribute no longer embeds widgets. Use<object data=name_of_your_widget></object>orHTMLElement.widgetinstead. This improves load speeds and allows for widget style handling.
Version 4.2:
TkinterWeb.replace_widget()TkinterWeb.replace_element()TkinterWeb.remove_widget()
Version 4.8
HtmlFrame.replace_widget()(deprecated in version 4.0) - useHtmlFrame.widget_to_element()andHTMLElement.widgetHtmlFrame.replace_element()(deprecated in version 4.0) - useHTMLElement.widgetHtmlFrame.remove_widget()(deprecated in version 4.0) - useHTMLElement.remove()
Version 4.14:
Deprecated
Version 4.11:
TkinterWeb.update_tags()- useSelectionManager.update_tags()TkinterWeb.select_all()- useSelectionManager.select_all()TkinterWeb.clear_selection()- useSelectionManager.clear_selection()TkinterWeb.update_selection()- useSelectionManager.update_selection()TkinterWeb.get_selection()- useSelectionManager.get_selection()TkinterWeb.copy_selection()- useSelectionManager.copy_selection()TkinterWeb.allocate_image_name()- useImageManager.allocate_image_name()TkinterWeb.handle_node_replacement()- useWidgetManager.handle_node_replacement()TkinterWeb.map_node()- useWidgetManager.map_node()TkinterWeb.find_text()- useSearchManager.find_text()TkinterWeb.send_onload()- useEventManager.send_onload()
Version 4.12:
Htmlframe.register_JS_object()- useJSEngine.register()
Version 4.14:
The configuration option
default_style- usetkinterweb.utilities.DEFAULT_STYLEor thedefaultstyleconfiguration option.The configuration option
dark_style- usetkinterweb.utilities.DARK_STYLEor thedefaultstyleconfiguration option.The configuration option
about_page_background- usettk.Style().configure("TFrame", background=).The configuration option
about_page_foreground- usettk.Style().configure("TFrame", foreground=).
Version 4.16:
HtmlFrame.get_caret_page_position()- useHtmlFrame.get_caret_position(return_element=False)HtmlFrame.set_caret_page_position()- useHtmlFrame.set_caret_position(index=)HtmlFrame.get_selection_page_position()- useHtmlFrame.get_selection_position(return_elements=False)HtmlFrame.set_selection_page_position()- useHtmlFrame.set_selection_position(start_index=, end_index=)
Version 4.22:
HtmlFrame.insert_html()- useHtmlFrame.add_html()
Renamed
Version 4.0:
HtmlFrame.get_currently_selected_text()->HtmlFrame.get_selection()TkwDocumentObjectModel->HTMLDocumentHtmlElement->HTMLElementHtmlElement.style()->HTMLElement.styleHtmlElement.innerHTML()->HTMLElement.innerHTMLHtmlElement.textContent()->HTMLElement.textContentHtmlElement.attributes()->HTMLElement.attributesHtmlElement.tagName()->HTMLElement.tagNameHtmlElement.parentElement()->HTMLElement.parentElementHtmlElement.children()->HTMLElement.childrenThe
scroll-xattribute was changed to thetkinterweb-scroll-xattribute. Like theoverflowCSS property, valid options are now “auto”, “visible”, “clip”, “scroll”, and “hidden”.
Added
Version 4.0:
CSSStyleDeclaration.*(any camel-case CSS property)TkinterWeb.enable_imagecache()TkinterWeb.update_tags()utilities.DOWNLOADING_RESOURCE_EVENT(equivalent to<<DownloadingResource>>)utilities.DONE_LOADING_EVENT(equivalent to<<DoneLoading>>)utilities.URL_CHANGED_EVENT(equivalent to<<UrlChanged>>)utilities.ICON_CHANGED_EVENT(equivalent to<<IconChanged>>)utilities.TITLE_CHANGED_EVENT(equivalent to<<TitleChanged>>)Many new configuration options were added. See the HTML Widgets Documentation for a complete list.
The
tkinterweb-full-pageattribute can now be added to elements to make them the same height as the viewport. Use this to align content vertically. This has no effect when shrink is enabled.
Version 4.1:
HtmlFrame.register_JS_object`()HTMLElement.widget(updated again in version 4.2)HTMLElement.onchangeHTMLElement.onloadHTMLElement.onclickHTMLElement.oncontextmenuHTMLElement.ondblclickHTMLElement.onmousedownHTMLElement.onmouseenterHTMLElement.onmouseleaveHTMLElement.onmousemoveHTMLElement.onmouseoutHTMLElement.onmouseoverHTMLElement.onmouseupTkinterWeb.send_onload()Added support for many JavaScript events.
The new configuration option
on_element_scriptcan be used to add a callback to run when a JavaScript event attribute on an element is encountered.The new configuration option
javascript_enabledcan be used to enable JavaScript support.
Version 4.2:
TkinterWeb.map_node()TkinterWeb.replace_node_with_widget()
Version 4.4:
HtmlFrame.insert_html()Added support for the HTML number input.
The new configuration option
tkhtml_versioncan be used to choose a specific Tkhtml version to load.
Version 4.5:
The new configuration option
ssl_cafilecan be used to provide a path to a CA Certificate file. See bug #28.
Version 4.6:
The new configuration option
request_timeoutcan be used to specify the number of seconds to wait before a request times out.
Version 4.7:
The new
<<DOMContentLoaded>>event will be generated once the page DOM content has loaded. The page may not be done loading, but at this point it is possible to interact with the DOM.
Version 4.8:
HtmlFrame.get_caret_page_position()(deprecated in version 4.16)HtmlFrame.set_caret_page_position()(deprecated in version 4.16)HtmlFrame.get_selection_page_position()(deprecated in version 4.16)HtmlFrame.set_selection_page_position()(deprecated in version 4.16)TkinterWeb.update_selection()The new configuration option
caret_browsing_enabledcan be used to enable or disable caret browsing mode.
Version 4.9:
TkinterWeb.allocate_image_name()TkinterWeb.check_images()
Version 4.10:
You can now set
allowstyling="deep"on elements with embedded widgets to also style their subwidgets.
Version 4.11:
Version 4.12:
Version 4.13:
Version 4.14:
The new configuration option
request_funccan be used to set a custom script to use to download resources.The new configuration option
defaultstylecan be used to set the default stylesheet to use when parsing HTML.
Version 4.15:
HtmlFrame.add_css()now accepts the additional parameterpriority.CaretManager.shift_left(),CaretManager.shift_right(),CaretManager.shift_up(),CaretManager.shift_down(), andCaretManager.shift_update()now accept the additional parameterupdate.The
HtmlTextwidget now supports thebackground,foreground,bg, andfgkeywords.
Version 4.16:
HtmlFrame.get_caret_position()now accepts the additional parameterreturn_element.HtmlFrame.get_selection_position()now accepts the additional parameterreturn_elements.The
HtmlTextwidget now supports thestatekeyword.Added introductory support for
HtmlLabelandHtmlFrame(shrink=True)widget resizing. This feature is experimental and may change at any time. SetHtmlFrame.unshrink = Trueto enable it and let me know how it works!
Version 4.17:
The new configuration option
textwrapcan be used to enable or disable text wrapping. In general, text wrapping should be disabled when shrink is enabled, and should be enabled when shrink is disabled. This is the default behaviour. This is only partially supported in Tkhtml 3.0; make sure you have the TkinterWeb-Tkhtml-Extras package installed and up-to-date.
Version 4.18:
Added basic support for most HTML5 elements in the corresponding TkinterWeb-Tkhtml-Extras release (version 1.3.0)
Added support for the HTML
<details>,<summary>, and<q>tags.
Version 4.19:
Added support for the
mediaattribute of<link>elements. Ensure our experimental Tkhtml release is installed.Added support for the HTML
<progress>tag. Ensure TkinterWeb-Tkhtml-Extras is installed.The new configuration option
javascript_backendcan be used to evaluate<script>elements and JavaScript events as Python code.
Version 4.20:
Version 4.21:
Version 4.22:
HtmlFrame.add_html()now accepts the new parameterindex.
Version 4.23:
HtmlFrame.snapshot_page()now accepts the new parameterinclude_head.
Version 4.24:
HtmlFrame.load_form_data()now accepts the new parameterforce.
Changed/Fixed
Version 4.0:
HtmlFrame.configure(),HtmlFrame.config(),HtmlFrame.cget(), andHtmlFrame.__init__()now support more configuration options.HtmlFrame.load_website(),HtmlFrame.load_file(), andHtmlFrame.load_url()no longer accept theinsecureparameter. useHTMLElement.configure(insecure=).Enabling/disabling caches now enables/disables the Tkhtml image cache.
Threading now cannot be enabled if the Tcl/Tk build does not support it.
HTMLElement.remove()now raises atkinter.TclErrorwhen invoked on<html>or<body>elements, which previously caused segmentation faults.HTMLElement.innerHTMLandHTMLElement.textContentnow raise atkinter.TclErrorwhen invoked on<html>elements, which previously caused segmentation faults.Shorthand CSS properties can now be set and returned after the document is loaded.
The ability to style color selector inputs was improved.
The ability to access form elements has improved.
Text elements now emit the
<<Modified>>event after the content updates.The TkinterWeb demo and some of the built-in pages have been updated. Many internal methods and variables have been renamed, removed, or modified.
Version 4.1:
HtmlFrame.screenshot_page()is now partially supported on Windows and now accepts the additional parametershow.The default selection and find text colors are less abrupt.
Version 4.2:
Widgets embedded in the document can now be removed without removing the containing element.
Version 4.3:
Prebuilt Tkhtml binaries have been split off into a new package, TkinterWeb-Tkhtml. This has been done to work towards bug #52 and reduce the download size of the TkinterWeb package when updating.
Version 4.4:
HtmlFrame.add_html()is now accepts the additional parameterreturn_element.It is now only possible to enable experimental mode if an experimental Tkhtml release is detected.
Some experimental HTML features were enabled in Windows and Linux.
border-radiusis now supported!
Version 4.5:
Periods are now supported in url fragments. See bug #143 .
Tkhtml file loading was updated in version 4.5. Some error messages have also been updated. Please submit a bug report if you notice any issues.
Version 4.6:
Url fragments are now tracked as the document loads. This ensures that the fragment is still visible even after loading CSS files or images that change the layout of the document.
gzipanddeflatecontent encodings are now supported. Brotli compression is also supported if thebrotlimodule is installed. This increases page load speeds and decreases bandwidth usage in some websites.Pressing Ctrl-A in an HTML number input, text input, or textarea will cause the widget’s text to be selected. Pasting will now overwrite any selected text.
Loading local files with a query string in the url will no longer raise an error.
Fixed
HTMLDocument.querySelector().
Version 4.7:
Fixed flickering when moving the mouse over scrollbars in
<iframe>elements.bind()calls to theHtmlFrame.bind()respect requests to bind<Enter>and<Leave>. All other events are still bound to the associatedTkinterWebinstance. Keep in mind that overriding the default bindings to<Enter>and<Leave>may cause unwanted side effects.
Version 4.8:
All HTML widgets now bind to
<Up>,<Down>,<Left>,<Right>,<Prior>,<Next>,<Home>, and<End>by default.Fixed
HTMLElement.parentElement().
Version 4.9:
TkinterWeb is now thread-safe when loading resources. All callbacks now will run on the main thread.
Fixed loading of data urls.
Local files will now load regardless of the number of slashes before the path.
Fixed some dark mode and image inversion bugs.
Version 4.10:
Binding button presses and motion events to the widget no longer removes internal bindings.
Setting
html.maximum_thread_count = 0no longer disables threading. Usehtml.threading_enabled = False.PILis now an optional dependency. I also recommend installing the new TkinterWeb-Tkhtml-Extras package.The
HTMLElement.widgetproperty now returns a Tk widget when used on<input>,<textarea>,<select>,<iframe>, and some<object>elements.Fixed scrollbar flashes when the widget opens.
DOM objects now provide more useful information when printed.
By default, scrolling on embedded widgets now scrolls the page if the embedded widget or subwidgets do not bind to the mousewheel.
If dark theme is enabled, HTML code passed to the configuration option
dark_stylewill now be automatically appended onto the code set bydefault_style.Plain text is no longer rendered as a blank page.
The event queue now only runs when threading is enabled.
Modifying the selection when selection is disabled now raises an error.
Modifying the caret position when caret browsing is disabled now raises an error.
Local file loading now happens on the main thread.
Fixed a fatal scrollbar error when loading TkinterWeb on Tk 8.5 on MacOS.
Fixed a fatal binding error when loading TkinterWeb on MacOS.
Many internal changes were made in this release. If you notice any bugs, please report them.
Version 4.11:
Fixed some minor bugs.
JavaScript events no longer fire when events are disabled.
The
TkinterWebwidget was restructured in this release. If you notice any bugs, please report them.
Version 4.12:
Fixed more minor bugs.
Side-scrolling is now supported.
Version 4.13:
Fixed more minor bugs, including a segfault when inserting a widget into the page’s root element.
grid_propagate(0)andpack_propagate(0)no longer have any effect on the widget. Requested width and height will now always be respected.
Version 4.14:
Fixed more minor bugs.
The
HtmlLabelwidget now automatically matches the ttk style.Alternate text for broken images is now displayed natively through Tkhtml.
Version 4.15:
Fixed more minor bugs.
Improved some error messages.
Improved code autocompletion.
All HTML widgets now bind to
<Ctrl-A>by default.Equality checking between
HTMLElementobjects is now fully supported.The
HtmlTextwidget is now editable out-of-the-box!The
HtmlLabelwidget now uses theTLabelstyle by default instead ofTFrame.
Version 4.16:
Fixed more minor bugs.
HtmlFrame.set_caret_position()now sets the caret relative to the document text when no element is provided.HtmlFrame.set_selection_position()now sets the selection relative to the document text when no elements are provided.A
NotImplementedErrorwill now raise when changing some settings viaHtmlFrame.configure(). This occurs on settings that have no effect after the widget loads and on the shrink value, which has been causing segfaults when changed after the widget loads. If you absolutely need to change the shrink value on the fly useHtmlFrame.html.configure()Text wrapping has been disabled by default in the
HtmlLabelandHtmlFrame(shrink=True)widgets.
Version 4.17:
Fixed some image loading and
<iframe>scrolling regressions.Fixed a bug where stopping a page load prevented the page from loading again when caches were enabled.
<style>tags and local files are now always evaluated in the main thread.The configuration options
horizontal_scrollbarandvertical_scrollbarnow accept another option,"dynamic". This behaves like"auto", with the difference that scrollbars are always hidden inHtmlLabelandHtmlFrame(shrink=True)widgets. This is the new default for vertical scrollbars.
Version 4.18:
Triple-clicking on text now highlights all text in the line, even if multiple inline elements are present.
Fixed some bugs that arose when stopping a page load and introduced some minor optimizations.
Version 4.19:
Fixed some bugs.
Callbacks now accept
Noneas a valid value.Permitted values for configuration option are now more tightly restricted.
CSSStyleDeclaration.cssTextcan now be set.
Version 4.20:
Fixed some regressions and bugs.
The
HtmlTextwidget now emits the<<Modified>>event when the user types in it.
Version 4.21:
Fixed a bug where
<style>and<script>elements were left out of the output fromHtmlFrame.save_page(). The output of this method is now the document’s original HTML and is unaffected by JavaScript or DOM changes.Fixed a bug where adding
HtmlLabelwidgets causes the app to open in the wrong part of the screen.HtmlFrame.current_urlno longer returns the working directory when loading plain HTML code.
Version 4.23:
Whitespace is now automatically stripped from the page’s title.
Improved
HtmlFrame.snapshot_page()output formatting and accuracy.In an effort to reduce the widget’s memory footprint, all HTML widgets no longer remember the original HTML code they are displaying:
The output of
HtmlFrame.save_page()is now the document’s original HTML only when the page has been cached. This is the case when caching is enabled and a url is loaded. Otherwise,HtmlFrame.snapshot_page()is used, with the contents of the<head>tag included if the widget is still loading.HtmlFrame.reload()now only reloads pages loaded from a url.
The original intent of both both methods is to be used when a url is loaded, and in an ideal world caching should always be enabled.
HtmlFrame.reload()andHtmlFrame.save_page()now fully support pages generated through form submissions.The
<<UrlChanged>>/utilities.URL_CHANGED_EVENTevent now also fires when a url is navigated to.The page cache backend was overhauled in this release. Please file a bug report if you notice any issues.
Loading cached stylesheets, scripts, and images no longer spawns new threads. This fixes some bugs when loading cached documents and improves load times on some pages.
Disabling the cache now also clears it.
Version 4.24:
Stopped windows from teleporting across the galaxy or disappearing altogether when changing
HTMLElement.innerHTMLandHTMLElement.textContentbefore the app opens.Fixed a minor threading bug in
HtmlFrame.load_form_data().Fixed bug #150 .
Version 4.25:
In an effort to closer match stock Tk widgets, debug message behaviour has been adjusted:
Debug messages are now disabled by default. Set the configuration option
messages_enabled=Trueto enable them.In an effort to keep backwards compatibility, if the configuration option
message_funcis set, the value ofmessages_enabledis ignored.
Auto-scrolling behaviour when searching the page for text been improved.
Fixed a regression impacting
HTMLElement.textContent.
Please report bugs or request new features on the issues page.