Skip to content

Commit 321c28b

Browse files
authored
More control images for docs, create_gif helper method (#5717)
* Add BottomAppBar example and integration test Updated documentation to include a new example image and code snippet for BottomAppBar. Added an integration test and corresponding golden image for visual regression testing of the BottomAppBar control. * Add Canvas example and test for documentation Updated Canvas documentation to include a basic example image and code snippet. Added a corresponding integration test and golden image for screenshot validation. Adjusted image references in docs to use new example image and media paths. * Add example and test for CupertinoActionSheet Updated documentation to include a new example image and code snippet for CupertinoActionSheet. Added an integration test and corresponding golden image for documentation purposes. * Update CupertinoActivityIndicator docs and add test Updated documentation for CupertinoActivityIndicator to include a new example image and improved example references. Added a golden image and an integration test for the control to ensure visual consistency. Also enhanced the docstring with a usage example. * Add BottomSheet example and integration test Updated documentation for BottomSheet with a new example image and code snippet. Added an integration test and corresponding screenshot for the BottomSheet control to improve test coverage and documentation clarity. * Add alert dialog example tests and update docs Introduced integration tests and golden images for alert dialog examples, covering both modal and non-modal dialogs. Updated documentation to use new screenshots instead of GIFs, and improved the example code to use a main guard. Added an empty __init__.py for the alert_dialog example package. * Add GIF creation utility to FletTestApp Introduces a create_gif method to FletTestApp for generating animated GIFs from a sequence of PNG images. Integration test for alert dialog now uses this method to create a GIF of the dialog flow when golden images are enabled. * Update alert dialog test to set GIF duration Added the 'duration=500' parameter to the create_gif call in test_alert_dialog.py to control the frame duration. Updated the corresponding golden GIF to reflect this change. * Update alert dialog test GIF generation timing Adjusted the sequence and duration of frames in the alert dialog test GIF for improved clarity. Default GIF frame duration in FletTestApp was increased to 1000ms, and the test now uses a longer duration and an updated frame sequence. * Update alertdialog docs with GIF example Replaced three static images with a single GIF to better illustrate modal and non-modal dialog flows in the alertdialog documentation.
1 parent 2c4edee commit 321c28b

File tree

29 files changed

+366
-22
lines changed

29 files changed

+366
-22
lines changed

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

Whitespace-only changes.

sdk/python/examples/controls/alert_dialog/modal_and_non_modal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ def main(page: ft.Page):
3636
)
3737

3838

39-
ft.run(main)
39+
if __name__ == "__main__":
40+
ft.run(main)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
class_name: flet.AlertDialog
33
examples: ../../examples/controls/alert_dialog
44
example_images: ../test-images/examples/material/golden/macos/alert_dialog
5-
example_media: ../examples/controls/alert_dialog/media
65
---
76

87
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic AlertDialog") }}
@@ -17,7 +16,7 @@ example_media: ../examples/controls/alert_dialog/media
1716
--8<-- "{{ examples }}/modal_and_non_modal.py"
1817
```
1918

20-
{{ image(example_media + "/modal_and_non_modal.gif", alt="modal-and-non-modal", width="80%") }}
19+
{{ image(example_images + "/alert_dialog_flow.gif", alt="Modal and non-modal dialogs", caption="Modal and non-modal dialogs",width="50%") }}
2120

2221

2322
{{ class_members(class_name) }}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.BottomAppBar
33
examples: ../../examples/controls/bottom_app_bar
4-
example_images: ../examples/controls/bottom_app_bar/media
4+
example_images: ../test-images/examples/material/golden/macos/bottom_app_bar
5+
example_media: ../examples/controls/bottom_app_bar/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic BottomAppBar", image_width="100%") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/bottom_app_bar/media
1617
--8<-- "{{ examples }}/notched_fab.py"
1718
```
1819

19-
{{ image(example_images + "/notched_fab.png", alt="notched-fab", width="80%") }}
20+
{{ image(example_media + "/notched_fab.png", alt="notched-fab", width="80%") }}
2021

2122

2223
{{ class_members(class_name) }}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.BottomSheet
33
examples: ../../examples/controls/bottom_sheet
4-
example_images: ../examples/controls/bottom_sheet/media
4+
example_images: ../test-images/examples/material/golden/macos/bottom_sheet
5+
example_media: ../examples/controls/bottom_sheet/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic BottomSheet") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/bottom_sheet/media
1617
--8<-- "{{ examples }}/basic.py"
1718
```
1819

19-
{{ image(example_images + "/basic.gif", alt="basic", width="80%") }}
20+
{{ image(example_media + "/basic.gif", alt="basic", width="80%") }}
2021

2122

2223
{{ class_members(class_name) }}

sdk/python/packages/flet/docs/controls/canvas/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
class_name: flet.canvas.Canvas
33
examples: ../../examples/controls/canvas
4-
example_images: ../../examples/controls/canvas/media
4+
example_images: ../../test-images/examples/core/golden/macos/canvas
5+
example_media: ../../examples/controls/canvas/media
56
---
67

78
# Canvas
89

9-
{{ class_summary(class_name) }}
10+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic Canvas") }}
1011

1112
## Examples
1213

@@ -18,7 +19,7 @@ example_images: ../../examples/controls/canvas/media
1819
--8<-- "{{ examples }}/smiling_face.py"
1920
```
2021

21-
{{ image(example_images + "/smiling_face.png", alt="smiling-face", width="80%") }}
22+
{{ image(example_media + "/smiling_face.png", alt="smiling-face", width="80%") }}
2223

2324

2425
### Flet logo
@@ -27,7 +28,7 @@ example_images: ../../examples/controls/canvas/media
2728
--8<-- "{{ examples }}/flet_logo.py"
2829
```
2930

30-
{{ image(example_images + "/flet_logo.png", alt="flet-logo", width="80%") }}
31+
{{ image(example_media + "/flet_logo.png", alt="flet-logo", width="80%") }}
3132

3233

3334
### Triangles
@@ -36,7 +37,7 @@ example_images: ../../examples/controls/canvas/media
3637
--8<-- "{{ examples }}/triangles.py"
3738
```
3839

39-
{{ image(example_images + "/triangles.png", alt="triangles", width="80%") }}
40+
{{ image(example_media + "/triangles.png", alt="triangles", width="80%") }}
4041

4142

4243
### Bezier curves
@@ -45,7 +46,7 @@ example_images: ../../examples/controls/canvas/media
4546
--8<-- "{{ examples }}/bezier_curves.py"
4647
```
4748

48-
{{ image(example_images + "/bezier_curves.png", alt="bezier-curves", width="80%") }}
49+
{{ image(example_media + "/bezier_curves.png", alt="bezier-curves", width="80%") }}
4950

5051

5152
### Text
@@ -54,7 +55,7 @@ example_images: ../../examples/controls/canvas/media
5455
--8<-- "{{ examples }}/text.py"
5556
```
5657

57-
{{ image(example_images + "/text.png", alt="text", width="80%") }}
58+
{{ image(example_media + "/text.png", alt="text", width="80%") }}
5859

5960

6061
### Free-hand drawing with image capture

sdk/python/packages/flet/docs/controls/cupertinoactionsheet/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
class_name: flet.CupertinoActionSheet
33
examples: ../../examples/controls/cupertino_action_sheet
4-
example_images: ../../examples/controls/cupertino_action_sheet/media
4+
example_images: ../../test-images/examples/cupertino/golden/macos/cupertino_action_sheet
5+
example_media: ../../examples/controls/cupertino_action_sheet/media
56
---
67

78
# CupertinoActionSheet
89

9-
{{ class_summary(class_name) }}
10+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic CupertinoActionSheet") }}
1011

1112
## Examples
1213

@@ -18,7 +19,7 @@ example_images: ../../examples/controls/cupertino_action_sheet/media
1819
--8<-- "{{ examples }}/basic.py"
1920
```
2021

21-
{{ image(example_images + "/basic.png", alt="basic", width="80%") }}
22+
{{ image(example_media + "/basic.png", alt="basic", width="80%") }}
2223

2324

2425
{{ class_members(class_name) }}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.CupertinoActivityIndicator
33
examples: ../../examples/controls/cupertino_activity_indicator
4-
example_images: ../examples/controls/cupertino_activity_indicator/media
4+
example_images: ../test-images/examples/cupertino/golden/macos/cupertino_activity_indicator
5+
example_media: ../examples/controls/cupertino_activity_indicator/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic CupertinoActivityIndicator") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/cupertino_activity_indicator/media
1617
--8<-- "{{ examples }}/basic.py"
1718
```
1819

19-
{{ image(example_images + "/basic.png", alt="basic", width="80%") }}
20+
{{ image(example_media + "/basic.png", alt="basic", width="80%") }}
2021

2122

2223
{{ class_members(class_name) }}
4.4 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
3+
import flet as ft
4+
import flet.canvas as cv
5+
import flet.testing as ftt
6+
7+
8+
@pytest.mark.asyncio(loop_scope="function")
9+
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
10+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
11+
await flet_app_function.assert_control_screenshot(
12+
request.node.name,
13+
cv.Canvas(
14+
width=160,
15+
height=160,
16+
shapes=[
17+
cv.Rect(
18+
0,
19+
0,
20+
160,
21+
160,
22+
paint=ft.Paint(
23+
color=ft.Colors.BLUE_100,
24+
style=ft.PaintingStyle.FILL,
25+
),
26+
),
27+
cv.Circle(
28+
80,
29+
80,
30+
50,
31+
paint=ft.Paint(
32+
color=ft.Colors.BLUE_400,
33+
style=ft.PaintingStyle.FILL,
34+
),
35+
),
36+
],
37+
),
38+
)

0 commit comments

Comments
 (0)