Skip to content

[Question] Matematical operation on value in Slider controls #4033

Answered by LukasSliacky
LukasSliacky asked this question in Q&A
Discussion options

You must be logged in to vote

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()

t = ft.Text()
my_slider = ft.Slider(min=0, max=100, divisions=10, label="{value}%", 
on_change=slider_changed)

page.add(
    ft.Text("Slider with 'on_change' event:"),
    my_slider, t)
#print(my_slider.label)

ft.app(main)`

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LukasSliacky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
1 participant