[Question] Matematical operation on value in Slider controls #4033
-
QuestionI have specific problem and i don't understand how to solve it :/ Value label works fine, but in my project I need to apply mathematical operation (dividing) on this value. Value Please, how can I divide value and after that show is as label? Code sampleimport flet as ft
def main(page):
def slider_changed(e):
t.value = f"Slider changed to {e.control.value}"
page.update()
t = ft.Text()
page.add(
ft.Text("Slider with 'on_change' event:"),
ft.Slider(min=0, max=100, divisions=10, label="{value}%", on_change=slider_changed), t)
ft.app(main)
```ValueError: invalid literal for int() with base 10`
### Error message
ValueError: invalid literal for int() with base 10
### ------------------------------------------------------
- [X] I have searched for answers to my question both in the issues and in previous discussions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
On StackOverflow was question answered. `import flet as ft
ft.app(main)` |
Beta Was this translation helpful? Give feedback.
On StackOverflow was question answered.
`import flet as ft
def main(page):
def slider_changed(e):
#Store value to perform mathematical opreations on first
slider_value = e.control.value
# then divide slider value by an integer
result = slider_value / 10
#update both text and slider conntrol with result
t.value = f"Slider value divided by 10 = {result}"
my_slider.label = f"{result}%"
page.update()
ft.app(main)`