advanced-input


Nameadvanced-input JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/NightKey/advanced-input
SummaryIO Extention
upload_time2024-05-01 14:50:55
maintainerNone
docs_urlNone
authorJanthó Dávid
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Advanced Input

Advanced input for python, where you can read in just one character or have inputs priority ordered.

## Usage

```py
from advanced-input import get_advanced_input, PriorityOrder
from threading import Thread
from time import sleep

input_handler = get_advanced_input()

def thread_one():
    user_input = input_handler.input(priority=PriorityOrder.High)
    print(user_input)

def main():
    backgroundThread = Thread(target=thread_one)
    backgroundThread.start()
    sleep(.1)
    input_handler.read("Press any character to exit...", PriorityOrder.Low)
    input_handler.stop()
```

This will result in a user input for `thread_one` being created before the `main` function's exit will be available. Normally, this would result in the program exiting, before accepting the user input of `thread_one`. With this, thread one will be in a higher priority than `main`, and that will be the first to be served the user's input. Additionally, `Read()` returns when one character is pressed.

If there are multiple inputs with the same priority, it will return them in a first come last serve method.

## Windows quirks

Due to how Windows works with new line (\r\n), on Windows it is not possible to read the "Carriage Return" (\r) character. It will always return "Line Feed" (\n) instead.
Due to how Windows console works, the default (utf-8) encoding input will not work with some special character. For it to work, please specify the encoding of your system.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NightKey/advanced-input",
    "name": "advanced-input",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Janth\u00f3 D\u00e1vid",
    "author_email": "davidjantho@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/65/815c27017ac44c26dc239cee2f35bedd5885394ba5e24986da84bd36d82c/advanced_input-0.2.2.tar.gz",
    "platform": null,
    "description": "# Advanced Input\r\n\r\nAdvanced input for python, where you can read in just one character or have inputs priority ordered.\r\n\r\n## Usage\r\n\r\n```py\r\nfrom advanced-input import get_advanced_input, PriorityOrder\r\nfrom threading import Thread\r\nfrom time import sleep\r\n\r\ninput_handler = get_advanced_input()\r\n\r\ndef thread_one():\r\n    user_input = input_handler.input(priority=PriorityOrder.High)\r\n    print(user_input)\r\n\r\ndef main():\r\n    backgroundThread = Thread(target=thread_one)\r\n    backgroundThread.start()\r\n    sleep(.1)\r\n    input_handler.read(\"Press any character to exit...\", PriorityOrder.Low)\r\n    input_handler.stop()\r\n```\r\n\r\nThis will result in a user input for `thread_one` being created before the `main` function's exit will be available. Normally, this would result in the program exiting, before accepting the user input of `thread_one`. With this, thread one will be in a higher priority than `main`, and that will be the first to be served the user's input. Additionally, `Read()` returns when one character is pressed.\r\n\r\nIf there are multiple inputs with the same priority, it will return them in a first come last serve method.\r\n\r\n## Windows quirks\r\n\r\nDue to how Windows works with new line (\\r\\n), on Windows it is not possible to read the \"Carriage Return\" (\\r) character. It will always return \"Line Feed\" (\\n) instead.\r\nDue to how Windows console works, the default (utf-8) encoding input will not work with some special character. For it to work, please specify the encoding of your system.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "IO Extention",
    "version": "0.2.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/NightKey/advanced-input/issues",
        "Homepage": "https://github.com/NightKey/advanced-input"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dc2fde5e1ae717326eda566849ebad6964e4c822745ec55c8fdd531eafb3d01",
                "md5": "0b1e33fa6ff1ef0bf324eef536dae994",
                "sha256": "536f4336e42e3c6a5cc24f92459fca5d8f14187577dc4ff505c9ae10d842e358"
            },
            "downloads": -1,
            "filename": "advanced_input-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b1e33fa6ff1ef0bf324eef536dae994",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 43677,
            "upload_time": "2024-05-01T14:50:53",
            "upload_time_iso_8601": "2024-05-01T14:50:53.753387Z",
            "url": "https://files.pythonhosted.org/packages/9d/c2/fde5e1ae717326eda566849ebad6964e4c822745ec55c8fdd531eafb3d01/advanced_input-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a165815c27017ac44c26dc239cee2f35bedd5885394ba5e24986da84bd36d82c",
                "md5": "9befc39cc8ee67c0e61cb41391db8790",
                "sha256": "a3902b91361e20b92c6d2fafbe1fc283a072b2ef8ab7aa73fe50c0fed487da38"
            },
            "downloads": -1,
            "filename": "advanced_input-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9befc39cc8ee67c0e61cb41391db8790",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 43586,
            "upload_time": "2024-05-01T14:50:55",
            "upload_time_iso_8601": "2024-05-01T14:50:55.021363Z",
            "url": "https://files.pythonhosted.org/packages/a1/65/815c27017ac44c26dc239cee2f35bedd5885394ba5e24986da84bd36d82c/advanced_input-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-01 14:50:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NightKey",
    "github_project": "advanced-input",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "advanced-input"
}
        
Elapsed time: 0.34285s