psgtray-foss


Namepsgtray-foss JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/csm10495/psgtray
SummaryMirror of psgtray that depends on System Tray Icon that works with the PySimpleGUI tkinter port. Uses pystray to supply the system tray. Works well under Windows.
upload_time2024-02-19 23:02:46
maintainer
docs_urlNone
authorWAS: PySimpleGUI
requires_python
license
keywords gui ui pysimplegui tkinter systemtray pystray
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Note this is a fork of psgtray that links to PySimpleGUI-4-foss
# Instead of the non-opensource PySimpleGUI 5+
# I'm not planning on updating this, just using it for my own cases.
# pip install psgtray-foss

<p align="center">
  <img src="https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/for_readme/Logo%20with%20text%20for%20GitHub%20Top.png" alt="Python GUIs for Humans">
  <h1 align="center">psgtray</h1>
</p>

Add a System Tray Icon to your tkinter port of PySimpleGUI.


## Installation

Installation is via pip:

`python -m pip install psgtray`

or if you need to upgrade later:

`python -m pip install --upgrade --no-cache-dir psgtray`


## Adding To Your PySimpleGUI Program

This is a copy of the demo program that can be found in the PySimpleGUI Project's Demo Program folder.

```python
import PySimpleGUI as sg
from psgtray import SystemTray

"""
    A System Tray Icon courtesy of pystray and your friends at PySimpleGUI

    Import the SystemTray object with this line of code:
    from psgtray import SystemTray

    Key for the system tray icon is:
        tray = SystemTray()
        tray.key

    values[key] contains the menu item chosen.

    One trick employed here is to change the window's event to be the event from the System Tray.


    Copyright PySimpleGUI 2021
"""

def main():

    menu = ['', ['Show Window', 'Hide Window', '---', '!Disabled Item', 'Change Icon', ['Happy', 'Sad', 'Plain'], 'Exit']]
    tooltip = 'Tooltip'

    layout = [[sg.Text('My PySimpleGUI Celebration Window - X will minimize to tray')],
              [sg.T('Double clip icon to restore or right click and choose Show Window')],
              [sg.T('Icon Tooltip:'), sg.Input(tooltip, key='-IN-', s=(20,1)), sg.B('Change Tooltip')],
              [sg.Multiline(size=(60,10), reroute_stdout=False, reroute_cprint=True, write_only=True, key='-OUT-')],
              [sg.Button('Go'), sg.B('Hide Icon'), sg.B('Show Icon'), sg.B('Hide Window'), sg.Button('Exit')]]

    window = sg.Window('Window Title', layout, finalize=True, enable_close_attempted_event=True)


    tray = SystemTray(menu, single_click_events=False, window=window, tooltip=tooltip, icon=sg.DEFAULT_BASE64_ICON)
    tray.show_message('System Tray', 'System Tray Icon Started!')
    sg.cprint(sg.get_versions())
    while True:
        event, values = window.read()

        # IMPORTANT step. It's not required, but convenient. Set event to value from tray
        # if it's a tray event, change the event variable to be whatever the tray sent
        if event == tray.key:
            sg.cprint(f'System Tray Event = ', values[event], c='white on red')
            event = values[event]       # use the System Tray's event as if was from the window

        if event in (sg.WIN_CLOSED, 'Exit'):
            break

        sg.cprint(event, values)
        tray.show_message(title=event, message=values)

        if event in ('Show Window', sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED):
            window.un_hide()
            window.bring_to_front()
        elif event in ('Hide Window', sg.WIN_CLOSE_ATTEMPTED_EVENT):
            window.hide()
            tray.show_icon()        # if hiding window, better make sure the icon is visible
            # tray.notify('System Tray Item Chosen', f'You chose {event}')
        elif event == 'Happy':
            tray.change_icon(sg.EMOJI_BASE64_HAPPY_JOY)
        elif event == 'Sad':
            tray.change_icon(sg.EMOJI_BASE64_FRUSTRATED)
        elif event == 'Plain':
            tray.change_icon(sg.DEFAULT_BASE64_ICON)
        elif event == 'Hide Icon':
            tray.hide_icon()
        elif event == 'Show Icon':
            tray.show_icon()
        elif event == 'Change Tooltip':
            tray.set_tooltip(values['-IN-'])

    tray.close()            # optional but without a close, the icon may "linger" until moused over
    window.close()

if __name__ == '__main__':
    main()
```

# Limitations

The Windows implementation is working well.  The Linux GTK version, not as well.

Updating the Menu after initial creation is not yet supported.

# Requirements

In order to use this pacakge you'll also need these packages:

* PySimpleGUI
* pystray (licensed under LGPL3)

Currently only versions <= 0.18.0 of pystray are supported


## Release Notes

### psgtray 1.0.2  12-Jan-2022

* Changed pypi setup to indicate version of pystray needs to be <= 0.18.0


### psgtray 1.0.1  21-Jun-2021

* Initial Release

# Support

Please open Issues in the main PySimpleGUI GitHub by with using the `psgisues` utility, the PySimpleGUI test harness, or go to https://Issues.PySimpleGUI.org.


# Designed and written by

mike from PySimpleGUI.org

# Contributing

Like the PySimpleGUI project, the psgtray project is currently licensed under an open-source license, the project itself is structured like a proprietary product.  Pull Requests are not accepted.


# License
GNU Lesser General Public License (LGPL 3) +

# Copyright
Copyright 2021 PySimpleGUI

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/csm10495/psgtray",
    "name": "psgtray-foss",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "GUI UI PySimpleGUI tkinter systemtray pystray",
    "author": "WAS: PySimpleGUI",
    "author_email": "WAS: mike@PySimpleGUI.org",
    "download_url": "",
    "platform": null,
    "description": "\n# Note this is a fork of psgtray that links to PySimpleGUI-4-foss\n# Instead of the non-opensource PySimpleGUI 5+\n# I'm not planning on updating this, just using it for my own cases.\n# pip install psgtray-foss\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/for_readme/Logo%20with%20text%20for%20GitHub%20Top.png\" alt=\"Python GUIs for Humans\">\n  <h1 align=\"center\">psgtray</h1>\n</p>\n\nAdd a System Tray Icon to your tkinter port of PySimpleGUI.\n\n\n## Installation\n\nInstallation is via pip:\n\n`python -m pip install psgtray`\n\nor if you need to upgrade later:\n\n`python -m pip install --upgrade --no-cache-dir psgtray`\n\n\n## Adding To Your PySimpleGUI Program\n\nThis is a copy of the demo program that can be found in the PySimpleGUI Project's Demo Program folder.\n\n```python\nimport PySimpleGUI as sg\nfrom psgtray import SystemTray\n\n\"\"\"\n    A System Tray Icon courtesy of pystray and your friends at PySimpleGUI\n\n    Import the SystemTray object with this line of code:\n    from psgtray import SystemTray\n\n    Key for the system tray icon is:\n        tray = SystemTray()\n        tray.key\n\n    values[key] contains the menu item chosen.\n\n    One trick employed here is to change the window's event to be the event from the System Tray.\n\n\n    Copyright PySimpleGUI 2021\n\"\"\"\n\ndef main():\n\n    menu = ['', ['Show Window', 'Hide Window', '---', '!Disabled Item', 'Change Icon', ['Happy', 'Sad', 'Plain'], 'Exit']]\n    tooltip = 'Tooltip'\n\n    layout = [[sg.Text('My PySimpleGUI Celebration Window - X will minimize to tray')],\n              [sg.T('Double clip icon to restore or right click and choose Show Window')],\n              [sg.T('Icon Tooltip:'), sg.Input(tooltip, key='-IN-', s=(20,1)), sg.B('Change Tooltip')],\n              [sg.Multiline(size=(60,10), reroute_stdout=False, reroute_cprint=True, write_only=True, key='-OUT-')],\n              [sg.Button('Go'), sg.B('Hide Icon'), sg.B('Show Icon'), sg.B('Hide Window'), sg.Button('Exit')]]\n\n    window = sg.Window('Window Title', layout, finalize=True, enable_close_attempted_event=True)\n\n\n    tray = SystemTray(menu, single_click_events=False, window=window, tooltip=tooltip, icon=sg.DEFAULT_BASE64_ICON)\n    tray.show_message('System Tray', 'System Tray Icon Started!')\n    sg.cprint(sg.get_versions())\n    while True:\n        event, values = window.read()\n\n        # IMPORTANT step. It's not required, but convenient. Set event to value from tray\n        # if it's a tray event, change the event variable to be whatever the tray sent\n        if event == tray.key:\n            sg.cprint(f'System Tray Event = ', values[event], c='white on red')\n            event = values[event]       # use the System Tray's event as if was from the window\n\n        if event in (sg.WIN_CLOSED, 'Exit'):\n            break\n\n        sg.cprint(event, values)\n        tray.show_message(title=event, message=values)\n\n        if event in ('Show Window', sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED):\n            window.un_hide()\n            window.bring_to_front()\n        elif event in ('Hide Window', sg.WIN_CLOSE_ATTEMPTED_EVENT):\n            window.hide()\n            tray.show_icon()        # if hiding window, better make sure the icon is visible\n            # tray.notify('System Tray Item Chosen', f'You chose {event}')\n        elif event == 'Happy':\n            tray.change_icon(sg.EMOJI_BASE64_HAPPY_JOY)\n        elif event == 'Sad':\n            tray.change_icon(sg.EMOJI_BASE64_FRUSTRATED)\n        elif event == 'Plain':\n            tray.change_icon(sg.DEFAULT_BASE64_ICON)\n        elif event == 'Hide Icon':\n            tray.hide_icon()\n        elif event == 'Show Icon':\n            tray.show_icon()\n        elif event == 'Change Tooltip':\n            tray.set_tooltip(values['-IN-'])\n\n    tray.close()            # optional but without a close, the icon may \"linger\" until moused over\n    window.close()\n\nif __name__ == '__main__':\n    main()\n```\n\n# Limitations\n\nThe Windows implementation is working well.  The Linux GTK version, not as well.\n\nUpdating the Menu after initial creation is not yet supported.\n\n# Requirements\n\nIn order to use this pacakge you'll also need these packages:\n\n* PySimpleGUI\n* pystray (licensed under LGPL3)\n\nCurrently only versions <= 0.18.0 of pystray are supported\n\n\n## Release Notes\n\n### psgtray 1.0.2  12-Jan-2022\n\n* Changed pypi setup to indicate version of pystray needs to be <= 0.18.0\n\n\n### psgtray 1.0.1  21-Jun-2021\n\n* Initial Release\n\n# Support\n\nPlease open Issues in the main PySimpleGUI GitHub by with using the `psgisues` utility, the PySimpleGUI test harness, or go to https://Issues.PySimpleGUI.org.\n\n\n# Designed and written by\n\nmike from PySimpleGUI.org\n\n# Contributing\n\nLike the PySimpleGUI project, the psgtray project is currently licensed under an open-source license, the project itself is structured like a proprietary product.  Pull Requests are not accepted.\n\n\n# License\nGNU Lesser General Public License (LGPL 3) +\n\n# Copyright\nCopyright 2021 PySimpleGUI\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Mirror of psgtray that depends on  System Tray Icon that works with the PySimpleGUI tkinter port.  Uses pystray to supply the system tray.  Works well under Windows.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/csm10495/psgtray"
    },
    "split_keywords": [
        "gui",
        "ui",
        "pysimplegui",
        "tkinter",
        "systemtray",
        "pystray"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "975002b432f0674cb6deafaf695842b5e4192da76b8400b4cea735468e552218",
                "md5": "a5b15e87c8511bfc3030c1b038b62fac",
                "sha256": "a14610a218e1d8f426a80e20941eb8f8dca79a5426a187e60e1d16ae6c058a82"
            },
            "downloads": -1,
            "filename": "psgtray_foss-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a5b15e87c8511bfc3030c1b038b62fac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 20133,
            "upload_time": "2024-02-19T23:02:46",
            "upload_time_iso_8601": "2024-02-19T23:02:46.396245Z",
            "url": "https://files.pythonhosted.org/packages/97/50/02b432f0674cb6deafaf695842b5e4192da76b8400b4cea735468e552218/psgtray_foss-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-19 23:02:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "csm10495",
    "github_project": "psgtray",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "psgtray-foss"
}
        
Elapsed time: 0.20315s