diff --git a/docs/how_it_works.md b/docs/how_it_works.md index e968f03..57b5ef3 100644 --- a/docs/how_it_works.md +++ b/docs/how_it_works.md @@ -30,11 +30,17 @@ The most important JSON object. It contains the following keys: {"type": "page", "func": ..., "args": ..., + "selector-to-element": ..., "url": ..., "html": ..., "uid": ...} ``` -`type` is the type of JSON object, and it has the value 'page' when JavaScript sends the HTML document as data. `func` contains the name of the Python function that should be called, `args` are the arguments of this function, `url` is the URL of the HTML page that sent the data, `html` is the HTML document itself as a string. `uid` is the id of the window when creating desktop apps. +`type` is the type of JSON object, and it has the value 'page' when JavaScript sends the HTML document as data. `func` contains the name of the Python function that should be called, `args` are the arguments of this function, `selector-to-element` is a boolean that is only true if one of the arguments is an HTML element, `url` is the URL of the HTML page that sent the data, `html` is the HTML document itself as a string. `uid` is the id of the window when creating desktop apps. +If one of the argument is an HTML element, it will be converted to a JSON that contains its CSS selector: +```json +{"type": "element", + "selector": ..., +``` #### Files information JSON Another type of JSON object is a JSON that contains uploaded files: diff --git a/docs/index.rst b/docs/index.rst index d94f0be..720e79c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ ToUI ==== -Version: v2.2.0 +Version: v2.3.0 .. include:: ../README.md :parser: myst_parser.sphinx_ diff --git a/docs/toui.elements.Element.get_selector.rst b/docs/toui.elements.Element.get_selector.rst new file mode 100644 index 0000000..86928d6 --- /dev/null +++ b/docs/toui.elements.Element.get_selector.rst @@ -0,0 +1,4 @@ +Element.get_selector +-------------------- + +.. automethod:: toui.elements.Element.get_selector diff --git a/docs/toui.elements.Element.rst b/docs/toui.elements.Element.rst index e84339f..c338fc4 100644 --- a/docs/toui.elements.Element.rst +++ b/docs/toui.elements.Element.rst @@ -22,6 +22,7 @@ Methods toui.elements.Element.get_height_property toui.elements.Element.get_id toui.elements.Element.get_selected + toui.elements.Element.get_selector toui.elements.Element.get_style_property toui.elements.Element.get_value toui.elements.Element.get_width_property diff --git a/docs/toui.elements.IFrameElement.get_selector.rst b/docs/toui.elements.IFrameElement.get_selector.rst new file mode 100644 index 0000000..9f290f9 --- /dev/null +++ b/docs/toui.elements.IFrameElement.get_selector.rst @@ -0,0 +1,4 @@ +IFrameElement.get_selector +-------------------------- + +.. automethod:: toui.elements.IFrameElement.get_selector diff --git a/docs/toui.elements.IFrameElement.rst b/docs/toui.elements.IFrameElement.rst index aae38f2..af04ceb 100644 --- a/docs/toui.elements.IFrameElement.rst +++ b/docs/toui.elements.IFrameElement.rst @@ -22,6 +22,7 @@ Methods toui.elements.IFrameElement.get_height_property toui.elements.IFrameElement.get_id toui.elements.IFrameElement.get_selected + toui.elements.IFrameElement.get_selector toui.elements.IFrameElement.get_style_property toui.elements.IFrameElement.get_value toui.elements.IFrameElement.get_width_property diff --git a/docs/toui.pages.Page.get_element_from_selector.rst b/docs/toui.pages.Page.get_element_from_selector.rst new file mode 100644 index 0000000..366509d --- /dev/null +++ b/docs/toui.pages.Page.get_element_from_selector.rst @@ -0,0 +1,4 @@ +Page.get_element_from_selector +------------------------------ + +.. automethod:: toui.pages.Page.get_element_from_selector diff --git a/docs/toui.pages.Page.rst b/docs/toui.pages.Page.rst index b55caf1..6ee1048 100644 --- a/docs/toui.pages.Page.rst +++ b/docs/toui.pages.Page.rst @@ -16,6 +16,7 @@ Methods toui.pages.Page.from_str toui.pages.Page.get_body_element toui.pages.Page.get_element + toui.pages.Page.get_element_from_selector toui.pages.Page.get_elements toui.pages.Page.get_html_element toui.pages.Page.get_window diff --git a/setup.py b/setup.py index 40b7e0b..28156c3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ small = False if "--small" in sys.argv: small = True - sys.argv.remove('--small') + sys.argv.remove('--small') name = "ToUI" version = __version__ diff --git a/tests/assets/full_app.html b/tests/assets/full_app.html index 4c61c65..70ea50f 100644 --- a/tests/assets/full_app.html +++ b/tests/assets/full_app.html @@ -37,6 +37,11 @@