semvec/pypi-packages huggingface dataset:
apathetic-logging 0.22.0
Small quality-of-life features on top of stdlib.
Requires Python: >=3.10
Keywords: library, logging, logger

# Apathetic Python Logging 🪵

[![CI](https://github.com/apathetic-tools/python-logs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/goldilocks/python-logs/actions/workflows/ci.yml)
[![License: MIT-a-NOAI](https://img.shields.io/badge/License-MIT--a--NOAI-blueviolet.svg)](LICENSE)
[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord&logoColor=white)](https://discord.gg/PW6GahZ7)

📘 **[Roadmap](./ROADMAP.md)** · 📝 **[Release Notes](https://github.com/apathetic-tools/python-logs/releases)**

**Small quality-of-life features on top of stdlib.**
*Because you don't need another large dependency.*

*Apathetic Python Logger* provides a lightweight, dependency-free logging solution designed for CLI tools. It extends Python's standard library `logging` module with colorized output, dual-stream handling (stdout/stderr), extra logging levels and context.

> [!NOTE]
> This project is largely AI-written and minimally polished. I rely on it, but I haven't reviewed every detail.
> Expect rough edges. Thoughtful issue reports are appreciated.

## Quick Start

```python
from apathetic_logging import get_logger, register_logger

# Register your logger
register_logger("my_app")

# Get the logger instance
logger = get_logger()

# Use it!
logger.info("Hello, world!")
logger.detail("Extra verbosity above INFO")
logger.brief("Lower verbosity than INFO")
logger.trace("Trace information")
```

## Installation

```bash
# Using poetry
poetry add apathetic-logger

# Using pip
pip install apathetic-logger
```

## Documentation

📚 **[Full Documentation →](https://apathetic-tools.github.io/python-logging/)**

For installation guides, API reference, examples, and more, visit our documentation website.

---

## ⚖️ License

- [MIT-a-NOAI License](LICENSE)

You're free to use, copy, and modify the library under the standard MIT terms.  
The additional rider simply requests that this project not be used to train or fine-tune AI/ML systems until the author deems fair compensation frameworks exist.  
Normal use, packaging, and redistribution for human developers are unaffected.
asynctkinter2 0.1.0
Async library for Tkinter
Requires Python: <4.0,>=3.10
Keywords: async, tkinter

# AsyncTkinter2

`asynctkinter2` は`tkinter`用のライブラリで、 よくあるasyncライブラリと同じでコールバック関数だらけの醜いコードを読みやすくしてくれます。 例えば

- Aを出力
- 一秒待機
- Bを出力
- labelが押されるまで待機
- Cを出力

といった事を普通にやろうとするとコードは

```python
def やりたき事(label):
    bind_id = None
    print('A')

    def 一秒後に(__):
        nonlocal bind_id
        print('B')
        bind_id = label.bind("<ButtonPress>", labelが押された時に, "+")
    label.after(1000, 一秒後に)

    def labelが押された時に(event):
        label.unbind("<ButtonPress>", bind_id)
        print('C')

やりたき事(...)
```

のように読みにくい物となりますが`asynctkinter2`を用いることで

```python
import asynctkinter2 as atk

async def やりたき事(label):
    print('A')
    await atk.sleep(label, 1000)
    print('B')
    await atk.event(label, "<ButtonPress>")
    print('C')

atk.start(やりたき事(...))
```

と分かりやすく書けます。

## Installation

Pin the minor version.

```text
pip install "asynctkinter2>=0.1,<0.2"
```

## 使用例

```python
import tkinter as tk
import asynctkinter2 as atk


def main():
    root = tk.Tk()
    root_task = atk.start(async_main(root))
    root.protocol("WM_DELETE_WINDOW", lambda: (root_task.cancel(), root.destroy()))
    root.mainloop()


async def async_main(root: tk.Tk):
    label = tk.Label(root, text='Hello', font=('', 80))
    label.pack()

    # 二秒待つ
    await atk.sleep(root, 2000)

    # labelが押されるのを待つ
    event = await atk.event(label, "<ButtonPress>")
    print(f"pos: {event.x}, {event.y}")

    # labelが押される か 5秒経つまで待つ。
    tasks = await atk.wait_any(
        atk.sleep(root, 5000),
        atk.event(label, "<ButtonPress>"),
    )
    if tasks[0].finished:
        print("5秒経った")
    else:
        event = tasks[1].result
        print(f"labelが押された (pos: {event.x}, {event.y})")

    # labelが押され なおかつ 5秒経つまで待つ
    tasks = await atk.wait_all(
        atk.sleep(root, 5000),
        atk.event(label, "<ButtonPress>"),
    )

    # GUIを固まらせずにHTTPリクエストを実行し、その完了を待つ
    import requests
    res: requests.Response = await atk.run_in_thread(root, lambda: requests.get("https://httpbin.org/delay/2"))
    label["text"] = f"{res.status_code = }"


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

## `asynctkinter` との違い

現在の[asynctkinter](https://github.com/asyncgui/asynctkinter)は

- メインループは `tkinter` が元々持っている `mainloop()` ではなく独自の物を用い
- タイマー機能に関しても `tkinter` が元々持っている `after()` ではなく独自の物を用いています。

対して `asynctkinter2` では独自の物を用いないようにしています。