Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def Clickable(self, count=0):
@idom.event(target_id="an-event")
async def an_event():
self.update(count=count + 1)
return idom.html.div({"anEvent": an_event, "count": count})
async def AnyElement(self):
return idom.html.div()
async def InputWrapper():
return idom.html.div(
idom.widgets.Input(
inp_ingore_var.set,
"number",
inp_ingore_var.value,
{"id": "inp-ignore"},
ignore_empty=True,
),
idom.widgets.Input(
inp_not_ignore_var.set,
"number",
inp_not_ignore_var.value,
{"id": "inp-not-ignore"},
ignore_empty=False,
),
async def IncrCounter(self, count=0):
@idom.event
async def incr_on_click(event):
self.update(count + 1)
button = idom.html.button(
{"onClick": incr_on_click, "id": "incr-button"}, "click to increment"
)
return idom.html.div(button, Counter(count))
async def simple_stateful_element():
index, set_index = idom.hooks.use_state(0)
set_index(index + 1)
return idom.html.div(index)
tasks = []
for index, text in enumerate(items):
async def remove_task(event, index=index):
set_items(items[:index] + items[index + 1 :])
task_text = idom.html.td(idom.html.p(text))
delete_button = idom.html.td({"onClick": remove_task}, idom.html.button(["x"]))
tasks.append(idom.html.tr(task_text, delete_button))
task_input = idom.html.input({"onKeyDown": add_new_task})
task_table = idom.html.table(tasks)
return idom.html.div(task_input, task_table)
async def ShowChartClicks(self):
log = EventLog({})
async def log_event(event):
log.update(event)
return idom.html.div(
ClickableChart(
{
"data": data,
"onClick": log_event,
"style": {"parent": {"width": "500px"}},
},
),
log,
)