For example this is my function:
def get_sum(item1, item2):
print(int(item1) + int(item2))
But I want to trigger that function when user clicks at a certain item in command prompt or any terminal.
Main question:
Is it possible to run functions by clicking in terminal?
Extra:
And I also saw a VS Code extension development output in terminal. When I run yo code
it shows very nice thing. And user can select the things with the arrow keys and press enter to run it. So could this also be possible in python?
Don't know about key pressing but I found myself an answer:-
We can use the keyboard
module.
import keyboard
abc = True
def run_func():
print('Hi, welcome!')
print('If you want to do this, press A or press B for doing that.')
while abc:
if keyboard.is_pressed('a'):
print('This function is run!')
abc = True
elif keyboard.is_pressed('b'):
print('That function is run!')
abc = True
print('To start press S')
while abc:
if keyboard.is_pressed('S'):
run_func()
abc = True
Use: When we press key we can run functions and many things!