Metadata-Version: 2.4
Name: timedinput
Version: 2.0.0
Summary: Timeout for python inputs
Author-email: Kerollos Emad <kerollos.em@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Kerollos Emad
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Source, https://github.com/kerollosy/timedinput
Project-URL: Bug Tracker, https://github.com/kerollosy/timedinput/issues
Keywords: input,stdin,timeout,console
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.7
Classifier: Intended Audience :: Developers
Classifier: Environment :: Console
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: jupyter
Requires-Dist: ipywidgets; extra == "jupyter"
Requires-Dist: jupyter-ui-poll; extra == "jupyter"
Dynamic: license-file

# timedinput 

[![PyPI version](https://img.shields.io/pypi/v/timedinput.svg)](https://pypi.org/project/timedinput/)
[![Python versions](https://img.shields.io/pypi/pyversions/timedinput.svg)](https://pypi.org/project/timedinput/)
[![Tests](https://github.com/kerollosy/timedinput/actions/workflows/tests.yml/badge.svg)](https://github.com/kerollosy/timedinput/actions/workflows/tests.yml)
[![License](https://img.shields.io/github/license/kerollosy/timedinput.svg)](https://github.com/kerollosy/timedinput/blob/main/LICENSE)

A Python module that waits for a specified amount of time for user input. If no input is received within the given timeout period, the module returns a default value or raises an exception. 

Unlike standard timeout modules, `timedinput` actively monitors keystrokes and fully supports modern interactive environments like **Jupyter Notebooks, Google Colab, and VS Code**.

## Installation

Standard installation for standard terminals (Windows/macOS/Linux):
```bash
pip install timedinput
```

**For Jupyter/Colab Support:**
To enable timeout functionality inside Jupyter environments, install the optional UI dependencies:
```bash
pip install timedinput[jupyter]
```
*(If you use `timedinput` in Jupyter without these dependencies, it will gracefully fall back to a standard, non-timing `input()` prompt to prevent crashes).*

## Usage
The `timedinput` function takes three optional arguments: `prompt`, `timeout`, and `default`.

```python
from timedinput import timedinput

# Prompt the user for input with a timeout of 10 seconds
user_input = timedinput("Enter something: ", timeout=10)

# Prompt the user for input with a timeout of 5 seconds and a default value
user_input = timedinput("Enter something: ", timeout=5, default="default")
```

If the user enters input within the specified timeout, the function returns the user's input as a string. If the user does not enter input within the specified timeout, the function returns the default value (if one was provided) or raises a `TimeoutOccurred` exception.

## Compatibility
- **Terminals:** Works perfectly on all standard terminals across Windows and Unix-like operating systems.
- **Interactive:** Fully compatible with JupyterLab, Classic Notebook, Google Colab, and VS Code Interactive windows.

## License
Released under the MIT License. See the LICENSE file for more information.
