macOS native utilities for Python
Project description
mm-pymac
macOS native utilities for Python.
Installation
uv add mm-pymac
Usage
Tray / Status Bar
from mm_pymac import TrayApp, MenuItem, MenuSeparator
app = TrayApp(title="My App")
app.set_menu([
MenuItem("Status: running", enabled=False),
MenuSeparator(),
MenuItem("Quit", callback=lambda _: app.quit()),
])
app.start_timer(1.0, lambda: print("tick"))
app.run()
Alerts
from mm_pymac import show_alert
result = show_alert(
"Your task is complete.",
title="Done",
buttons=("Cancel", "OK"),
default_button="OK",
)
if result == "OK":
print("User confirmed")
Lock Screen
from mm_pymac import is_screen_locked
locked = is_screen_locked()
if locked is None:
print("Cannot determine lock state")
elif locked:
print("Screen is locked")
else:
print("Screen is unlocked")
Clipboard
from mm_pymac import set_clipboard, get_clipboard, clear_clipboard
# Copy text
set_clipboard("Hello, world!")
# Read text (returns None if clipboard has no text)
text = get_clipboard()
# Clear clipboard
clear_clipboard()
# Clear only if clipboard still contains the expected value
clear_clipboard(expected="Hello, world!")
Event subscription
Subscribe to lock/unlock events (requires a running run loop, e.g. TrayApp.run()):
from mm_pymac import on_screen_locked, on_screen_unlocked
unsub_lock = on_screen_locked(lambda: print("Screen locked"))
unsub_unlock = on_screen_unlocked(lambda: print("Screen unlocked"))
# Later, to stop listening:
unsub_lock()
unsub_unlock()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mm_pymac-0.0.2.tar.gz
(35.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mm_pymac-0.0.2.tar.gz.
File metadata
- Download URL: mm_pymac-0.0.2.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8349ec409ce9ea4b0e5572a8b1106739129b050bb62825f54731f81826d0bb1
|
|
| MD5 |
7ddd2ad3310b7a83eaa8129ef00fd8cc
|
|
| BLAKE2b-256 |
da5bdea39ce98ab6e2b261b1e56f13da7ba47e3df2320dd64318798cf82745eb
|
File details
Details for the file mm_pymac-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mm_pymac-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8794a04b44714c9a7c946de691b4edf78d70a1153b6d7f1d9f439a87d6a5d2dc
|
|
| MD5 |
3d5ed7bf88605d2b36f2c694d953c764
|
|
| BLAKE2b-256 |
019b39fed8af669ed4ac0e6475135df908eabb4be43845ed327aa79cdb404ff8
|