Skip to content

Commit e7bcf05

Browse files
committed
fix Disposal default parameter, add reorderable list view example tests and images
1 parent 64fc1b6 commit e7bcf05

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

sdk/python/examples/controls/reorderable_list_view/__init__.py

Whitespace-only changes.

sdk/python/examples/controls/reorderable_list_view/horizontal_and_vertical.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ def get_color(i):
4646
)
4747

4848

49-
ft.run(main)
49+
if __name__ == "__main__":
50+
ft.run(main)

sdk/python/packages/flet/docs/controls/reorderablelistview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
class_name: flet.ReorderableListView
33
examples: ../../examples/controls/reorderable_list_view
4-
example_images: ../examples/controls/reorderable_list_view/media
4+
example_images: ../test-images/examples/material/golden/macos/reorderable_list_view
55
---
66

7-
{{ class_summary(class_name) }}
7+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Reorderable list view") }}
88

99
## Examples
1010

@@ -16,7 +16,7 @@ example_images: ../examples/controls/reorderable_list_view/media
1616
--8<-- "{{ examples }}/horizontal_and_vertical.py"
1717
```
1818

19-
{{ image(example_images + "/horizontal_and_vertical.gif", alt="horizontal-and-vertical", width="80%") }}
19+
{{ image(example_images + "/horizontal_and_vertical.png", alt="horizontal-and-vertical", width="80%") }}
2020

2121

2222
### Custom drag handle
30.3 KB
Loading
14.5 KB
Loading
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pytest
2+
3+
import flet as ft
4+
import flet.testing as ftt
5+
6+
from examples.controls.reorderable_list_view import horizontal_and_vertical
7+
8+
9+
@pytest.mark.asyncio(loop_scope="function")
10+
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
11+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
12+
await flet_app_function.assert_control_screenshot(
13+
request.node.name,
14+
ft.ReorderableListView(
15+
controls=[
16+
ft.ListTile(
17+
title=ft.Text(f"Item {i}"),
18+
bgcolor=ft.Colors.BLUE_GREY_300,
19+
)
20+
for i in range(1, 6)
21+
],
22+
),
23+
)
24+
25+
26+
@pytest.mark.parametrize(
27+
"flet_app_function",
28+
[{"flet_app_main": horizontal_and_vertical.main}],
29+
indirect=True,
30+
)
31+
@pytest.mark.asyncio(loop_scope="function")
32+
async def test_horizontal_and_vertical(flet_app_function: ftt.FletTestApp):
33+
flet_app_function.page.enable_screenshots = True
34+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
35+
flet_app_function.page.update()
36+
await flet_app_function.tester.pump_and_settle()
37+
flet_app_function.assert_screenshot(
38+
"horizontal_and_vertical",
39+
await flet_app_function.page.take_screenshot(
40+
pixel_ratio=flet_app_function.screenshots_pixel_ratio
41+
),
42+
)

sdk/python/packages/flet/src/flet/controls/material/reorderable_list_view.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ class ReorderableListView(ListView):
4040
automatically created drag handle (see [`show_default_drag_handles`][(c).]).
4141
To customize the draggable area, use the [`ReorderableDragHandle`][flet.] to
4242
define your own drag handle or region.
43+
44+
```python
45+
ft.ReorderableListView(
46+
controls=[
47+
ft.ListTile(
48+
title=ft.Text(f"Item {i}"),
49+
bgcolor=ft.Colors.BLUE_GREY_300,
50+
)
51+
for i in range(1, 6)
52+
],
53+
)
54+
```
55+
4356
"""
4457

4558
controls: list[Control] = field(default_factory=list)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def create_gif(
452452
*,
453453
duration: int = 1000,
454454
loop: int = 0,
455-
disposal: DisposalMode = 0,
455+
disposal: DisposalMode = DisposalMode.DEFAULT,
456456
) -> Path:
457457
"""Create an animated GIF from a sequence of image files.
458458

0 commit comments

Comments
 (0)