Skip to content

"RuntimeError: asyncio.run() cannot be called from a running event loop (first sample code) #5462

@DJuego

Description

@DJuego

Duplicate Check

Describe the bug

Python version: 3.13.5.
Environment: Spyder 6.0.7

I recently discovered this library and have installed it in a virtual environment. However when I run the example code I get "RuntimeError: asyncio.run() cannot be called from a running event loop" I must warn that I am working in Spyder Environment (winpython)

DJuego

Code sample

Code
import flet as ft

def main(page: ft.Page):
    page.title = "Flet counter example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(e):
        txt_number.value = str(int(txt_number.value) - 1)
        page.update()

    def plus_click(e):
        txt_number.value = str(int(txt_number.value) + 1)
        page.update()

    page.add(
        ft.Row(
            [
                ft.IconButton(ft.Icons.REMOVE, on_click=minus_click),
                txt_number,
                ft.IconButton(ft.Icons.ADD, on_click=plus_click),
            ],
            alignment=ft.alignment.center,
        )
    )

ft.app(main)

To reproduce

+Python version: 3.13.5.
+Environment: Spyder 6.0.7
+pip install flet

Run the sample code

Expected behavior

Display the example interface of flet.

Screenshots / Videos

Image

Operating System

Windows 10 x64

Operating system details

Flet version

Version: 0.28.3

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions