flet-dev / flet Goto Github PK
View Code? Open in Web Editor NEWFlet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
Home Page: https://flet.dev
License: Apache License 2.0
Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
Home Page: https://flet.dev
License: Apache License 2.0
Is it possible to use the file picker package?
https://pub.dev/packages/file_picker
Is it now possible to change the font style?
https://eugenkiss.github.io/7guis/
GUI tasks:
Useful materials:
Configuring OAuth provider:
provider = GitHubOAuthProvider(
"<client_id>",
"<client_secret>",
"<redirect_url>",
["user", "public_repo])
Authenticate (start OAuth flow) user:
auth: Authentication = page.login(provider, fetch_user=True, fetch_groups=True)
# fetch_users, fetch_groups if enabled ensure required scopes are set
page.auth # the last Authentication
page.auth.token # authentication token
page.auth.user # instance of AuthUser class
page.auth.provider # instance of OAuthProvider
Check if a session is authenticated:
if page.auth != None:
# user is logged in
class OAuthProvider():
_name
client_id
client_secret
authorization_endpoint
token_endpoint
redirect_url
def get_user():
pass
class OAuthToken():
token
created
expiresIn
refreshToken
scope
token_type
class AuthUser():
id
class GitHubUser(AuthUser):
full_name
email
teams
authorization_endpoint
: https://github.com/login/oauth/authorize
token_endpoint
: https://github.com/login/oauth/access_token
read:user
, user:email
read:org
authorization_endpoint
: https://accounts.google.com/o/oauth2/auth
token_endpoint
: https://oauth2.googleapis.com/token
https://www.googleapis.com/auth/userinfo.email
, https://www.googleapis.com/auth/userinfo.profile
authorization_endpoint
: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize
token_endpoint
: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
user.read
Directory.Read.All
Web: http(s)://{application_url}/api/oauth/redirect
Desktop: http://localhost/api/oauth/redirect
Mobile: flet://api/oauth/redirect
login(provider)
method flowstate
value, save state
in Authentication object.redirect_url
.page.oauth_login(authorization_url, state)
.oauth_state_{state}
key and page_id:session_id
value.oauth_login
on a client with authorization_url
and state
.authorization_url
in:
redirect_url
.page_id:session_id
by oauth_state_{state}
key. Verifies state
.on_authorize
event to a Python code with code
, error
, state
.state
.on_authorize
event to a Python code with code
, error
, state
.on_authorize
handler called:
state
code
, client_secret
, token_endpoint
.page.on_login
event handler called.flet is good but how do we call native functions with it
ig we should look into plyer
library
https://github.com/kivy/plyer
is there any plans to make an API layer library for flet specifically ?
Hi,
Thanks for this awesome package! Absolutely love this!
I have some questions:
Thanks,
Harshal
What should be the thought process or code to capture the position of a mouse with respect to an image loaded on the window and then paint/draw a dot at that location?
Hi there, I look through the doc and did not find a case of demonstration the concept id signal or slot which is used for interaction between components or thread/process.
Could anyone give some idea of how to do that manually?
Thanks
OS: kubuntu 22.04
python 3.10
File "/home/Python/flet_examples/counter.py", line 1, in
import flet
File "/home/.local/lib/python3.10/site-packages/flet/init.py", line 17, in
from flet.flet import *
File "/home/.local/lib/python3.10/site-packages/flet/flet.py", line 12, in
from ensurepip import version
ModuleNotFoundError: No module named 'ensurepip'
Feature idea: Support for drag & drop events -- conceptually, an event on a control that is called at drag start to provide a data object (dict), then another event on a target control that handles a drop, including the data provided at the start. I see flutter has all the required machinery, not sure how much out-of-the-box support is provided by flutter for the visuals (like in iOS you automatically get a "shadow image" of the control being dragged, and an indicator whether the control under the mouse/finger supports dropping).
The following code does not set page's background color of a newly generated theme:
def main(page: Page):
page.bgcolor = colors.SECONDARY
page.update()
flet.app(target=main)
Expected behavior: A color from a custom theme is used.
Actual behavior: A color from default Flutter theme is used.
Traceback (most recent call last):
File "C:\Users\Administrator\Documents\TEST\crossplatformappswith_flet_and_flutter\counter.py", line 1, in
import flet
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\flet_init_.py", line 1, in
from flet.alert_dialog import AlertDialog
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\flet\alert_dialog.py", line 3, in
from beartype import beartype
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_init_.py", line 59, in
from beartype.decor.main import beartype
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_decor\main.py", line 22, in
from beartype.typing import TYPE_CHECKING
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype\typing_init.py", line 329, in
from beartype.typing._typingpep544 import (
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype\typing_typingpep544.py", line 35, in
from beartype._util.cache.utilcachecall import callable_cached
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_util\cache\utilcachecall.py", line 33, in
from beartype._util.func.arg.utilfuncargtest import (
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_util\func\arg\utilfuncargtest.py", line 16, in
from beartype._util.func.utilfunccodeobj import get_func_codeobj
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_util\func\utilfunccodeobj.py", line 19, in
from beartype._data.datatyping import Codeobjable, TypeException
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\beartype_data\datatyping.py", line 85, in
BeartypeReturn = Union[BeartypeableT, BeartypeConfedDecorator]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\typing.py", line 243, in inner
return func(*args, **kwds)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\typing.py", line 316, in getitem
return self._getitem(self, parameters)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\typing.py", line 421, in Union
parameters = _remove_dups_flatten(parameters)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\typing.py", line 215, in _remove_dups_flatten
all_params = set(params)
TypeError: unhashable type: 'list'
This is a very generic control.
like this: https://github.com/EdsonBueno/infinite_scroll_pagination
Examples for TextField
still need to be updated to Flet (refer to Textbox
, demonstrate features that TextField
does not have).
is there any way to implement hot reload? the development is really slow this way
Implementation notes:
https://pdm.fming.dev/latest/pyproject/pep621/#console-scripts
https://api.flutter.dev/flutter/dart-io/FileSystemEntity/watch.html
dart-lang/sdk#30918
https://api.dart.dev/stable/2.17.6/dart-io/Process-class.html
how can i make app with multi pages
and how to navigate between them ??
Example usage:
# ...
flet.app(target=main, web_renderer="html")
Supported values:
auto
(default) - optimizing for download size on mobile browsers and optimizing for performance on desktop browsers.html
- optimizing download size over performance on both desktop and mobile browsers.canvaskit
- prioritizing performance and pixel-perfect consistency on both desktop and mobile browsers.Resources: https://docs.flutter.dev/development/platform-integration/web/renderers#runtime-configuration
User control (UserControl
) allows building re-usable components by combining existing Flet controls. User control behaves like a Control
, could have methods and properties.
User control has lifecycle methods:
did_mount()
- called after the UserControl added to a page and assigned transient id
.will_unmount()
- called before the UserControl is removed from the page.UserControl
is inhrited from Stack
control and allows multiple children.
UserControl is isolated from outside layout, i.e. when update()
method is called for the parent control any changes inside the UserControl are not included into the update digest. UserControl should call self.update()
to push its changes to a Flet page.
There is no elevation propritie in AppBar
Similar products:
In kivy I can subclass the TextInput
widget to change the behaviour to always make the value uppercase and one letter long by doing the following:
class MyTextInput(TextInput):
def __init__(self, **kwargs):
super(MyTextInput, self).__init__(**kwargs)
def keyboard_on_textinput(self, window, text):
"""Upper case and always one letter only."""
self.text = text.upper()
Can something similar be done in flet? I tried the following which did not work:
def main(page: Page):
def cw_textbox_changed(e):
e.control.value = e.control.value[-1:]
page.update()
c1 = Container(
content=TextField(
value="W",
label=None,
hint_text=None,
text_align="center",
border="none",
content_padding=None,
data=d,
on_change=cw_textbox_changed,
),
)
Not sure if c1.value = e.control.value[-1:]
would do the trick, since I have many TextField
controls and only the one event handler function.
Hot Module Replacement is good for development, can it be supported?
** (flet:31142): CRITICAL **: 10:04:19.347: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) == 0' failed
This happens on the console while playing with the ToDo App example w/o modifications. The GUI seems functional.
The server is listening and the app is available via manually started web browser.
But no way to force native window to show up automatically, this must be a bug.
The same happens on Arch and Manjaro.
Python 3.10.5, flet 1.3.2.
I am simply pasting your examples w/o any modifications.
I am really searching for Location support for mapping purpose. It will be really useful on development of location based services.
Flet does not perform window_maximized correctly on Windows 10. page.window_maximized = True
sets the height of the window to be the height of the entire screen, instead of the height of the entire screen minus that of the taskbar; like other apps do. Also page.window_height
includes the height of the window title bar (with minimize, maximize and close buttons), but there does not seem to be any way to get the height of the window title bar; as such it is difficult to size an image to the page height, especially when targeting both 4k and 720p displays.
After installing Flet support through the Ubuntu 22.04 LTS PIP, every attempt to load an application with python3 app_name.py
just loads an empty window with the loading in progress icon and no content. The error message below is displayed.
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method isFocused on channel window_manager)
The webapp version always loads successfully in the browser. What am I missing?
PS: I also have Flutter installed. Could this be causing some bad behavior?
From the user: "...I tried to use page.theme.color_scheme_seed to modify it, but it didn't change on the page.".
Do you have plans aboou DatePicker control realisation?
Hi Team Flet,
Very excited to see this project! This has a lot of potential for quickly building applications and seamlessly porting existing Python Apps to Modern Technologies and Flutter.
My questions:
I'm trying to understand flet, is it just python code, if I wanted to send request should I use normal python request lib or something else
Same for cameras, file upload and converting to apk.
The docs is missing alot
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.