TkinterWeb Extensions
The following objects are extensions to the TkinterWeb widget and are largely internal. You will likely never need to access them, but they are described here just in case.
The methods described in this page may change at any time without warning. If you are relying on anything here, please let me know so I know to keep compatibility.
- class tkinterweb.extensions.SelectionManager(html)
An extension to manage the selection’s state. Largely internal.
Only interact with this object if the convenience methods provided elsewhere are insufficient.
This object can be accessed through the
selection_managerproperty of theTkinterWebwidget.- Variables:
html – The associated
TkinterWebinstance.node – The node the caret is in.
selection_type – The state of the selection (0, 1, or 2), used when double-clicking.
selection_start_node – The node containing the start of the selection.
selection_start_offset – The selection’s offset within the node.
selection_end_node – The node containing the end of the selection.
selection_end_offset – The selection’s offset within the node.
New in version 4.11.
- begin_selection(node, offset)
Begin selecting.
- reset_selection_type()
Reset the selection type.
- clear_selection()
Clear the current selection.
- update_tags()
Update selection and find tag colours.
- select_all()
Select all text in the document.
- double_click_selection()
Stimulate a double-click on the selection.
- extend_selection(node, offset)
Extend the selection.
- update_selection()
Update the current selection.
- get_selection()
Return any selected text.
- copy_selection()
Copy the selected text to the clipboard.
- class tkinterweb.extensions.CaretManager(html)
An extension to manage the caret’s state. Largely internal.
Only interact with this object if the convenience methods provided elsewhere are insufficient.
This object can be accessed through the
caret_managerproperty of theTkinterWebwidget.- Variables:
html – The associated
TkinterWebinstance.node – The node the caret is in.
offset – The caret’s offset within the node.
index – The document text index of the start of the node; fallback if the node is deleted.
caret_frame – The blinky widget.
target_offset – The text offset used for traversing up/down.
blink_delay – The caret’s blink delay, in milliseconds. Updated in version 4.11.
caret_width – The caret’s width, in pixels. New in version 4.11.
caret_color – The caret’s colour. If None, the text colour under it will be matched.
scrolling_threshold – If the distance between the visible part of the page and the caret is nonzero but is less than this number, a scrolling animation will play.
scrolling_teleport – If the distance between the visible part of the page and the caret is nonzero but is greater than
scrolling_threshold, the page is scrolled to this number before the scrolling animation plays.
New in version 4.8.
- set(node, offset, recalculate=False)
Set the caret’s position.
- is_placed()
Check if the caret has been placed onto the document.
- register_nodes_from_index(event, index, update_caret_start=False)
Update the caret’s internal state.
- shift_up(event=None, update=True)
Shift the caret up.
- shift_down(event=None, update=True)
Shift the caret down.
- shift_left(event=None, update_caret_start=True, update=True)
Shift the caret left.
- shift_right(event=None, update_caret_start=True, update=True)
Shift the caret right.
- update(event=None, auto_scroll=True, fallback=None, update=True, xview=None, yview=None)
Refresh the caret or update its position.
- hide()
Hide the caret. Show the caret again by calling
CaretManager.update().
- reset()
Hide the caret and reset its position.
- class tkinterweb.extensions.EventManager(html)
An extension to manage custom node bindings and JavaScript events. Largely internal.
Only interact with this object if the convenience methods provided elsewhere are insufficient.
This object can be accessed through the
event_managerproperty of theTkinterWebwidget.- Variables:
html – The associated
TkinterWebinstance.bindings – A dictionary of bindings. You shouldn’t need to touch this.
loaded_elements – A list storing loaded elements.
New in version 4.10.
- reset()
Reset all bindings.
- post_event(node, JS_event_name, event=None, Tk_event_name=None)
Given a CSS node and JavaScript event name, trigger any related bindings.
If
eventis provided, the event generated will be modified from the given event. IfTk_event_nameis provided, an event will be created using the given name.All generated events have the additional
nodeproperty, representing the corresponding Tkhtml node.
- create_modified_event(node, event, Tk_event_name=None)
Create a new event using details from
event.
- create_new_event(node, Tk_event_name)
Create a new event.
- bind(node, event, callback, add=None)
Add a binding.
- unbind(node, event, funcid=None)
Remove a binding.
- post_element_event(node_handle, attribute, event=None, event_name=None)
Post an element event.
New in version 4.11.
- send_onload(root=None, children=None)
Send the onload signal for nodes that aren’t handled at runtime. We keep this a seperate command so that it can be run after inserting elements or changing the innerHTML.
New in version 4.11.
- class tkinterweb.extensions.WidgetManager(html)
An extension to manage stored widgets. Largely internal.
Only interact with this object if the convenience methods provided elsewhere are insufficient.
This object can be accessed through the
widget_managerproperty of theTkinterWebwidget.- Variables:
html – The associated
TkinterWebinstance.widget_container_attr – The HTML attribute given to elements containing a widget.
hovered_embedded_node – True if the mouse is over a widget in the document, otherwise False.
New in version 4.11.
- get_node_widget(node)
Get the widget associated with the given node.
- handle_node_replacement(node, widgetid, deletecmd, stylecmd=None, allowscrolling=True, handledelete=True, check=True)
Replace a Tkhtml3 node with a Tkinter widget.
This method is used internally by
set_node_widget()and offers more control.I don’t recommend using it unless absolutely needed.
- map_node(node, force=False)
Redraw a node if it currently contains a Tk widget.
- set_node_widget(node, widgetid=None)
Replace a node with a Tk widget.
- class tkinterweb.extensions.SearchManager(html)
An extension to manage search the document. Largely internal.
Only interact with this object if the convenience methods provided elsewhere are insufficient.
This object can be accessed through the
search_managerproperty of theTkinterWebwidget.- Variables:
html – The associated
TkinterWebinstance.
New in version 4.11.
- find_text(searchtext, select, ignore_case, highlight_all, test=False)
Search for and highlight specific text in the document.