Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/cupertino_timer_picker/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ def handle_timer_picker_change(e: ft.Event[ft.CupertinoTimerPicker]):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/menu_bar/nested_submenus.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ def handle_submenu_hover(e: ft.Event[ft.SubmenuButton]):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/menu_item_button/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ def handle_on_hover(e: ft.Event[ft.MenuItemButton]):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/navigation_bar/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def main(page: ft.Page):
page.add(ft.Text("Body!"))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
class_name: flet.CupertinoTimerPicker
examples: ../../examples/controls/cupertino_timer_picker
example_images: ../examples/controls/cupertino_timer_picker/media
example_media: ../examples/controls/cupertino_timer_picker/media
example_images: ../test-images/examples/cupertino/golden/macos/cupertino_timer_picker
---

{{ class_summary(class_name) }}
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Simple Cupertino timer picker") }}

## Examples

Expand All @@ -16,7 +17,7 @@ example_images: ../examples/controls/cupertino_timer_picker/media
--8<-- "{{ examples }}/basic.py"
```

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


{{ class_members(class_name) }}
7 changes: 4 additions & 3 deletions sdk/python/packages/flet/docs/controls/listview.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
class_name: flet.ListView
examples: ../../examples/controls/list_view
example_images: ../examples/controls/list_view/media
example_media: ../examples/controls/list_view/media
example_images: ../test-images/examples/core/golden/macos/list_view
---

{{ class_summary(class_name) }}
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic list view") }}

## Examples

Expand All @@ -16,7 +17,7 @@ example_images: ../examples/controls/list_view/media
--8<-- "{{ examples }}/autoscroll_and_dynamic_items.py"
```

{{ image(example_images + "/autoscroll_and_dynamic_items.gif", alt="autoscroll-and-dynamic-items", width="80%") }}
{{ image(example_media + "/autoscroll_and_dynamic_items.gif", alt="autoscroll-and-dynamic-items", width="80%") }}


{{ class_members(class_name) }}
4 changes: 2 additions & 2 deletions sdk/python/packages/flet/docs/controls/menubar.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
class_name: flet.MenuBar
examples: ../../examples/controls/menu_bar
example_images: ../examples/controls/menu_bar/media
example_images: ../test-images/examples/material/golden/macos/menu_bar
---

{{ class_summary(class_name) }}
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic menu bar") }}

## Examples

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/packages/flet/docs/controls/menuitembutton.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
class_name: flet.MenuItemButton
examples: ../../examples/controls/menu_item_button
example_images: ../examples/controls/menu_item_button/media
example_images: ../test-images/examples/material/golden/macos/menu_item_button
---

{{ class_summary(class_name) }}
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Menu item buttons outside of menubar") }}

## Examples

Expand Down
6 changes: 3 additions & 3 deletions sdk/python/packages/flet/docs/controls/navigationbar/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
class_name: flet.NavigationBar
examples: ../../examples/controls/navigation_bar
example_images: ../../examples/controls/navigation_bar/media
example_images: ../../test-images/examples/material/golden/macos/navigation_bar
---

# NavigationBar

{{ class_summary(class_name) }}
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Simple navigation bar") }}

## Examples

Expand All @@ -18,7 +18,7 @@ example_images: ../../examples/controls/navigation_bar/media
--8<-- "{{ examples }}/basic.py"
```

{{ image(example_images + "/basic.gif", alt="basic", width="80%") }}
{{ image(example_images + "/basic.png", alt="basic", width="80%") }}


{{ class_members(class_name) }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

import flet as ft
import flet.testing as ftt


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
flet_app_function.resize_page(100, 300)
flet_app_function.page.update()
await flet_app_function.assert_control_screenshot(
request.node.name,
ft.ListView(
controls=[ft.Text(f"Item {i}") for i in range(1, 6)],
divider_thickness=1,
),
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest

import flet as ft
import flet.testing as ftt

from examples.controls.cupertino_timer_picker import basic


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app_function.assert_control_screenshot(
request.node.name,
ft.CupertinoTimerPicker(value=1000),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": basic.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_basic(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.resize_page(400, 400)
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()

btn = await flet_app_function.tester.find_by_text("00:01:10")
await flet_app_function.tester.tap(btn)
await flet_app_function.tester.pump_and_settle()

flet_app_function.assert_screenshot(
"basic",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import pytest

import flet as ft
import flet.testing as ftt

from examples.controls.menu_bar import nested_submenus


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
flet_app_function.page.enable_screenshots = True
flet_app_function.resize_page(150, 200)
flet_app_function.page.update()
mb = ft.MenuBar(
controls=[
ft.SubmenuButton(
content=ft.Text("Submenu"),
controls=[
ft.MenuItemButton(content=ft.Text("Item 1")),
ft.MenuItemButton(content=ft.Text("Item 2")),
ft.MenuItemButton(content=ft.Text("Item 3")),
],
),
],
)
flet_app_function.page.add(mb)
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
btn = await flet_app_function.tester.find_by_text("Submenu")
await flet_app_function.tester.tap(btn)
await flet_app_function.tester.pump_and_settle()

flet_app_function.assert_screenshot(
"image_for_docs",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": nested_submenus.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_nested_submenus(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.resize_page(400, 400)
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle(
duration=ft.Duration(milliseconds=500)
)
flet_app_function.assert_screenshot(
"nested_submenus1",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
smb = await flet_app_function.tester.find_by_text("File")
await flet_app_function.tester.tap(smb)
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"nested_submenus2",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
mib = await flet_app_function.tester.find_by_text("Save")
await flet_app_function.tester.tap(mib)
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"nested_submenus3",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)

flet_app_function.create_gif(
["nested_submenus1", "nested_submenus2", "nested_submenus3"],
"nested_submenus",
duration=1600,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import pytest

import flet as ft
import flet.testing as ftt

from examples.controls.menu_item_button import basic


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app_function.assert_control_screenshot(
request.node.name,
ft.Row(
controls=[
ft.MenuItemButton(
content=ft.Text("Yes"),
on_click=lambda e: print("yes"),
autofocus=True,
),
ft.MenuItemButton(
content=ft.Text("No"),
on_click=lambda e: print("no"),
),
ft.MenuItemButton(
content=ft.Text("Maybe"),
on_click=lambda e: print("maybe"),
),
],
alignment=ft.MainAxisAlignment.CENTER,
height=50,
width=200,
expand=True,
),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": basic.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_basic(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.resize_page(400, 400)
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle(
duration=ft.Duration(milliseconds=500)
)
flet_app_function.assert_screenshot(
"basic1",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
btn = await flet_app_function.tester.find_by_text("BgColors")
await flet_app_function.tester.tap(btn)
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"basic2",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
mib = await flet_app_function.tester.find_by_text("Green")
await flet_app_function.tester.tap(mib)
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"basic3",
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)

flet_app_function.create_gif(
["basic1", "basic2", "basic3"],
"basic",
duration=1600,
)
Loading
Loading