mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
* add pyweb * build * add test file * fix pydom example code * remove old reference to js * temporarily comment out query functions on BaseElement while rearranging code to reuse the same underlying logic accross PyDom and other elements * add temp TODO comment to content as it breaks with template elements * update pydom example to define code on external file * fix name type while renaming document -> dom * add real pydom test files * add classes to dom scope * __len__ to ElementCollection * fix some of the old tests * rename test from test_query_by_class to test_getitem_by_class * change test for read and write multiple elements * add find method to BaseElement * fix remaining tests * add Collection Tests * add equality to Collection * add test for collection style manipulation * fix getter for style property and rename style related attribute from pop to remove * add single element creation test * remove append on BaseElement and add body and head to dom * add test_create_element_child to verify child creation * add children getter property to Element * remove old code * remove more old code, change style attribute from visibility to visible and now default getters on collection to return a list with the value of an attribute for every element in the collection * remove more old code and add possibility to customize test flags via url * add support to pass Js and pydom.Element elements to when decorator * remove methods related to input type of elements until we have a better design for it * rename _element to _js * add test_when decorator with a ElementCollection input * when decorator now supporte pydom.ElementCollection as input * update pyscript.js * remove useless variable from when decorator * remove base.py from pyweb * add nodes for append collection test and add better feedback on successes vs failure * add tests and fix code for support of append Element and ElementCollection * manage access to content attribute when tagname is template * fix comment --------- Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
27 lines
653 B
Python
27 lines
653 B
Python
import random
|
|
from pyscript import display
|
|
from pyweb import pydom
|
|
from pyweb.base import when
|
|
from datetime import datetime as dt
|
|
|
|
|
|
@when("click", "#just-a-button")
|
|
def on_click(event):
|
|
print(f"Hello from Python! {dt.now()}")
|
|
display(f"Hello from Python! {dt.now()}", append=False, target="result")
|
|
|
|
|
|
@when("click", "#color-button")
|
|
def on_color_click(event):
|
|
print("1")
|
|
btn = pydom["#result"]
|
|
print("2")
|
|
btn.style["background-color"] = f"#{random.randrange(0x1000000):06x}"
|
|
|
|
|
|
def reset_color():
|
|
pydom["#result"].style["background-color"] = "white"
|
|
|
|
|
|
# btn_reset = pydom["#color-reset-button"][0].when('click', reset_color)
|