Code Monkey home page Code Monkey logo

flet-dev / flet Goto Github PK

View Code? Open in Web Editor NEW
9.1K 9.1K 354.0 32.17 MB

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

PowerShell 0.03% Shell 0.08% Dockerfile 0.01% Go 3.18% Batchfile 0.01% HTML 0.09% Kotlin 0.01% Swift 0.09% Objective-C 0.01% Dart 41.07% CMake 0.57% C++ 0.79% C 0.04% Python 53.83% Ruby 0.15% JavaScript 0.07%
android flutter ios python server-driven-ui web

flet's People

Contributors

50bytes-dev avatar abdulmumin1 avatar all-mute avatar am1010101 avatar apumapho avatar ariefendi992 avatar dshaw0004 avatar ewen-zippedscript avatar feodorfitsner avatar inesafitsner avatar iron3oxide avatar isaffathir avatar jantosi avatar johnnychen94 avatar kacper-os avatar kulothunganug avatar lucasew avatar mikaelho avatar modaye avatar ndonkohenri avatar pouralijan avatar shenanigansd avatar skeledrew avatar taaaf11 avatar techemmy avatar thearyadev avatar trafire avatar xzripper avatar youjiacheng avatar zerocool940711 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flet's Issues

Authentication

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

Providers

GitHub

  • authorization_endpoint: https://github.com/login/oauth/authorize
  • token_endpoint: https://github.com/login/oauth/access_token
  • User scope: read:user, user:email
  • Groups scope: read:org
  • Get emails
  • Get user
  • Get teams

Google

  • authorization_endpoint: https://accounts.google.com/o/oauth2/auth
  • token_endpoint: https://oauth2.googleapis.com/token
  • User scope: https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile
  • Groups scope: ?
  • Get user: https://www.googleapis.com/oauth2/v3/userinfo
    • sub
    • email
    • name

Azure

Redirect URLs

Web: http(s)://{application_url}/api/oauth/redirect
Desktop: http://localhost/api/oauth/redirect
Mobile: flet://api/oauth/redirect

login(provider) method flow

  • Generate random state value, save state in Authentication object.
  • Build authorization URL with redirect_url.
  • Call page.oauth_login(authorization_url, state).
  • Fletd stores an expiring cache object under oauth_state_{state} key and page_id:session_id value.
  • Fletd calls oauth_login on a client with authorization_url and state.
  • Flet client opens authorization_url in:
  • After user login and consent on OAuth provider side:
    • Web and desktop:
      • Redirects back to redirect_url.
      • Fletd fetches page_id:session_id by oauth_state_{state} key. Verifies state.
      • Fletd sends on_authorize event to a Python code with code, error, state.
      • Fletd generates HTML output with JavaScript code closing browser window/tab.
    • Mobile:
      • Verifies state.
      • Flet client sends on_authorize event to a Python code with code, error, state.
  • On Python side internal on_authorize handler called:
    • Validate state
    • Request token with code, client_secret, token_endpoint.
  • user and groups optionally fetch.
  • page.on_login event handler called.

Build for Android and using other flutter plugins

Hi,

Thanks for this awesome package! Absolutely love this!

I have some questions:

  1. Is it possible to compile the app as an android app? If yes, I'd appreciate any leads on this
  2. How can use other flutter plugins with flet?

Thanks,
Harshal

How component interact with background thread or process?

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

No module name ensurepip

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'

Support for drag & drop events

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).

Themed colors have no effect on "page" level

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.

Issues while importing flet using python 3.9

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'

Calc tutorial improvements

  • Full-screen "stretchy" layout
  • Responsive layout (changing result text size)
  • Packaging into executable with PyInstaller

Outdated examples for TextField

Examples for TextField still need to be updated to Flet (refer to Textbox, demonstrate features that TextField does not have).

multi pages app

how can i make app with multi pages
and how to navigate between them ??

Configure web renderer at runtime

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 Controls

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.

Chat app

Similar products:

  • Slack
  • Matter most
  • Zulip
  • Rocket.chat

How to change the value of a TextField in the on_change event

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.

HMR supported?

Hot Module Replacement is good for development, can it be supported?

Assertion "lookup_hash_table" fails on ToDo App example

** (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.

Native window won't show up for any of the examples

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.

`Location` control

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

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.

Error to load an app: MissingPluginException

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?

Allow partial theme updates

From the user: "...I tried to use page.theme.color_scheme_seed to modify it, but it didn't change on the page.".

3rd Party Flutter Plugins Support?

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:

  • How can we use 3rd party Flutter Plugins with this? Is it planned in the roadmap?
  • In case we want to use more advanced Flutter Functionality, does Flet support them somehow? (such as platform specific components, custom animations, Flutter Painter etc.)

Progressive Web Applications (PWA) done right!

  • Use localStorage instead of sessionStorage to track session when the app is installed as PWA
  • Reduce reconnection timeout for faster dehydration
  • Changing application icons: Windows, Linux, macOS, iOS, Android
  • Changing application name, palette in manifest.json
  • Banner control "Add this app to your desktop":
    • Chrome
    • Firefox
    • Edge
    • Safari
    • iOS Safari
    • Chrome on Android.

Is it pure python?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.