|
| 1 | +# Button |
| 2 | + |
| 3 | +Buttons provide clickable interface elements with hover effects. |
| 4 | + |
| 5 | +## Basic Usage |
| 6 | + |
| 7 | +```python |
| 8 | +button = pygameui.Button( |
| 9 | + position=(100, 100), |
| 10 | + content="Click Me", |
| 11 | + width=200, |
| 12 | + height=50, |
| 13 | + color=(255, 255, 255), |
| 14 | + hover_color=(200, 200, 200), |
| 15 | + click_color=(150, 150, 150), |
| 16 | + text_color=(0, 0, 0), |
| 17 | + centered=True |
| 18 | +) |
| 19 | +``` |
| 20 | + |
| 21 | +## Properties |
| 22 | + |
| 23 | +```python |
| 24 | +position: tuple[int, int], |
| 25 | +width: int = 200, |
| 26 | +height: int = 50, |
| 27 | +border_radius: int = 10, |
| 28 | +content: str = "Click me.", |
| 29 | +color: tuple[int, int, int] = (255, 255, 255), |
| 30 | +hover_color: tuple[int, int, int] = (200, 200, 200), |
| 31 | +click_color: tuple[int, int, int] = (150, 150, 150), |
| 32 | +text_color: tuple[int, int, int] = (100, 100, 100), |
| 33 | +text_hover_color: tuple[int, int, int] = (0, 0, 0), |
| 34 | +text_click_color: tuple[int, int, int] = (0, 0, 0), |
| 35 | +font_size: int = 20, |
| 36 | +font_family: str = "Arial", |
| 37 | +centered: bool = False |
| 38 | +``` |
| 39 | + |
| 40 | +- `position`: Tuple of (x, y) coordinates |
| 41 | +- `width`: Width of the button |
| 42 | +- `height`: Height of the button |
| 43 | +- `border_radius`: Radius for rounded corners |
| 44 | +- `content`: Text displayed on the button |
| 45 | +- `color`: Default button backgroundcolor |
| 46 | +- `hover_color`: Backgroundcolor when the button is hovered over |
| 47 | +- `click_color`: Backgroundcolor when the button is clicked |
| 48 | +- `text_color`: Color of the text when not hovered |
| 49 | +- `text_hover_color`: Color of the text when hovered over |
| 50 | +- `text_click_color`: Color of the text when clicked |
| 51 | +- `font_size`: Size of the text font |
| 52 | +- `font_family`: Font family for the text |
| 53 | +- `centered`: If True, the button is centered on the provided position |
| 54 | + |
| 55 | +### Button States |
| 56 | +- Normal: Default appearance |
| 57 | +- Hover: When mouse is over the button |
| 58 | +- Click: When button is being pressed |
0 commit comments