rating_widget
_rating_widget
¶
Star/score rating widget.
Classes:
| Name | Description |
|---|---|
FXRatingWidget |
A clickable star rating widget. |
Classes¶
FXRatingWidget
¶
FXRatingWidget(
parent: Optional[QWidget] = None,
max_rating: int = 5,
initial_rating: float = 0,
allow_half: bool = False,
icon_size: int = 20,
filled_icon: str = "star",
empty_icon: str = "star_border",
half_icon: str = "star_half",
)
Bases: FXThemeAware, QWidget
flowchart TD
fxgui.fxwidgets._rating_widget.FXRatingWidget[FXRatingWidget]
fxgui.fxstyle.FXThemeAware[FXThemeAware]
fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._rating_widget.FXRatingWidget
click fxgui.fxwidgets._rating_widget.FXRatingWidget href "" "fxgui.fxwidgets._rating_widget.FXRatingWidget"
click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
A clickable star rating widget.
This widget provides a configurable star rating with: - Configurable max stars - Half-star support (optional) - Hover preview - Theme-aware icons
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
int
|
Maximum number of stars. |
5
|
|
float
|
Initial rating value. |
0
|
|
bool
|
Whether to allow half-star ratings. |
False
|
|
int
|
Size of star icons in pixels. |
20
|
|
str
|
Icon name for filled stars. |
'star'
|
|
str
|
Icon name for empty stars. |
'star_border'
|
|
str
|
Icon name for half-filled stars. |
'star_half'
|
Signals
rating_changed: Emitted when the rating changes.
Examples:
>>> rating = FXRatingWidget(max_rating=5, initial_rating=3)
>>> rating.rating_changed.connect(lambda r: print(f"Rating: {r}"))
Methods:
| Name | Description |
|---|---|
clear_rating |
Clear the rating (set to 0). |
enterEvent |
Handle mouse enter. |
get_rating |
Return the current rating. |
leaveEvent |
Handle mouse leave to clear hover. |
mouseMoveEvent |
Handle mouse move for hover preview. |
mousePressEvent |
Handle mouse click to set rating. |
set_rating |
Set the rating value. |
Attributes:
| Name | Type | Description |
|---|---|---|
rating |
float
|
Return the current rating. |