Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

bouton

import threading
import queue
import time

def read_kbd_input(inputQueue):
    print('Ready for keyboard input:')
    while (True):
        input_str = input()
        inputQueue.put(input_str)

def main():
    EXIT_COMMAND = "exit"
    inputQueue = queue.Queue()

    inputThread = threading.Thread(target=read_kbd_input, args=(inputQueue,), daemon=True)
    inputThread.start()

    while (True):
        if (inputQueue.qsize() > 0):
            input_str = inputQueue.get()
            print("input_str = {}".format(input_str))

            if (input_str == EXIT_COMMAND):
                print("Exiting serial terminal.")
                break

            # Insert your code here to do whatever you want with the input_str.

        # The rest of your program goes here.

        time.sleep(0.01) 
    print("End.")

if (__name__ == '__main__'): 
    main()
Comment

PREVIOUS NEXT
Code Example
Python :: how to do alignment of fasta in biopython 
Python :: raspberry pi set python 3 as default 
Python :: run server localhost for shar file 
Python :: knn compute_distances_one_loop 
Python :: parameter name in string 
Python :: python tkinter.ttk combobox down event on mouseclick 
Python :: python raw strings 
Python :: python extract multiple values from a single cell in a dataframe column using pandas 
Python :: store dataframes 
Python :: extract data using selenium and disable javascript 
Python :: heatmap colorbar label 
Python :: how to end if else statement in python 
Python :: django insert data into database without form 
Python :: Dynamic use of templates in Jinja2 
Python :: Django, limit queryset without slicing 
Python :: python compare number with a precision 
Python :: python for loop skip iteration if condition not met jinja 
Python :: ring Sort List Item 
Python :: store image in django postprocessimage in django storage 
Python :: Hiding and encrypting passwords in Python using advpass() module 
Python :: Python soma números 
Python :: matplotlib doesnt show suptitle 
Python :: python launch ipython from script 
Python :: django save another class data while saving a class 
Python :: python seeded random 
Python :: defaultdict python inport 
Python :: how to change text in a canvas tkinter 
Python :: count numbers that add up to 10 in python 
Python :: affinity propagation cosine similarity python 
Python :: any(iterable) 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =