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

[!WARNING] The package will be installed on non-Windows platforms with no errors.

This is for automation purposes only, as the package will only work on Windows.

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.2.1.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file ptray-1.2.1.tar.gz.

File metadata

  • Download URL: ptray-1.2.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ptray-1.2.1.tar.gz
Algorithm Hash digest
SHA256 074b53e9cf8e3f516c8d95fe072672b3c5edc70fd55a1ef752ab963e1be1f4c0
MD5 a9978ae577fbd125fbda85b48e5e1728
BLAKE2b-256 088c09f96610646bbf726b0045d30b3ee8b9fe5592588d4c46a4d0ce8640cbe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ptray-1.2.1.tar.gz:

Publisher: python-publish.yml on donno2048/pytray

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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