mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -05:00
pre-commit.ci has been disabled for a while. This PR ensures that all the files has been validated/formatted by pre-commit, to avoid spurious diffs in subsequent PRs. During the process, ruff broke the code because it removed an "unused" import which was actually used. A linter which breaks my code is a linter which I cannot trust, so I just removed it. I re-enabled isort instead.
28 lines
654 B
Python
28 lines
654 B
Python
import random
|
|
from datetime import datetime as dt
|
|
|
|
from pyscript import display
|
|
from pyweb import pydom
|
|
from pyweb.base import when
|
|
|
|
|
|
@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)
|