Closed lasifea closed 1 week ago
Seems like this property must be of type of string.
Two ways to display a tooltip in the Segment
:
tooltip
property to a string
tooltip
property of its label
to a string
or Tooltip
objectExample:
import flet as ft
def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.add(
ft.SegmentedButton(
selected={"0"},
selected_icon=ft.Icon(ft.icons.CHECK),
segments=[
ft.Segment(
value="0",
icon=ft.Icon(ft.icons.LOOKS_ONE),
label=ft.Text("I am Text", size=16),
tooltip="tooltip from text",
),
ft.Segment(
value="2",
icon=ft.Icon(ft.icons.LOOKS_3),
label=ft.Text(
"I am Class",
size=16,
tooltip=ft.Tooltip(
message="tooltip from class",
padding=3,
border_radius=10,
gradient=ft.LinearGradient(
colors=[ft.colors.RED, ft.colors.BLUE]
),
),
),
),
],
)
)
ft.app(main)
Disadvantage with the second option is that, the tooltip will only be visible when hovering on the label. So, hovering on the icon won't show the tooltip.
OK, I'm watting for the next version of Flet. Thanks!
Duplicate Check
Describe the bug
I found that when I set the tooltip in the Segment component, the text displayed incorrectly, and the same issue also exists in other components, such as the BarChartRod component. In version 0.23.2, this issue will not occur. (From machine translation, please understand if the expression is inaccurate.)
Code sample
Code
```python import flet as ft def main(page: ft.Page): page.horizontal_alignment = ft.CrossAxisAlignment.CENTER page.vertical_alignment = ft.MainAxisAlignment.CENTER page.window.width = 500 page.window.height = 300 segments = [ft.Segment('0', icon=ft.Icon(ft.icons.LOOKS_ONE), label=ft.Text('Dog', size=16), tooltip='a dog'), ft.Segment('1', icon=ft.Icon(ft.icons.LOOKS_TWO), label=ft.Text('Cat', size=16), tooltip='一只猫'), ft.Segment('2', icon=ft.Icon(ft.icons.LOOKS_3), label=ft.Text('Bird', size=16), tooltip=ft.Tooltip('一只鸟', padding=20, border_radius=10))] segment_btn = ft.SegmentedButton(segments=segments, selected={'0'}, selected_icon=ft.Icon(ft.icons.CHECK)) page.add(segment_btn) if __name__ == '__main__': ft.app(main) ```To reproduce
After running, please notice the tooltip of the button.
Expected behavior
No response
Screenshots / Videos
Captures
[Upload media here] ![image](https://github.com/user-attachments/assets/c2e7440e-33eb-44db-9d0f-99a75d18a86f)Operating System
Windows
Operating system details
Windows 11
Flet version
0.24.1
Regression
No, it isn't
Suggestions
No response
Logs
Logs
```console [Paste your logs here] ```Additional details
There may still be some components that have the same issue, but I haven't encountered them yet.