flet icon indicating copy to clipboard operation
flet copied to clipboard

question: example code doesn't work

Open zangxx66 opened this issue 9 months ago • 15 comments

python:3.12.12 OS:macOS 15.7.3

I run the following example code in the virtual environment, but the controls failed to load properly. Is it because Flet does not support the virtual environment?

import flet as ft


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

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

    def minus_click(e):
        input.value = str(int(input.value) - 1)

    def plus_click(e):
        input.value = str(int(input.value) + 1)

    page.add(
        ft.Row(
            alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.IconButton(ft.Icons.REMOVE, on_click=minus_click),
                input,
                ft.IconButton(ft.Icons.ADD, on_click=plus_click),
            ],
        )
    )


ft.run(main)
Image

zangxx66 avatar Feb 13 '26 00:02 zangxx66

Hey, so i have been having this issue too, for me 0.80.3 and above just do not load the controls. As shown in your screenshot.

hapatapa avatar Feb 13 '26 18:02 hapatapa

it's work with me

Image

I use flet==0.80.5 And Python3.14.2

mostafa-kessassi avatar Feb 14 '26 01:02 mostafa-kessassi

PlotlyChart Examples do not work, either. Windows 11 Python 3.14 Flet 0.80.5

gsal avatar Feb 14 '26 03:02 gsal

@gsal Try this it's work

import plotly.express as px
from flet import Image,Page,run
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
result = fig.to_image()
def main(page:Page):
    page.add(
        Image(
            src=result
        )
    )
    page.update()
run(main)

mostafa-kessassi avatar Feb 14 '26 20:02 mostafa-kessassi

@mostafa-kessassi : the line result = fig.to_image() never returns.

gsal avatar Feb 15 '26 04:02 gsal

It works on my end (v0.80.5 - macOS 15):

Image

Wll suggest you create a new venv and retry, as the issue you have seems specific to you.

ndonkoHenri avatar Feb 15 '26 16:02 ndonkoHenri

@gsal for me it's work try install last version of all

pip install kaleido==1.2.0 plotly==6.5.2

mostafa-kessassi avatar Feb 15 '26 20:02 mostafa-kessassi

@mostafa-kessassi : right, that's what I have....I just installed in the last couple of days, as I wanted to include my first graph in my first Flet app.

By the way, an example from the matplotlib works just fine.

In any case, here is part of my pyproject.toml, and the specs of my computer GPUs ....maybe the issue is GPU related?

dependencies = [
    "flet-charts>=0.80.5",
    "flet-datatable2>=0.80.5",
    "kaleido>=1.2.0",
    "lazy-loader>=0.4",
    "matplotlib>=3.10.8",
    "numpy>=2.4.2",
    "pandas>=3.0.0",
    "plotly>=6.5.2",
    "pyyaml>=6.0.3",
    "scipy>=1.17.0",
]

[dependency-groups]
dev = [
    "flet-charts>=0.80.5",
    "flet[all]>=0.80.5",
]

GPU 0

	Intel(R) UHD Graphics

	Driver version:	32.0.101.7077
	Driver date:	9/16/2025
	DirectX version:	12 (FL 12.1)
	Physical location:	PCI bus 0, device 2, function 0

	Utilization	0%
	Dedicated GPU memory	1.0/8.0 GB
	Shared GPU memory	0.4/63.8 GB
	GPU Memory	0.4/63.8 GB

GPU 1

	NVIDIA RTX 2000 Ada Generation Laptop GPU

	Driver version:	32.0.15.7371
	Driver date:	8/21/2025
	DirectX version:	12 (FL 12.1)
	Physical location:	PCI bus 1, device 0, function 0

	Utilization	4%
	Dedicated GPU memory	1.0/8.0 GB
	Shared GPU memory	0.2/63.8 GB
	GPU Memory	1.2/71.8 GB

gsal avatar Feb 15 '26 22:02 gsal

It works on my end (v0.80.5 - macOS 15):

Image Wll suggest you create a new venv and retry, as the issue you have seems specific to you.

I create new venv but issue remains unresolved(v0.80.5 - macOS 15 - python 3.12)

Image

zangxx66 avatar Feb 15 '26 23:02 zangxx66

Sorry, I guess it is my fault that we are talking about two different things, intertwined.

@zangxx66 : Hey, what's up with the 'sudo' thing? Will you start over without sudo? ...it is only a few lines:

mkdir singer
cd singer
uv init
uv add "flet[all]>=0.80.5"
cp ../main.py .
uv run main.py 

gsal avatar Feb 15 '26 23:02 gsal

Sorry, I guess it is my fault that we are talking about two different things, intertwined.

@zangxx66 : Hey, what's up with the 'sudo' thing? Will you start over without sudo? ...it is only a few lines:

mkdir singer
cd singer
uv init
uv add "flet[all]>=0.80.5"
cp ../main.py .
uv run main.py 

I can run the program normally by using view=ft.AppView.FLET_APP_WEB or view=ft.AppView.WEB_BROWSER, but others will show "working". Maybe I have some uninstalled dependencies.

zangxx66 avatar Feb 16 '26 00:02 zangxx66

First, a rhetorical question: what version of Python are you using?

Now, the question I actually mean to ask: Do you have a like a normal, pre-installed version of Python that uv is finding and using.....or....is uv installing its own Python?

It may be a pain, but I would try a "proper" Python installation (over uv's ), I believe it may include libraries that have been stripped from what uv gets.

gsal avatar Feb 16 '26 18:02 gsal

@gsal bro your pc are so great then what i have i think you build the app and after that you test it or you test it in vs code normaly

mostafa-kessassi avatar Feb 16 '26 19:02 mostafa-kessassi

@zangxx66 it a file messing or somthing wrong in system files flet in 0.80.5 are great and work can you try delete python and install the new version and change the dir* of you project file to make it in smole path like paste in in desktop folder

mostafa-kessassi avatar Feb 16 '26 19:02 mostafa-kessassi

@zangxx66 if you still face an issue concerning this, you can ping me on Flet discord server, and we could join a voice-channel to try understanding this better.

Will close this ticket for now, if you don't mind.

ndonkoHenri avatar Feb 19 '26 18:02 ndonkoHenri