Page#
- class toui.pages.Page(html_file=None, html_str=None, url=None)[source]#
Bases:
objectCreates an HTML page that can be used as a window or as a webpage.
- url#
The URL of the page.
- Type:
str
- window#
A pywebview.Window object. It is automatically created when adding the Page to DesktopApp and running the app.
- Type:
pywebview.Window, default = None
Examples
Importing the class:
>>> from toui import Page
Creating a Page from an HTML file:
>>> path = "../examples/assets/test1.html" >>> page = Page(html_file=path)
Creating a Page from a string:
>>> page = Page(html_str="<html><h1>Hello</h1></html>") >>> page <html><h1>Hello</h1></html>
Creating a page with a URL:
>>> page = Page(html_str="<html><h1>Hello</h1></html>", url="/")
Getting an element in the Page from its id:
>>> page = Page(html_str='<html><h1 id="heading">Hello</h1></html>', url="/") >>> element = page.get_element(element_id="heading") >>> element <h1 id="heading">Hello</h1>
See also
pywebview api: https://pywebview.flowrl.com/guide/api.html
- Parameters:
html_file (str) – The path to the HTML file.
html_str (str) – A string containing HTML code.
url (str, optional) – If the page was used as a webpage, this will be the URL of the page.
Methods#
Adds a function to the Page. |
|
Converts a bs4.BeautifulSoap object to a Page object. |
|
Reads an HTML file and converts it to an Page object. |
|
Converts HTML code to a Page object. |
|
Gets the first |
|
Gets an element from its |
|
Get elements from the Page by their tag name and attributes. |
|
Gets the first |
|
Sets a function that will be called when the user types the URL in a browser or when a request is sent to the URL. |
|
Converts the Page object to a bs4.BeautifulSoap object. |
|
Converts the Page object to an HTML file. |
|
Converts the Page object to HTML code. |