How to Running Text from right to left and back left to right repeat #1548
Replies: 2 comments
-
Hi there, from flet import Page, Text, Container, margin, transform, animation, Column, app
import time
def main(page: Page):
page.window_width = 500
page.window_height = 300
page.padding = 20
page.window_center()
duration_in_sec = 1
mytext_1 = Text(value="Smooth movement",
size=15,
weight="bold",
offset=transform.Offset(0, 0),
animate_offset=animation.Animation(duration_in_sec*1000))
mytext_2 = Text(value="Movement with Pauses",
size=15,
weight="bold",
offset=transform.Offset(0, 0),
animate_offset=animation.Animation(duration_in_sec*1000))
def animate_text_1(when_to_stop):
offset = 0
while offset<= when_to_stop:
mytext_1.offset = transform.Offset(offset, 0)
time.sleep(duration_in_sec)
offset += 1
mytext_1.update()
def animate_text_2(when_to_stop):
offset = 0
while offset<= when_to_stop:
mytext_2.offset = transform.Offset(offset, 0)
time.sleep(duration_in_sec*1.5)
offset += 1
mytext_2.update()
page.add(Container(
margin=margin.only(top=page.window_height/2),
content=Column([mytext_1, mytext_2]),
)
)
animate_text_1(when_to_stop=2)
animate_text_2(when_to_stop=2)
app(target=main) |
Beta Was this translation helpful? Give feedback.
-
how to to text not back again from left to right . my code
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
i stuck how to create running text in flet . can you give me example code
Code sample
Error message
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions