flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.34k stars 442 forks source link

[Feature Request] system tray icon component #954

Open InfernalAzazel opened 1 year ago

InfernalAzazel commented 1 year ago

Please Describe The Problem To Be Solved flet no a system tray icon component

(Optional): Suggest A Solution

(Replace This Text: A concise description of your preferred solution. Things to address include:

If there are multiple solutions, please present each one separately. Save comparisons for the very end.)

ndonkoHenri commented 1 year ago

https://github.com/ndonkoHenri/Flet-as-System-Tray-Icon

InfernalAzazel commented 1 year ago

hi, I've seen this before, it's not easy to customize, that is, it's the same as the flet gui menu.

tray_icon = pystray.Icon(
    name="Test",
    icon=tray_image,
    title="Flet in tray",
    menu=pystray.Menu(
        pystray.MenuItem(
            "Open App",
            default_item_clicked,  # alternative/broader callback: menu_item_clicked
            default=True  # set as default menu item
        ),
        pystray.MenuItem(
            "Go Nowhere 1",
            other_item_clicked  # alternative/broader callback: menu_item_clicked
        ),
        pystray.MenuItem(
            "Go Nowhere 2",
            other_item_clicked  # alternative/broader callback: menu_item_clicked
        ),
        pystray.MenuItem(
            "Close App",
            exit_app  # alternative/broader callback: menu_item_clicked
        )
    ),
    visible=False,
)
cccaballero commented 6 months ago

I was about to create a new issue and saw this one. The described approach using pystray doesn't work completely in Linux (Ubuntu 22.04).

pystray does not support menu items in Linux. There is also an issue where it's not possible to hide the window. In other operating systems, it's possible to minimize the window and skip the taskbar, but the skip taskbar feature doesn't work in Linux.

There are the tray_manager and window_manager Flutter plugins that allow properly handling tray icons and hiding/showing windows for all major desktop platforms.

Is it possible to include those features in Flet?