You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 line
654 B

  1. from __future__ import annotations
  2. from typing import TYPE_CHECKING, Any, Callable, Optional
  3. from .element import Element
  4. if TYPE_CHECKING:
  5. from .styles.base import BaseStyle
  6. class Button(Element):
  7. def __init__(
  8. self,
  9. name: str,
  10. label: str,
  11. callback: Optional[Callable] = None,
  12. style: Optional[BaseStyle] = None,
  13. **metadata: Any,
  14. ):
  15. self.name = name
  16. self.label = label
  17. self.callback = callback
  18. super().__init__(style=style, metadata=metadata)
  19. def activate(self) -> Any:
  20. if self.callback:
  21. return self.callback()
  22. return True