This repository contains Flet sample applications you can use to learn Flet or as a starting point for your own great apps.
flet-dev / examples Goto Github PK
View Code? Open in Web Editor NEWFlet sample applications
License: MIT License
Flet sample applications
License: MIT License
Could anyone guide me to a tutorial on how I can change the default loading image and icon.
I checked this tutorial, but it doesn't seem to be working, or maybe I'm not using it right.
EDIT: Ok, playing around with a little more, changing the port did the trick. Seems like there is some kind of cache? I've disabled cache for the localhost in developer tools. Any idea how to get around this?
Part 1 scope:
Out of scope:
I was working with this file and i tried to run it in my system, when ever the website load, the dialog box doesn't appears.
but it works after the second execution.
Let me make it simple for you to understand
let me start with:
i run the code and it opens in the browser but the dialog box doesn't appears, now i don't close the tab where it is opened and now i stop the code and run it again, this time too it opens in another tab, this time too dialog box doesn't appears on the second tab but it opens in the previously opened tab.
the tab on first image was opened during second execution where page.dialog doesn't opens
the tab on the second image was opened during first execution where initially page.dialog didn't open but after second execution (without closing the tab ) page.dialog opened.
it seems that Control Gallery sample app is down. Also Trolli does not start properly showing the following error message "There was an error processing your request: ''NoneType" object has no property width"
How to create splash screen when windows desktop software starts?
For example, it would be nice if ft.ElevatedButton(text="press A") could bind the 'A' key shortcut. thanks a lot.
Hello, I found out that Chip
cannot use different label colors for selected and unselected states. Instead, the check mark color can be changed.
Here is an example:
# ...
[
ft.Chip(
label=ft.Text("Chip"),
selected_color=ft.colors.PRIMARY,
check_color=ft.colors.ON_PRIMARY,
on_select=lambda _: page.update(),
)
]
# ...
It would be nice if there were a way to set also the label to colors.PRIMARY
when selected.
I think an option could be a selected_label_color
-ish argument. Alternatively, the check_color
could be used on label when selected.
In 0.7.4, the app run fine. However, after upgrading to flet 0.8.0, it failed to run
Step to re-produce (Windows 11, official cpython 3.11.4, 64bit)
Here is the full log (including 0.7.4 and 0.8.0)
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
^Z
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>pip freeze | grep flet
flet==0.7.4
flet-core==0.7.4
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>git show head | head -3
commit 0b0c25b
Author: Feodor Fitsner [email protected]
Date: Wed Jul 5 18:50:27 2023 -0700
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>python main.py
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>pip install --upgrade flet
Requirement already satisfied: flet in d:\prg\venv\flet1\lib\site-packages (0.7.4)
Collecting flet
Using cached flet-0.8.0-py3-none-win_amd64.whl (22.7 MB)
Collecting copier<9.0.0,>=8.0.0 (from flet)
Using cached copier-8.0.0-py3-none-any.whl (38 kB)
Collecting flet-runtime==0.8.0 (from flet)
Using cached flet_runtime-0.8.0-py3-none-any.whl (20 kB)
Requirement already satisfied: packaging<24.0,>=23.1 in d:\prg\venv\flet1\lib\site-packages (from flet) (23.1)
Collecting pydantic<2 (from flet)
Using cached pydantic-1.10.11-cp311-cp311-win_amd64.whl (2.1 MB)
Collecting qrcode<8.0.0,>=7.4.2 (from flet)
Using cached qrcode-7.4.2-py3-none-any.whl (46 kB)
Collecting watchdog<4.0.0,>=3.0.0 (from flet)
Using cached watchdog-3.0.0-py3-none-win_amd64.whl (82 kB)
Requirement already satisfied: websocket-client<2.0.0,>=1.5.2 in d:\prg\venv\flet1\lib\site-packages (from flet) (1.6.1)
Collecting websockets<12.0.0,>=11.0.3 (from flet)
Using cached websockets-11.0.3-cp311-cp311-win_amd64.whl (124 kB)
Collecting flet-core==0.8.0 (from flet-runtime==0.8.0->flet)
Using cached flet_core-0.8.0-py3-none-any.whl (246 kB)
Collecting httpx<0.25.0,>=0.24.1 (from flet-runtime==0.8.0->flet)
Using cached httpx-0.24.1-py3-none-any.whl (75 kB)
Requirement already satisfied: oauthlib<4.0.0,>=3.2.2 in d:\prg\venv\flet1\lib\site-packages (from flet-runtime==0.8.0->flet) (3.2.2)
Requirement already satisfied: repath<0.10.0,>=0.9.0 in d:\prg\venv\flet1\lib\site-packages (from flet-core==0.8.0->flet-runtime==0.8.0->flet) (0.9.0)
Collecting colorama>=0.4.3 (from copier<9.0.0,>=8.0.0->flet)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting decorator>=5.1.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting dunamai>=1.7.0 (from copier<9.0.0,>=8.0.0->flet)
Using cached dunamai-1.17.0-py3-none-any.whl (24 kB)
Collecting funcy>=1.17 (from copier<9.0.0,>=8.0.0->flet)
Using cached funcy-2.0-py2.py3-none-any.whl (30 kB)
Collecting jinja2>=3.1.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting jinja2-ansible-filters>=1.3.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached jinja2_ansible_filters-1.3.2-py3-none-any.whl (18 kB)
Collecting pathspec>=0.9.0 (from copier<9.0.0,>=8.0.0->flet)
Using cached pathspec-0.11.1-py3-none-any.whl (29 kB)
Collecting plumbum>=1.6.9 (from copier<9.0.0,>=8.0.0->flet)
Using cached plumbum-1.8.2-py3-none-any.whl (127 kB)
Collecting pygments>=2.7.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached Pygments-2.15.1-py3-none-any.whl (1.1 MB)
Collecting pyyaml>=5.3.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached PyYAML-6.0-cp311-cp311-win_amd64.whl (143 kB)
Collecting pyyaml-include>=1.2 (from copier<9.0.0,>=8.0.0->flet)
Using cached pyyaml_include-1.3.1-py3-none-any.whl (20 kB)
Collecting questionary>=1.8.1 (from copier<9.0.0,>=8.0.0->flet)
Using cached questionary-1.10.0-py3-none-any.whl (31 kB)
Collecting typing-extensions>=4.2.0 (from pydantic<2->flet)
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting pypng (from qrcode<8.0.0,>=7.4.2->flet)
Using cached pypng-0.20220715.0-py3-none-any.whl (58 kB)
Requirement already satisfied: certifi in d:\prg\venv\flet1\lib\site-packages (from httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (2023.5.7)
Requirement already satisfied: httpcore<0.18.0,>=0.15.0 in d:\prg\venv\flet1\lib\site-packages (from httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (0.16.3)
Requirement already satisfied: idna in d:\prg\venv\flet1\lib\site-packages (from httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (3.4)
Requirement already satisfied: sniffio in d:\prg\venv\flet1\lib\site-packages (from httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (1.3.0)
Collecting MarkupSafe>=2.0 (from jinja2>=3.1.1->copier<9.0.0,>=8.0.0->flet)
Using cached MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl (17 kB)
Collecting pywin32 (from plumbum>=1.6.9->copier<9.0.0,>=8.0.0->flet)
Using cached pywin32-306-cp311-cp311-win_amd64.whl (9.2 MB)
Collecting prompt_toolkit<4.0,>=2.0 (from questionary>=1.8.1->copier<9.0.0,>=8.0.0->flet)
Using cached prompt_toolkit-3.0.39-py3-none-any.whl (385 kB)
Requirement already satisfied: h11<0.15,>=0.13 in d:\prg\venv\flet1\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (0.14.0)
Requirement already satisfied: anyio<5.0,>=3.0 in d:\prg\venv\flet1\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx<0.25.0,>=0.24.1->flet-runtime==0.8.0->flet) (3.7.1)
Collecting wcwidth (from prompt_toolkit<4.0,>=2.0->questionary>=1.8.1->copier<9.0.0,>=8.0.0->flet)
Using cached wcwidth-0.2.6-py2.py3-none-any.whl (29 kB)
Requirement already satisfied: six>=1.9.0 in d:\prg\venv\flet1\lib\site-packages (from repath<0.10.0,>=0.9.0->flet-core==0.8.0->flet-runtime==0.8.0->flet) (1.16.0)
Installing collected packages: wcwidth, pywin32, pypng, funcy, websockets, watchdog, typing-extensions, pyyaml, pygments, prompt_toolkit, plumbum, pathspec, MarkupSafe, dunamai, decorator, colorama, questionary, qrcode, pyyaml-include, pydantic, jinja2, flet-core, jinja2-ansible-filters, httpx, flet-runtime, copier, flet
Attempting uninstall: websockets
Found existing installation: websockets 10.4
Uninstalling websockets-10.4:
Successfully uninstalled websockets-10.4
Attempting uninstall: watchdog
Found existing installation: watchdog 2.3.1
Uninstalling watchdog-2.3.1:
Successfully uninstalled watchdog-2.3.1
Attempting uninstall: flet-core
Found existing installation: flet-core 0.7.4
Uninstalling flet-core-0.7.4:
Successfully uninstalled flet-core-0.7.4
Attempting uninstall: httpx
Found existing installation: httpx 0.23.3
Uninstalling httpx-0.23.3:
Successfully uninstalled httpx-0.23.3
Attempting uninstall: flet
Found existing installation: flet 0.7.4
Uninstalling flet-0.7.4:
Successfully uninstalled flet-0.7.4
Successfully installed MarkupSafe-2.1.3 colorama-0.4.6 copier-8.0.0 decorator-5.1.1 dunamai-1.17.0 flet-0.8.0 flet-core-0.8.0 flet-runtime-0.8.0 funcy-2.0 httpx-0.24.1 jinja2-3.1.2 jinja2-ansible-filters-1.3.2 pathspec-0.11.1 plumbum-1.8.2 prompt_toolkit-3.0.39 pydantic-1.10.11 pygments-2.15.1 pypng-0.20220715.0 pywin32-306 pyyaml-6.0 pyyaml-include-1.3.1 qrcode-7.4.2 questionary-1.10.0 typing-extensions-4.7.1 watchdog-3.0.0 wcwidth-0.2.6 websockets-11.0.3
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>pip freeze | grep flet
flet==0.8.0
flet-core==0.8.0
flet-runtime==0.8.0
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>python main.py
Unhandled error processing page session : Traceback (most recent call last):
File "d:\prg\venv\flet1\Lib\site-packages\flet_runtime\app.py", line 357, in on_session_created
session_handler(page)
File "P:\prj\python\flet\examples\python\apps\trolli\src\main.py", line 207, in main
app.initialize()
File "P:\prj\python\flet\examples\python\apps\trolli\src\main.py", line 86, in initialize
self.create_new_board("My First Board")
File "P:\prj\python\flet\examples\python\apps\trolli\src\main.py", line 187, in create_new_board
new_board = Board(self, self.store, board_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "P:\prj\python\flet\examples\python\apps\trolli\src\board.py", line 49, in init
width=(self.app.page.width - 310),
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'width'
Exception in thread Thread-5 (__sync_handler):
Traceback (most recent call last):
File "D:\prg\python\3.11_64\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "D:\prg\python\3.11_64\Lib\threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "d:\prg\venv\flet1\Lib\site-packages\flet_core\event_handler.py", line 30, in __sync_handler
h(e)
File "P:\prj\python\flet\examples\python\apps\trolli\src\app_layout.py", line 130, in page_resize
self.page.update()
^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'update'
(flet1) P:\prj\python\flet\examples\python\apps\trolli\src>
Exception in thread Thread-102 (__sync_handler):
Traceback (most recent call last):
File "...\flet-env\Lib\site-packages\flet_core\event_handler.py", line 28, in __sync_handler
h(r)
File "...\solitaire\solitaire-final-part1\card.py", line 126, in drop
self.update()
File "...\flet-env\Lib\site-packages\flet_core\control.py", line 260, in update
assert self.__page, "Control must be added to the page first."
AssertionError: Control must be added to the page first.
NOTE: flet-env is my virtual-environment where I tested.
I tried running calc.py both desktop and browser and neither instance seems to respond to clicks or keys. The other examples (counter.py
and todo.py
) work. Not sure how to debug or diagnose further.
i try you sample floating action button menu
but error no found package vector
Traceback (most recent call last):
File "C:\Users\LENOVO\Pictures\fletapp\flet2\main.py", line 4, in
from fab import AnimatedMenuButton, MenuItem
File "C:\Users\LENOVO\Pictures\fletapp\flet2\fab.py", line 9, in
from flet import (
ImportError: cannot import name 'Vector' from 'flet' (C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\flet_init_.py)
Returning 503 error on Windows/Chrome and Android
On desktop app, I use gettext.translation to implement i18n.
When switching languages, how can I refresh the text on the flet UI immediately without closing and resetting the app?
The values of e.data in Button_clicked do not arrive !!!
I am attempting to the scale of some buttons when I do the buttons scale from the center "anchor point"
Is it possible to have buttons scale from a different "anchor point" i.e have the left side of the button stay put as the left and top side scale up
codes doesn't not work. always get a "None" value.
environment:win11 desktop and pycharm
def pick_files_result(e: FilePickerResultEvent):
selected_files.value = (
", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!"
)
selected_files.update()
selected_path.value = e.path
selected_path.update()
pick_files_dialog = FilePicker(on_result=pick_files_result)
selected_files = Text()
selected_path = flet.Text()
Hi, can you help me in this example:
when i add a row with button [Add] the method 'appLine' adds a line correctly
while the external process consumer using the same 'Appline' method fails
thanks a lot
# flet
import flet
from flet import (
Container, Page, Row, Column, animation, transform,
VerticalDivider, Text, colors,
ListView, FilledButton, UserControl
)
# multiprocess
from multiprocessing import Process
from multiprocessing import Queue
# from multiprocessing import Value
from queue import Empty
from time import sleep
from random import random
#---------------------------------------------------------
# myClass
#---------------------------------------------------------
class MyApp(UserControl):
#-------------------------------------------------------
# override the constructor
def __init__(self, que):
# execute the base constructor
UserControl.__init__(self)
#-----------------------------------------------------
# ListView
self.lVie=ListView(
expand=1,
auto_scroll=True,
)
self.lCou = 1
self.fCol = "#00bb00"
self.bCol = '#000000'
self.que = que
self.prd = None
#-------------------------------------------------------
def appLine(self, item):
if item:
self.lVie.controls.append(
Text(
# f"Line {self.lCou}",
f">{item}",
color=self.fCol,
bgcolor=self.bCol,
)
)
self.lCou += 1
try:
self.update()
except:
...
#-------------------------------------------------------
def build(self):
#-----------------------------------------------------
# Button
self.btn1 = FilledButton(
text=" Add ",
# expand=1,
on_click=self.clicked_btn,
data="btn1",
)
self.btn2 = FilledButton(
text=" Rem ",
# expand=1,
on_click=self.clicked_btn,
data="btn2",
)
#-----------------------------------------------------
# Container
return Container(
Row(
[
# Left
Container(
bgcolor=colors.SURFACE_VARIANT,
width=150,
height=700,
border_radius=10,
),
VerticalDivider(),
# Middle
Container(
bgcolor=self.bCol,
width=150,
height=700,
# border_radius=10,
expand=1,
content=Row(
controls=[
self.lVie,
],
),
),
VerticalDivider(),
# Right
Container(
bgcolor=colors.SURFACE_VARIANT,
width=150,
height=700,
# expand=True,
border_radius=10,
padding=20,
content=Column(
controls=[
Column(
controls=[
self.btn1,
self.btn2,
],
),
],
),
),
],
spacing=0,
expand=True,
),
)
#-------------------------------------------------------
# Button
def clicked_btn(self, e):
# print("data:", e.control.data)
if e.control.data == 'btn1':
# print("Btn1")
self.appLine(f"Line {self.lCou}")
# start generate work
self.prd = prodStart(self)
self.prd.start()
elif e.control.data == 'btn2':
# print("Btn2")
if self.lVie.controls.__len__():
# self.lVie.controls.pop()
self.lVie.controls.__delitem__(0)
# self.lCou -= 1
self.update()
#---------------------------------------------------------
# Application
#---------------------------------------------------------
def main(page: Page):
page.title = "myApp"
page.add(app)
#---------------------------------------------------------
# generate work
def producerT(self):
print('Producer: Running', flush=True)
# generate work
for i in range(3):
# generate a value
value = random()
# block
sleep(value)
# add to the queue
self.que.put(value)
print('Producer: Done', flush=True)
#---------------------------------------------------------
# instance work
def prodStart(self):
# start the producer
prod = Process(target=producerT, args=(self,))
return prod
#-------------------------------------------------------
# consume work
def consumer(self):
print('Consumer: Running', flush=True)
# consume work
while True:
# get a unit of work
try:
item = self.que.get(timeout=0.5)
except Empty:
# print('Consumer: waiting...', flush=True)
continue
# check for stop
if item is None:
# self.prd.terminate()
print('Producer: Terminated', flush=True)
break
if item:
# report
print(f'<< {item}', flush=True)
self.appLine(f'<< {item}')
# all done
print('Consumer: Terminated', flush=True)
#---------------------------------------------------------
# Main
#---------------------------------------------------------
# entry point
if __name__ == '__main__':
# create the shared queue
queue = Queue()
app = MyApp(queue)
app.horizontal_alignment="center",
# start the consumer
consumer_process = Process(target=consumer, args=(app,))
consumer_process.start()
# start the producer
# producer_process = Process(target=producer, args=(queue,0))
# producer_process.start()
# Main loop
flet.app(target=main)
# flet.app(target=main, view=flet.WEB_BROWSER)
# force stop consumer
queue.put(None)
# wait for all processes to finish
# producer_process.join()
consumer_process.join()
flet 0.12.1
Python 3.11
Windows
IDE vscode
I cloned the repo and run the main file and got the below error.
The error:
PS C:\Users\admin\trolli> & C:/Python311/python.exe c:/Users/admin/trolli/trolli/src/main.py
Unhandled error processing page session : Traceback (most recent call last):
File "C:\Users\admin\AppData\Roaming\Python\Python311\site-packages\flet_runtime\app.py", line 363, in on_session_created
session_handler(page)
File "c:\Users\admin\trolli\trolli\src\main.py", line 207, in main
app.initialize()
File "c:\Users\admin\trolli\trolli\src\main.py", line 87, in initialize
self.page.go("/")
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'go'
When I change tab when using Navigation Rail on your example, my ram memory increase
The more I use Navigation Rail, the more ram memory increase
How to fix it? If I use this code for my program, it may cause slow due to over ram memory
Description
The Trolli tutorial appears to be incomplete. I think the TrelloApp class is missing its UserControl parent and also its build() method. I also visited the corresponding github repo for this app https://github.com/flet-dev/examples/tree/main/python/apps/trolli which, upon running main.py after creating a new virtual environment and installing the project requirements, I encountered an error on the create_new_board implementation where the Board() is receiving a None type for its first arg instead a control.
Code example to reproduce the issue:
Follow this first section:
https://flet.dev/docs/tutorials/trello-clone#defining-entities-and-layout
Describe the results you received:
AttributeError: 'TrelloApp' object has no attribute '_build_add_commands'
Describe the results you expected:
According to the tutorial:
"we can see the result and get hot reloading when we make any style changes. For example, try adding alignment="center" to the first row in the container like this…"
Flet version (pip show flet):
Version: 0.20.0
Give your requirements.txt file (don't pip freeze, instead give direct packages):
anyio==4.2.0
arrow==1.3.0
binaryornot==0.4.4
certifi==2024.2.2
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
cookiecutter==2.5.0
flet==0.20.0
flet-core==0.20.0
flet-runtime==0.20.0
h11==0.14.0
httpcore==0.17.3
httpx==0.24.1
idna==3.6
Jinja2==3.1.3
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
oauthlib==3.2.2
packaging==23.2
Pygments==2.17.2
pypng==0.20220715.0
python-dateutil==2.8.2
python-slugify==8.0.4
PyYAML==6.0.1
qrcode==7.4.2
repath==0.9.0
requests==2.31.0
rich==13.7.0
six==1.16.0
sniffio==1.3.0
text-unidecode==1.3
types-python-dateutil==2.8.19.20240106
typing_extensions==4.9.0
urllib3==2.2.0
watchdog==3.0.0
websocket-client==1.7.0
websockets==11.0.3
Operating system:
macOS
Features
Through this example application, a user will get to know how to authenticate Firebase and MongoDB with the
flet-dev
package.
I want to work on this, please assign it to me :)
Running the following lines of code, my original code displayed the correct attributes on desktop mac, but None on web and ios. The debug messages 'item added' and 'item in list = True' was displayed on all 3 platforms, but on web and ios it displayed None instead of the expected attributes. The fix chatgpt gave me corrected it so that it now displays the correct attributes on all platforms. What was the issue here? I'm not an experienced programmer so I don't understand what happened. Is this something about Python I don't understand or something specific to flet?
functions_item.add_item(page, 'item_name', 23, 46, 15, 6, 2)
page.add(ft.Text(f"item_name has {functions_item.fetch_item_attributes(page, 'item_name')}"))
How to use Canvas ? how paint image and save image?
can't run on Flet desktop(windows), error: Exception: oauthAuthorize command is not supported.
File "icon-browser.py", line 40
while batch := list(islice(iterator, batch_size)):
^
SyntaxError: invalid syntax
Hi,
I have a Python script which consists of 5 functions. If I run functions separately everything works smoothly. But if I run it in one main.py file a few of those mouse clicks miss Y coordinate in the middle of the process. I am hopeless to find why it does miss it. X is always correct but Y coordinate is a bit too up and hence it miss an "OK" button
Did anyone ever experience this?
From IOS (Ipad & Iphone), I want to save files (upload) using FilePicker.
I downloaded examples/python/controls/file-picker/file-picker-all-modes.py from Github.
The Python example works well on my desktop (Windows).
On IOS, "Pick files" works well, but ...
Trying "Save file", IOS Files app popup manager doesn't open.
Trying "Open directory, IOS Files app popup manager opens, by Flet crash without any message when I try (click) to open a directory.
With flet==0.1.62, the counter-accessible.py example fails:
Traceback (most recent call last): File "counter-accessible.py", line 3, in <module> from flet.page import KeyboardEventData ImportError: cannot import name 'KeyboardEventData' from 'flet.page' (/home/marc/.local/lib/python3.8/site-packages/flet/page.py)
Hi there,
Flet looks really promising! Great work!
I looked through your documentation but couldn't find a widget that supports the selection of multiple folders. It would be extremely handy to have a widget like file picker but instead of selecting files I need to be able to select folders (directories) that are returned as a list. Any plans of implementing that?
Thank you
'Flet' app window gives the following error when closed with the cross sign.
Here is sample code:
import flet as ft
def main(page: ft.Page):
# add/update controls on Page
# pass
t = ft.Text(value="Hello, world!", color="green")
page.controls.append(t)
page.update()
btn = ft.ElevatedButton("Click me!")
page.add(btn)
ft.app(target=main)
And here is the error :
%Run flet-002_counter.py
Exception ignored in: <function StreamWriter.del at 0x000001525F2E6660>
Traceback (most recent call last):
File "d:\wpy64-31160\python-3.11.6.amd64\Lib\asyncio\streams.py", line 395, in del
self.close()
File "d:\wpy64-31160\python-3.11.6.amd64\Lib\asyncio\streams.py", line 343, in close
return self._transport.close()
^^^^^^^^^^^^^^^^^^^^^^^
File "d:\wpy64-31160\python-3.11.6.amd64\Lib\asyncio\proactor_events.py", line 109, in close
self._loop.call_soon(self._call_connection_lost, None)
File "d:\wpy64-31160\python-3.11.6.amd64\Lib\asyncio\base_events.py", line 761, in call_soon
self._check_closed()
File "d:\wpy64-31160\python-3.11.6.amd64\Lib\asyncio\base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
I just tested the to-do app.
https://replit.com/join/qhjhrfdrqe-dennisgg
Ran it.
Downloaded it to desktop
entered data
closed the app
reopened the app
all of the data entered was gone
Do you have an example of any kind of data persistence between sessions on the desktop?
thank you
file-picker-upload-progress.py
gives
Exception: Unsupported command: getUploadUrl
on upload.
Also, the documentation is very unclear as to where the files have gone, so that they can be used again later.
While trying to pass GridView
through build()
functions of custom classes and placing it inside a Row
, grid refuses to show up.
Code sample:
import flet as ft
class Thing(ft.UserControl):
def build(self):
self.view = ft.GridView(
runs_count = 5
)
for i in range(0, 60):
self.view.controls.append(
ft.Text(f"Text {i}")
)
return self.view
class App(ft.UserControl):
def build(self):
self.view = ft.Row([Thing()])
return self.view
def main(page: ft.Page):
app = App()
page.add(app)
ft.app(target=main)
Replacing Row
with Column
works fine, as well as replacing GridView
with ListView
. The problem is specific just for the aforementioned particular combination for some reason.
Any tips or workarounds to solve the issue are highly appreciated.
How to restart the app by programming?
If I have a restart menu item, or a pop-up box prompts the user to resetart.
session_handler(page)
TypeError: 'Page' object is not callable
Connected to MySQL database successfully.
Unhandled error processing page session : Traceback
(most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\flet_runtime\app.py", line 357, in on_session_created
session_handler(page)
TypeError: 'Page' object is not callable
can't run the app due to this error
When i run the command flet build apk
It stucks at packaging python app.
In requirements.txt i have this libraries:
flet
pyotp
cryptography
mysql-connrctor-python
argon2-cffi
Please help me!
Any ideas why is this not working ?
Do you know if there is a way to edit a selection of text that the user has highlighted (say to make it bold/underlined/italic, or to change color/font, etc.) If not, is there perhaps something like that on the way?
FilePicker didn't work on iOS PWA but it's working on both desktop and Android.
The FilePicker only works if running with Flet app from AppStore and running "flet run --ios"
Can you make it work without depending on Flet app from App Store?
Hello!
I was running the home-store.py
routing example from here, and I faced this issue:
(python_flutter) ➜ python_flutter python3 src/main.py
(flet:19284): Gdk-CRITICAL **: 13:47:24.916: gdk_window_get_state: assertion 'GDK_IS_WINDOW (window)' failed
My system:
OS: Ubuntu 22.04.3 LTS x86_64
Kernel: 6.2.0-36-generic
When i try to search something at https://gallery.flet.dev/icons-browser/ it returns nothing.
The Javascript console shows this:
pyodide.asm.js:9 PyodideTask exception was never retrieved
future: <PyodideTask finished name='Task-25' coro=<app_async.<locals>.on_event() done, defined at /lib/python3.11/site-packages/flet/flet.py:52> exception=TypeError("argument of type 'function' is not iterable")
batched @ pyodide.asm.js:9
write @ pyodide.asm.js:9
(anônimo) @ pyodide.asm.js:9
handleEAGAIN @ pyodide.asm.js:9
readWriteHelper @ pyodide.asm.js:9
write @ pyodide.asm.js:9
write @ pyodide.asm.js:9
doWritev @ pyodide.asm.js:9
_fd_write @ pyodide.asm.js:9
$write @ pyodide.asm.wasm:0x457dbd
$_Py_write @ pyodide.asm.wasm:0x2d9907
$func6451 @ pyodide.asm.wasm:0x39d19e
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$func1226 @ pyodide.asm.wasm:0x1ad900
$PyObject_VectorcallMethod @ pyodide.asm.wasm:0x1a43ef
$func6521 @ pyodide.asm.wasm:0x3a06e5
$func6519 @ pyodide.asm.wasm:0x3a049b
$func6517 @ pyodide.asm.wasm:0x3a01e0
$func6547 @ pyodide.asm.wasm:0x3a2e32
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$func1225 @ pyodide.asm.wasm:0x1ad824
$PyObject_VectorcallMethod @ pyodide.asm.wasm:0x1a43ef
$func6588 @ pyodide.asm.wasm:0x3a7424
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$func2039 @ pyodide.asm.wasm:0x1e41e4
$PyObject_CallOneArg @ pyodide.asm.wasm:0x1a394c
$PyFile_WriteObject @ pyodide.asm.wasm:0x1b9397
$func3165 @ pyodide.asm.wasm:0x25f48e
$func2037 @ pyodide.asm.wasm:0x1e3f77
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5416
$PyObject_CallOneArg @ pyodide.asm.wasm:0x1a394c
$func4616 @ pyodide.asm.wasm:0x2f9e11
$func4644 @ pyodide.asm.wasm:0x2fb13c
$PyObject_CallFinalizerFromDealloc @ pyodide.asm.wasm:0x1e6c4c
$func2398 @ pyodide.asm.wasm:0x1f6af7
$_Py_Dealloc @ pyodide.asm.wasm:0x1e972e
$func2356 @ pyodide.asm.wasm:0x1f4024
$_Py_Dealloc @ pyodide.asm.wasm:0x1e972e
$func2398 @ pyodide.asm.wasm:0x1f6c9b
$_Py_Dealloc @ pyodide.asm.wasm:0x1e972e
$func1103 @ pyodide.asm.wasm:0x1a4edc
$_Py_Dealloc @ pyodide.asm.wasm:0x1e972e
$func2356 @ pyodide.asm.wasm:0x1f4024
$_Py_Dealloc @ pyodide.asm.wasm:0x1e972e
$func1595 @ pyodide.asm.wasm:0x1c05cf
$func1594 @ pyodide.asm.wasm:0x1c0400
$Py_DecRef @ pyodide.asm.wasm:0x1e6a2e
wrapper.destroy @ pyodide.asm.js:9
wrapper @ pyodide.asm.js:9
setTimeout (assíncrono)
hiwire_call_bound @ pyodide.asm.js:9
$func337 @ pyodide.asm.wasm:0x15affd
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5416
$func1064 @ pyodide.asm.wasm:0x1a35b0
$_PyObject_Call @ pyodide.asm.wasm:0x1a383a
$PyObject_Call @ pyodide.asm.wasm:0x1a38dc
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2685c5
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5524
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$func4595 @ pyodide.asm.wasm:0x2f8d4a
$func4590 @ pyodide.asm.wasm:0x2f8743
$func4591 @ pyodide.asm.wasm:0x2f8a04
$func4588 @ pyodide.asm.wasm:0x2f7dac
$func4587 @ pyodide.asm.wasm:0x2f7942
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$_PyObject_MakeTpCall @ pyodide.asm.wasm:0x1a3091
$func3387 @ pyodide.asm.wasm:0x289e4d
$func2037 @ pyodide.asm.wasm:0x1e3f77
$func1064 @ pyodide.asm.wasm:0x1a3579
$_PyObject_Call @ pyodide.asm.wasm:0x1a383a
$PyObject_Call @ pyodide.asm.wasm:0x1a38dc
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2685c5
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_pyproxy_apply @ pyodide.asm.wasm:0x15f45e
Module.callPyObjectKwargs @ pyodide.asm.js:9
Module.callPyObject @ pyodide.asm.js:9
wrapper @ pyodide.asm.js:9
setTimeout (assíncrono)
hiwire_call_bound @ pyodide.asm.js:9
$func337 @ pyodide.asm.wasm:0x15affd
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5416
$func1064 @ pyodide.asm.wasm:0x1a35b0
$_PyObject_Call @ pyodide.asm.wasm:0x1a383a
$PyObject_Call @ pyodide.asm.wasm:0x1a38dc
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2685c5
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5524
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$func4595 @ pyodide.asm.wasm:0x2f8d4a
$func4643 @ pyodide.asm.wasm:0x2faf70
$func2418 @ pyodide.asm.wasm:0x1f968e
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$_PyObject_MakeTpCall @ pyodide.asm.wasm:0x1a3091
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3682
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func1428 @ pyodide.asm.wasm:0x1b7321
$func1449 @ pyodide.asm.wasm:0x1b8034
$PyIter_Send @ pyodide.asm.wasm:0x191cf2
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2640ae
$func1428 @ pyodide.asm.wasm:0x1b7321
$func1449 @ pyodide.asm.wasm:0x1b8034
$PyIter_Send @ pyodide.asm.wasm:0x191cf2
$func4588 @ pyodide.asm.wasm:0x2f7aac
$func4596 @ pyodide.asm.wasm:0x2f8e71
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$func2039 @ pyodide.asm.wasm:0x1e41e4
$func3387 @ pyodide.asm.wasm:0x289e61
$func2037 @ pyodide.asm.wasm:0x1e3f77
$func1064 @ pyodide.asm.wasm:0x1a3579
$_PyObject_Call @ pyodide.asm.wasm:0x1a383a
$PyObject_Call @ pyodide.asm.wasm:0x1a38dc
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2685c5
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_pyproxy_apply @ pyodide.asm.wasm:0x15f45e
Module.callPyObjectKwargs @ pyodide.asm.js:9
Module.callPyObject @ pyodide.asm.js:9
wrapper @ pyodide.asm.js:9
setTimeout (assíncrono)
hiwire_call_bound @ pyodide.asm.js:9
$func337 @ pyodide.asm.wasm:0x15affd
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5416
$func1064 @ pyodide.asm.wasm:0x1a35b0
$_PyObject_Call @ pyodide.asm.wasm:0x1a383a
$PyObject_Call @ pyodide.asm.wasm:0x1a38dc
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x2685c5
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5524
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$func4595 @ pyodide.asm.wasm:0x2f8d4a
$func4590 @ pyodide.asm.wasm:0x2f8846
$func4619 @ pyodide.asm.wasm:0x2fa097
_PyCFunctionWithKeywords_TrampolineCall @ pyodide.asm.js:9
$func1226 @ pyodide.asm.wasm:0x1ad900
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_PyEval_EvalFrameDefault @ pyodide.asm.wasm:0x26a368
$func3201 @ pyodide.asm.wasm:0x26e3d0
$_PyFunction_Vectorcall @ pyodide.asm.wasm:0x1a3a04
$func1114 @ pyodide.asm.wasm:0x1a5416
$PyObject_Vectorcall @ pyodide.asm.wasm:0x1a3694
$_pyproxy_apply @ pyodide.asm.wasm:0x15f45e
Module.callPyObjectKwargs @ pyodide.asm.js:9
Module.callPyObject @ pyodide.asm.js:9
apply @ pyodide.asm.js:9
apply @ pyodide.asm.js:9
self.onmessage @ python-worker.js:45
pyodide.asm.js:9 future: <PyodideTask finished name='Task-25' coro=<app_async.<locals>.on_event() done, defined at /lib/python3.11/site-packages/flet/flet.py:52> exception=TypeError("argument of type 'function' is not iterable")>```
我安装以下步骤运行,然后收到'NoneType' object has no attribute 'width'异常
git clone https://github.com/flet-dev/examples.git
cd examples\python\apps\trolli
pip3 install -r requirements.txt
python3 ./src/main.py
Unhandled error processing page session : Traceback (most recent call last):
File "D:\Procedure\LanguageInterpreter\Python310\lib\site-packages\flet_runtime\app.py", line 363, in on_session_created
session_handler(page)
File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 207, in main
app.initialize()
File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 86, in initialize
self.create_new_board("My First Board")
File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 187, in create_new_board
new_board = Board(self, self.store, board_name)
File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\board.py", line 49, in __init__
width=(self.app.page.width - 310),
AttributeError: 'NoneType' object has no attribute 'width'
经过分析发现在src\main.py:83 self.page.update()
后self.page就会等于None
跟踪下去是flet_core\page.py:466 ctrl.page = None
将其赋值为None
请问是什么问题导致的呢,以下是我的版本
Python 3.10.7
flet 0.12.0
flet-core 0.12.0
flet-fastapi 0.12.0
flet-runtime 0.12.0
HI,
I try the example pubsub after update Flet and dont' work
good day, I'm working on uploading files to my server. I'm using one to one example from:
https://github.com/flet-dev/examples/blob/main/python/controls/file-picker/file-picker-upload-progress.py
When I upload files larger than 536 MB, it only downloads 536 MB to disk. At the same time, on_upload writes that progress is 100%.
I'm still a newbie and most likely I did something wrong, but suddenly I'm not the only one having this problem.
just tried to start a new app,
installed flet using pip pip install flet
and then started flet by importing flet.
import flet
then the error poped out:
Traceback (most recent call last):
File "/Users/admin/Documents/SampleScripts/todo.py", line 1, in <module>
import flet
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/flet/__init__.py", line 1, in <module>
from flet.alert_dialog import AlertDialog
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/flet/alert_dialog.py", line 3, in <module>
from beartype import beartype
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/__init__.py", line 59, in <module>
from beartype._decor.main import beartype
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/_decor/main.py", line 22, in <module>
from beartype.typing import TYPE_CHECKING
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/typing/__init__.py", line 329, in <module>
from beartype.typing._typingpep544 import (
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/typing/_typingpep544.py", line 35, in <module>
from beartype._util.cache.utilcachecall import callable_cached
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/_util/cache/utilcachecall.py", line 33, in <module>
from beartype._util.func.arg.utilfuncargtest import (
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/_util/func/arg/utilfuncargtest.py", line 16, in <module>
from beartype._util.func.utilfunccodeobj import get_func_codeobj
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/_util/func/utilfunccodeobj.py", line 19, in <module>
from beartype._data.datatyping import Codeobjable, TypeException
File "/Users/admin/Documents/SampleScripts/venv/lib/python3.9/site-packages/beartype/_data/datatyping.py", line 85, in <module>
BeartypeReturn = Union[BeartypeableT, BeartypeConfedDecorator]
File "/usr/local/Cellar/[email protected]/3.9.1_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 262, in inner
return func(*args, **kwds)
File "/usr/local/Cellar/[email protected]/3.9.1_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 339, in __getitem__
return self._getitem(self, parameters)
File "/usr/local/Cellar/[email protected]/3.9.1_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 451, in Union
parameters = _remove_dups_flatten(parameters)
File "/usr/local/Cellar/[email protected]/3.9.1_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 231, in _remove_dups_flatten
return tuple(_deduplicate(params))
File "/usr/local/Cellar/[email protected]/3.9.1_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 205, in _deduplicate
all_params = set(params)
TypeError: unhashable type: 'list'
any help?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.