Replies: 1 comment 4 replies
-
Check out this: #4252 I think support for command line arguments was added in 0.25.(release). I've put together a demo of this below: import flet as ft
def main(page: ft.Page):
page.title = "System Args Demo"
# Display original system arguments
args_text = ft.Text(f"System Arguments: {sys.argv}")
page.add(args_text)
if __name__ == "__main__":
import sys
ft.app(target=main) That will then need to be build using Flet Build.
Once it has been, an argument can be passed as follows (to the executable with the .app) In the screenshot, we see the sys.arg that we passed in. Does that help at all - or not what you were asking? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Is there a way to pass command line arguments to your (built) flet application, for example to open a file indicated in the argument?
I can use
sys.argv
and if I run my flet code withpython3 flet_code.py argument
, I can parse thesys.argv[1]
to getargument
. However the arguments are not parsed on the built program. (Also I could not find a way to pass arguments if I run the code withflet run flet_code.py argument
.)Is there a supported way for command line arguments in flet, or is this something that is simply not possible for now?
Thank you in advance
Code sample
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions