Skip to content

Commit 64fc1b6

Browse files
committed
add DisposalMode enum and parameter to create_gif function
1 parent 7e703d2 commit 64fc1b6

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

sdk/python/packages/flet/integration_tests/examples/core/test_responsive_row.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
2323
},
2424
)
2525
for i in range(1, 6)
26-
],
27-
)
26+
],
27+
),
2828
)
2929

3030

@@ -44,7 +44,7 @@ async def test_basic(flet_app_function: ftt.FletTestApp):
4444
"responsive1",
4545
await flet_app_function.page.take_screenshot(
4646
pixel_ratio=flet_app_function.screenshots_pixel_ratio,
47-
delay=ft.Duration(seconds=1)
47+
delay=ft.Duration(seconds=1),
4848
),
4949
)
5050
flet_app_function.resize_page(800, 500)
@@ -55,8 +55,8 @@ async def test_basic(flet_app_function: ftt.FletTestApp):
5555
"responsive2",
5656
await flet_app_function.page.take_screenshot(
5757
pixel_ratio=flet_app_function.screenshots_pixel_ratio,
58-
delay=ft.Duration(seconds=1)
59-
)
58+
delay=ft.Duration(seconds=1),
59+
),
6060
)
6161
flet_app_function.resize_page(200, 500)
6262
flet_app_function.page.update()
@@ -66,13 +66,14 @@ async def test_basic(flet_app_function: ftt.FletTestApp):
6666
"responsive3",
6767
await flet_app_function.page.take_screenshot(
6868
pixel_ratio=flet_app_function.screenshots_pixel_ratio,
69-
delay=ft.Duration(seconds=1)
69+
delay=ft.Duration(seconds=1),
7070
),
7171
)
7272
flet_app_function.create_gif(
7373
["responsive1", "responsive2", "responsive3"],
7474
"responsive_row_basic",
7575
duration=1600,
76+
disposal=ftt.DisposalMode.BACKGROUND,
7677
)
7778

7879

@@ -118,4 +119,5 @@ async def test_custom_breakpoint(flet_app_function: ftt.FletTestApp):
118119
["responsive_custom_1", "responsive_custom_2", "responsive_custom_3"],
119120
"responsive_row_custom_breakpoint",
120121
duration=1600,
121-
)
122+
disposal=ftt.DisposalMode.BACKGROUND,
123+
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from flet.testing.finder import Finder
22
from flet.testing.flet_test_app import FletTestApp
3+
from flet.testing.flet_test_app import DisposalMode
34
from flet.testing.tester import Tester
45

5-
__all__ = ["Finder", "FletTestApp", "Tester"]
6+
__all__ = ["Finder", "FletTestApp", "DisposalMode", "Tester"]

sdk/python/packages/flet/src/flet/testing/flet_test_app.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from io import BytesIO
88
from pathlib import Path
99
from typing import Any, Optional
10+
from enum import Enum
1011

1112
import numpy as np
1213
from PIL import Image
@@ -21,6 +22,32 @@
2122
__all__ = ["FletTestApp"]
2223

2324

25+
class DisposalMode(Enum):
26+
"""
27+
Indicates the way in which a frame is treated after being displayed.
28+
"""
29+
30+
DEFAULT = 0
31+
"""
32+
No disposal method specified
33+
"""
34+
35+
NONE = 1
36+
"""
37+
Do not dispose
38+
"""
39+
40+
BACKGROUND = 2
41+
"""
42+
Restore to background color.
43+
"""
44+
45+
PREVIOUS = 3
46+
"""
47+
Restore to previous content.
48+
"""
49+
50+
2451
class FletTestApp:
2552
"""
2653
Flet app test controller coordinates running a Python-based
@@ -425,7 +452,7 @@ def create_gif(
425452
*,
426453
duration: int = 1000,
427454
loop: int = 0,
428-
disposal: int = 0
455+
disposal: DisposalMode = 0,
429456
) -> Path:
430457
"""Create an animated GIF from a sequence of image files.
431458
@@ -490,7 +517,7 @@ def create_gif(
490517
duration=duration,
491518
loop=loop,
492519
optimize=True,
493-
disposal=2
520+
disposal=disposal.value,
494521
)
495522
finally:
496523
for frame in frames:

0 commit comments

Comments
 (0)