Skip to main content

Like python's input(), but with timeout and default value

Project description

input_timeout

Define how long you want to wait for the user's input.

After the time is over, a default value is set.

from input_timeout import InputTimeout



        i = InputTimeout(

            timeout=20,

            input_message=" >> ",

            timeout_message="'Sorry, you were not fast enough'",

            defaultvalue="slow",

            cancelbutton="esc",

            show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',

        ).finalvalue

        print(f"\n\nYour input was {i}")



        i = InputTimeout(

            timeout=5,

            input_message=" >> ",

            timeout_message="Sorry, you were not fast enough: ",

            defaultvalue="slow",

            cancelbutton="esc",

            show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',

        ).finalvalue

        print(f"\n\nYour input was {i}")



        i = InputTimeout(

            timeout=10,

            input_message=" >> ",

            timeout_message="Sorry, you were not fast enough",

            defaultvalue="Wake up!",

            cancelbutton=None,

            show_special_characters_warning=None,

        ).finalvalue

        print(f"\n\nYour input was {i}")



        i = InputTimeout(

            timeout=10,

            input_message=" >> ",

            timeout_message="Sorry, you were not fast enough",

            defaultvalue="Are you sleeping?",

            cancelbutton="esc",

            show_special_characters_warning=None,

        ).finalvalue

        print(f"\n\nYour input was {i}")



        i = InputTimeout(

            timeout=10,

            input_message=" >>",

            timeout_message="Sorry, you were not fast enough",

            defaultvalue="you are so slow",

            cancelbutton=None,

            show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',

        ).finalvalue

        print(f"\n\nYour input was {i}")

Output:

    #output

    If you want to use special characters, you have to use alt+\d\d\d\d

Press "ctrl" to see a complete list of all combinations!

 >>  babba

Your input was babba

If you want to use special characters, you have to use alt+\d\d\d\d

Press "ctrl" to see a complete list of all combinations!

alt+0192	->	À		alt+0193	->	Á		alt+0196	->	Ä		alt+0194	->	Â		

alt+0195	->	Ã		alt+0197	->	Å		alt+0198	->	Æ		alt+0228	->	ä		

alt+0224	->	à		alt+0225	->	á		alt+0226	->	â		alt+0227	->	ã		

alt+0229	->	å		alt+0230	->	æ		alt+0199	->	Ç		alt+0231	->	ç		

alt+0208	->	Ð		alt+0240	->	ð		alt+0203	->	Ë		alt+0200	->	È		

alt+0201	->	É		alt+0202	->	Ê		alt+0235	->	ë		alt+0232	->	è		

alt+0233	->	é		alt+0234	->	ê		alt+0207	->	Ï		alt+0204	->	Ì		

alt+0205	->	Í		alt+0206	->	Î		alt+0239	->	ï		alt+0236	->	ì		

alt+0237	->	í		alt+0238	->	î		alt+0209	->	Ñ		alt+0241	->	ñ		

alt+0214	->	Ö		alt+0210	->	Ò		alt+0211	->	Ó		alt+0212	->	Ô		

alt+0213	->	Õ		alt+0216	->	Ø		alt+0140	->	Œ		alt+0246	->	ö		

alt+0242	->	ò		alt+0243	->	ó		alt+0244	->	ô		alt+0245	->	õ		

alt+0248	->	ø		alt+0156	->	œ		alt+0138	->	Š		alt+0223	->	ß		

alt+0154	->	š		alt+0222	->	Þ		alt+0254	->	þ		alt+0220	->	Ü		

alt+0217	->	Ù		alt+0218	->	Ú		alt+0219	->	Û		alt+0252	->	ü		

alt+0249	->	ù		alt+0250	->	ú		alt+0251	->	û		alt+0159	->	Ÿ		

alt+0221	->	Ý		alt+0255	->	ÿ		alt+0253	->	ý		alt+0168	->	¨		

alt+0136	->	ˆ		alt+0180	->	´		alt+0175	->	¯		alt+0184	->	¸		

alt+0192	->	À		alt+0193	->	Á		alt+0196	->	Ä		alt+0194	->	Â		

alt+0195	->	Ã		alt+0197	->	Å		alt+0198	->	Æ		alt+0228	->	ä		

alt+0224	->	à		alt+0225	->	á		alt+0226	->	â		alt+0227	->	ã		

alt+0229	->	å		alt+0230	->	æ		alt+0199	->	Ç		alt+0231	->	ç		

alt+0208	->	Ð		alt+0240	->	ð		alt+0203	->	Ë		alt+0200	->	È		

alt+0201	->	É		alt+0202	->	Ê		alt+0235	->	ë		alt+0232	->	è		

alt+0233	->	é		alt+0234	->	ê		alt+0207	->	Ï		alt+0204	->	Ì		

alt+0205	->	Í		alt+0206	->	Î		alt+0239	->	ï		alt+0236	->	ì		

alt+0237	->	í		alt+0238	->	î		alt+0209	->	Ñ		alt+0241	->	ñ		

alt+0214	->	Ö		alt+0210	->	Ò		alt+0211	->	Ó		alt+0212	->	Ô		

alt+0213	->	Õ		alt+0216	->	Ø		alt+0140	->	Œ		alt+0246	->	ö		

alt+0242	->	ò		alt+0243	->	ó		alt+0244	->	ô		alt+0245	->	õ		

alt+0248	->	ø		alt+0156	->	œ		alt+0138	->	Š		alt+0223	->	ß		

alt+0154	->	š		alt+0222	->	Þ		alt+0254	->	þ		alt+0220	->	Ü		

alt+0217	->	Ù		alt+0218	->	Ú		alt+0219	->	Û		alt+0252	->	ü		

alt+0249	->	ù		alt+0250	->	ú		alt+0251	->	û		alt+0159	->	Ÿ		

alt+0221	->	Ý		alt+0255	->	ÿ		alt+0253	->	ý		alt+0168	->	¨		

alt+0136	->	ˆ		alt+0180	->	´		alt+0175	->	¯		alt+0184	->	¸		

Sorry, you were not fast enough: 

Your input was slow

 >>  super

Your input was super

 >>  adasa

Your input was adasa

If you want to use special characters, you have to use alt+\d\d\d\d

Press "ctrl" to see a complete list of all combinations!

Sorry, you were not fast enough

Your input was you are so slow

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

input_timeout-0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

input_timeout-0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file input_timeout-0.1.tar.gz.

File metadata

  • Download URL: input_timeout-0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for input_timeout-0.1.tar.gz
Algorithm Hash digest
SHA256 c13eb1d52b329aef0771155d720c11464bfb22ee6c240ec60a19f5d1084f1363
MD5 c7e65978753d62620341b13ab8cdccda
BLAKE2b-256 cc4bad40568a47a7642c7e4ccc0b21c5c5be4f4901db31d95438c63727b255ef

See more details on using hashes here.

Provenance

File details

Details for the file input_timeout-0.1-py3-none-any.whl.

File metadata

  • Download URL: input_timeout-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for input_timeout-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e20590ec3debefad733450aa1718e6928296b24dd5d1162d6e261bd48b0218f
MD5 b1b78da3c4fa4867880a3756732c0a01
BLAKE2b-256 d4c224cffbe6f77b3b05d467fbe24fe27cb31c94bb1608adccae52bd51a3c9e3

See more details on using hashes here.

Provenance

Supported by

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