Page#
- class toui.pages.Page(html_file=None, html_str=None, url=None, title=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
- title#
In desktop app, this attribute will be the title of the window.
- Type:
str
- window_defaults#
In desktop apps, this dictionary sets the default parameters of the window. To set a certain default parameter for a window before creating it, include it in this dictionary. The parameters that can be set are the keyword arguments of the class [webview.create_window()](https://pywebview.flowrl.com/guide/api.html) in pywebview package.
- Type:
dict
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.
title (str) – In desktop app, this parameter will be the title of the window.
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 |
|
Gets an element from its CSS selector. |
|
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. |
|
Adds a footer to the page. |
|
Adds a navigation bar to the page. |
|
Converts the Page object to a bs4.BeautifulSoap object. |
|
Converts the Page object to an HTML file. |
|
Converts the Page object to HTML code. |