Skip to content

How to use Multiple AnimatedSwitch using a list #3751

Closed Answered by Michel7GitHub
Michel7GitHub asked this question in Q&A
Discussion options

You must be logged in to vote

I finaly find a way to do it, using Controls DATA property. Here is my new code :

import flet as ft

def main(page: ft.Page):

	ls = dict()					# LIST of Animated Switch
	
	for i in range(5):
		
		name = ('A', 'B', 'C', 'D', 'E', 'F')[i]
	
		ls[name] = dict()

		def animate(e):
			ls[name]['c'].content = ls[name]['c2'] if ls[name]['c'].content == ls[name]['c1'] else ls[name]['c1']
			ls[name]['c'].update()
 
		ls[name]['c1'] = ft.Container(
			ft.Text(f"{name} / 1", style=ft.TextThemeStyle.HEADLINE_MEDIUM),
			alignment=ft.alignment.center,
			width=100+i, height=100+i, bgcolor=ft.colors.GREEN, on_click=animate,
			data=name
		)
		ls[name]['c2'] = ft.Container(
   	    		ft.Text(f"{name} …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ndonkoHenri
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