Spaces:
Running
Running
File size: 910 Bytes
b72ab63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from __future__ import annotations
from gradio.component_meta import create_or_modify_pyi
from gradio.events import EventListener, Events
BLOCKS_EVENTS: list[EventListener | str] = [Events.load]
class BlocksMeta(type):
def __new__(cls, name, bases, attrs):
for event in BLOCKS_EVENTS:
trigger = (
event
if isinstance(event, EventListener)
else EventListener(event_name=event)
).copy()
trigger.set_doc(component=name)
attrs[event] = trigger.listener
component_class = super().__new__(cls, name, bases, attrs)
create_or_modify_pyi(BlocksEvents, "BlocksEvents", BLOCKS_EVENTS)
return component_class
class BlocksEvents:
"""
This class is used to hold the events for the Blocks component. It is populated dynamically
by the BlocksMeta metaclass.
"""
pass
|