Print before input
Project description
inputer: Print before input
If you want to print something before Python default function input() prompt, you can use this package inputer. To achieve this, inputer give you a object to control input like this:
import inputer
import threading
import time
input_handle = inputer.Inputer()
def always_print(input_handle):
while True:
input_handle.print_before("I am here!")
time.sleep(1)
th = threading.Thread(target=always_print, args=(input_handle,), daemon=True)
th.start()
while True:
text = input_handle.input("> ")
if text == "exit":
break
In addition, you can use following methods of Inputer
to control input:
Inputer.input(prompt='')
: Just like Python default functioninput
;Inputer.print_before(*args, **kwargs)
: Just like Python default functionprint
but print before input prompt;Inputer.eprint_before(*args, **kwargs)
: Print before input prompt to stdandar error;Inputer.left(n=1)
: Move current cursor backn
position, just like pressleft
key on keybord;Inputer.right(n=1)
: Move current cursor forwardn
position, just like pressright
key on keybord;Inputer.up(n=1)
: Change current input buffer to last input text, just like pressup
key on keybord;Inputer.down(n=1)
: Change current input buffer to next input text, just like pressdown
key on keybord;Inputer.backspace(n=1)
: Left deleten
characters, just like pressbackspace
key on keybord;Inputer.delete(n=1)
: Right deleten
characters, just like pressdel
key on keybord;Inputer.current_str
: Get current input buffer text;Inputer.current_cursor
: Get current cursor position;Inputer.insert(text)
: Inserttext
at current cursor position;Inputer.hide()
: Hide prompt text and user input text;Inputer.unhide()
: Show prompt text and user input text again;Inputer.block()
: Forbidden user input;Inputer.unblock()
: Allow user input again;Inputer.use_history(history_filename)
: All history input is saved in a history file even if you don't call this method. This method allow you to specify a history file to save history input in;
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
inputer-0.0.2.tar.gz
(3.8 kB
view hashes)