Skip to main content

A Python module to interact with the Windows tray.

Project description

pytray

A Python module to interact with the Windows tray.

Installation

From PyPI

pip3 install ptray

From GitHub

pip3 install git+https://github.com/donno2048/pytray

Usage

Here is a simple example:

import pytray, time, os
pytray.create_tray_element()
pytray.create_menu(
    ("Exit", 1), ("Close", 2)
)
pytray.add_icon()
i = 0
while True:
    start_time = time.time()
    while time.time() - start_time < 0.3:
        click = pytray.what_is_clicked()
        if click == 1:
            exit()
        elif click == 2:
            pytray.hide_menu()
        elif click == None:
            pass
        time.sleep(0.1) # make sure only one click is registered
    pytray.set_icon(os.path.abspath(f"cat\\{i}.ico")) # requires the cat directory from this repo (by Kyome22)
    i = (i + 1) % 5

Project details


Download files

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

Source Distribution

ptray-1.1.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page