File tree Expand file tree Collapse file tree
integration_tests/examples/material
src/flet/controls/material Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
22class_name : flet.Banner
33examples : ../../examples/controls/banner
4- example_images : ../examples/controls/banner/media
4+ example_images : ../test-images/examples/material/golden/macos/banner
5+ example_media : ../examples/controls/banner/media
56---
67
7- {{ class_summary(class_name) }}
8+ {{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic Banner" ) }}
89
910## Examples
1011
@@ -16,7 +17,7 @@ example_images: ../examples/controls/banner/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) }}
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ import flet as ft
4+ import flet .testing as ftt
5+
6+
7+ @pytest .mark .asyncio (loop_scope = "function" )
8+ async def test_image_for_docs (flet_app_function : ftt .FletTestApp , request ):
9+ page = flet_app_function .page
10+ page .theme_mode = ft .ThemeMode .LIGHT
11+ page .enable_screenshots = True
12+ page .window .width = 400
13+ page .window .height = 200
14+ banner = ft .Banner (
15+ leading = ft .Icon (ft .Icons .INFO_OUTLINED , color = ft .Colors .PRIMARY ),
16+ content = ft .Text ("Backup completed successfully." ),
17+ actions = [ft .TextButton ("Dismiss" )],
18+ bgcolor = ft .Colors .SURFACE_CONTAINER_LOW ,
19+ open = True ,
20+ )
21+ page .add (banner )
22+ page .update ()
23+ await flet_app_function .tester .pump_and_settle ()
24+ flet_app_function .assert_screenshot (
25+ "test_image_for_docs" ,
26+ await flet_app_function .page .take_screenshot (
27+ pixel_ratio = flet_app_function .screenshots_pixel_ratio
28+ ),
29+ )
30+ page .update ()
Original file line number Diff line number Diff line change @@ -26,6 +26,17 @@ class Banner(DialogControl):
2626 Banners are displayed at the top of the screen, below a top app bar. They are
2727 persistent and non-modal, allowing the user to either ignore them or interact with
2828 them at any time.
29+
30+ ```python
31+ banner = ft.Banner(
32+ leading=ft.Icon(ft.Icons.INFO_OUTLINED, color=ft.Colors.PRIMARY),
33+ content=ft.Text("Backup completed successfully."),
34+ actions=[ft.TextButton("Dismiss")],
35+ bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
36+ open=True,
37+ )
38+ page.show_dialog(banner)
39+ ```
2940 """
3041
3142 content : StrOrControl
You can’t perform that action at this time.
0 commit comments