Skip to content

Command line arguments trough sys.argv not working on flet 0.27 #5128

Open
@jnsh

Description

@jnsh

Duplicate Check

Describe the bug

This was discussed in #5108

Using python's sys.argv to parse command line arguments to built flet applications is not working on Flet 0.27.6. I have been able to reproduce this on MacOS and Linux.

According to @ap4499 it was working on MacOS with Flet 0.25 on Mac, but I haven't been able to get builds working with that version on either Linux or Mac, so I can not confirm this.

Code sample

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

To reproduce

  1. Build above code against Flet 0.27.6
  2. Run the built program without command line arguments -> program starts and displays the sys.argv as empty list
  3. Run the built program with command line arguments (e.g. ./build/linux/program argument) -> the progam window opens but hangs without displaying any content

Expected behavior

Expected sys.argv to work for parsing command line arguments on the built program, as it should be reportedly possible.

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

Rocky Linux 9.3

Flet version

0.27.6

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

No response

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions