Skip to main content

TrayApp

based on Moses Palmér's pystray library!

Simple library for creating system tray applications.

PyPI version MIT License

Usage

with TrayApp(name='Test',  # the little tooltip, seen when hovering over the icon
             icon_path=Path('../path/to/the/image.png'),  # anything that can be transformed into a PIL.Image
             icon_size=(256, 256,)  # size to create the thumbnail
             ) as app:

    # create the menu shown when icon gets right-clicked here

    app.add_button(text='hello world',
                   action=print,  # method to call when clicked
                   args=('hello world',),  # arguments, optional, in a tuple
                   # determines wheter the function gets called when the icon is left-clicked
                   # optional, default to False, can be obviously only used once per app
                   default=True  
                   )

    app.add_separator()  # well...

    with app.add_submenu(text='SubMenu') as submenu:  # submenues can be created by using a context manager within

        with submenu.add_submenu(text='first subsub') as first_sub_sub:  # and recursivly as well
            first_sub_sub.add_button(text='1.1', action=print, args=('1.1',))
            first_sub_sub.add_button(text='1.2', action=print, args=('1.2',))

        with submenu.add_submenu(text='second susub') as second_sub_sub:
            second_sub_sub.add_button(text='2.1', action=print, args=('2.1',))
            second_sub_sub.add_button(text='2.2', action=print, args=('2.2',))

        # any add_button(), add_separator(), add_submenu(), add_radiobuttongroup() can be used here
        # just remember to add them to the right submenu        

    app.add_separator()

    # a RadioButtonGroup is a group of buttons which can be used to select something
    # trying it out might be the best way to understand it
    with app.add_radiobuttongroup() as rbg:  # used with a contextmanager as well
        rbg.add(text='hello')
        rbg.add(text='world', selected=True)  # selected determines the item which is selected on creation

RadioButtonGroup example:

items = (
        'hello',
        'world',
        'this',
        'is',
        'just',
        'an',
        'example',
    )

# you NEED to provide the group itself since just state would be by value
def print_selected(rbg): print(items[rbg.state])

selected_item = 3  # saved outside and updated when the app is closed

with TrayApp(name='Test',
             icon_path=Path(r'C:\Users\robin\Documents\Private\Python\trayPy\data\test.png'),
             icon_size=(256, 256,)) as app:

    with app.add_radiobuttongroup() as rbg:
        for index, item in enumerate(items):
            rbg.add(text=item, selected=index == selected_item)

    # to check if it works
    app.add_button(text='print the selected', action=print_selected, args=(rbg,), default=False)

License

MIT, see the LICENSE file

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trayapp-0.1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trayapp-0.1.4-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file trayapp-0.1.4.tar.gz.

File metadata

  • Download URL: trayapp-0.1.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for trayapp-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9127053184db9b4658280b0f3fd5778b9e8134391b3b0b6bab275bbd456f0bd9
MD5 7ec26f11862bf6a1e20f68ec8a8851e0
BLAKE2b-256 57b1e7149488b49a09ec0c9089706d2698855fb8ce3f31f4d48431427710db70

See more details on using hashes here.

File details

Details for the file trayapp-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: trayapp-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for trayapp-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7deb2dc585119e9dc179c90c51ded0bdee42b6b7c68d6a0cedd59da5173e2bfa
MD5 4ea5e5d6eec46905dba96baa0ae673dc
BLAKE2b-256 534b304ad62174daabfa620caa5cd48adcfc20e4bed0f885bd8d4b7df23195c9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page